akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> d(n);
	rep(i,n) cin >> d.at(i);
	int m;cin >> m;
	vector<int> t(m);
	rep(i,m) cin >> t.at(i);
	sort(d.begin(),d.end());
	sort(t.begin(),t.end());
	int i=0,j=0;
	while(j<m){
		if(i>=n || d[i]>t[j]){
			cout << "NO" << endl;
			return 0;
		}
		if(d[i]==t[j]){
			i++;
			j++;
		}
		else i++;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1792
num = gets.to_i
def check_three(n)
  return false if n == 0
  n /= 10
  return true if n % 10 == 3
  check_three(n)
end

(1..num).each do |n|
  print " #{n}" if n % 3 == 0 || n % 10 == 3 || check_three(n)
end
puts ""



Measured memory_bytes: 8876
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(set(a))
count = 0
z = 0
for i in b:
    if i > n:
        count += n-z
        break
    else:
        j = a.count(i)
        if j < i:
            count += j
            z += j
        else:
            count += j-i
            z += j
print(count)

Measured memory_bytes: 20760
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    int l[n];
    int num = 1;
    int l0 = 0;
    for (int i=0; i < n; i++){
        cin >> l[i];
        l0 += l[i];
        if (l0 <= x){
            num += 1;
        }
        else{
            break;
        }
    }
    cout << num << endl;
}

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

 using namespace std;
 
 #define inf ((1<<31)-1)
 #define inf64 ((1<<63)-1)
 #define odd(x) (x&1)
 #define pow2(x) (1<<x)
 #define log2bin(x) (32-__builtin_clz(x)-1)
 #define popcnt(x) __builtin_popcount(x)
 #define m7(x) (x%1000000007)
 #define swapi(x,y) x^=y;y^=x;x^=y
 #define forinc(var,from,to) for(auto var=from,To=to;var!=To;var++) // bisa untuk iter jg
 #define fordec(var,from,to) for(auto var=from,To=to;var!=To;var--)
 #define fors(var,s) for(int var=0;s[var];var++)
 #define ll long long
 #define rational tuple<bool,long long,long long>
 #define point pair<long long,long long>
 #define mpr make_pair
 #define mtp make_tuple
 #define pb emplace_back

 #define _tab '\t'
 #define $ <<_tab<<

 #define cinarr(A,len) for(int i=0;i<len;i++){cin>>A[i];}
 #define coutarr(A,len) for(int i=0;i<len;i++){cout<<A[i]<<' ';}cout<<endl
 #define coutin(V) for(auto& i : V){cout << i << ' ';}cout<<endl // for vect and set
 #define coutmap(U) for(auto& i : U){cout << i.first << "->" << i.second << ", ";}cout<<endl // for map

 // DEBUG
 #define deb(x) cout << #x << '\t' << x << endl

 // ==== fast function ====
 /*
 #define sortsec(T1,T2) [](const pair<T1,T2> &a,const pair<T1,T2> &b){ return a.second<b.second;}
 #define sortsecgreater(T1,T2) [](const pair<T1,T2> &a,const pair<T1,T2> &b){ return a.second>b.second;}
 */

/*========================================================================*/
/* strategi/note:



/================================*/



bool solved=0;
void solve(){solved=1;
    int n;
    cin >> n;
    int A[n];
    cinarr(A,n);
    int ans = 0;
    for(int i = 0; i<n-2; i++){
        for(int j = i+1; j<n-1; j++){
            for(int k = j+1; k<n; k++){
                if(A[i]+A[j]>A[k] and A[i]+A[k]>A[j] and A[j]+A[k]>A[i] //syarat bisa membentuk
                    and A[i]!=A[j] and A[j]!=A[k] and A[i]!=A[k]){ // syarat soal
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

int main(){
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     //cout<<fixed<<setprecision( ); // iomanip **

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

     if(!solved)cout<<"solve() function blm dipanggil!"<<endl;
	 //cout.flush(); cin.get();
     return 0;
}


Measured memory_bytes: 3660
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	if text[2] == text[3] && text[4] == text[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int MOD = 1000'000'007;
const double EPS = 0.000'000'001;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

const int N = 100010;
int dp[N], h[N];
int n;

int solve(int i)
{
	if(i == n - 1) return 0;
	if(i >= n) return MOD;

	int& r = dp[i];

	if(r == -1)
	{
		int a = solve(i + 1) + (i + 1 < n ? abs(h[i] - h[i + 1]) : MOD);
		int b = solve(i + 2) + (i + 2 < n ? abs(h[i] - h[i + 2]) : MOD);
		r = min(a, b);
	}

	return r;
}

int main()
{
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);
	cout.precision(10);
	
	cin >> n;

	memset(dp, -1, sizeof(dp));

	for(int i = 0; i < n; i++) cin >> h[i];

	cout << solve(0) << endl;
	
	//cerr << "Tempo de execucao: " << (double)clock() / CLOCKS_PER_SEC << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),cnt(n);
    ll tmp;
    rep(i,n){
        cin >> tmp;
        tmp--;
        a[i] = tmp;
        cnt[tmp]++;//
    }
ll sum = 0;
    rep(i,n){
        //if(cnt[i] > 1){
            sum += (cnt[i] * (cnt[i]-1))/2;
        //}
    }

    tmp = 0;
    rep(i,n){
        //if(cnt[a[i]] > 1){
            tmp = -1*((cnt[a[i]]) *   (cnt[a[i]] - 1))/2;
            tmp +=   ((cnt[a[i]]-1) * (cnt[a[i]] - 2))/2;
        //}
        cout << sum + tmp << endl;
    }

    return 0;
}

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

int main(){
  long long n,m;
  cin >> n >> m;
  vector<pair<int, int>> p(n);
  for(int i=0; i<n; i++){
    int a,b;
    cin >> a >> b;
    p.at(i) = make_pair(a, b);
  }
  sort(p.begin(),p.end());
  long long sum=0, ans=0;
  for(int i=0; i<n; i++){
    pair<int, int> q=p.at(i);
    if(q.second <= m-sum){
      sum += (long long)(q.second);
      ans += (long long)(q.first)*(long long)(q.second);
    }else{
      ans += (long long)(m-sum)*(long long)(q.first);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 3005
#define M 51
#define INF 1000000007
#define MOD 924844033
#define MOD2 1000000009
#define eps 1e-14
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}

int from[N][2],to[N][2];
ll fac[N];
int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        MST(from,0);
        from[0][0] = 1;
        int up = min(n,2*k);
        FOR(i,1,up)
        {
            if(i>k)FOR(j,0,n)swap(from[j][0],from[j][1]);
            for(int x = i;x<=n;x+=2*k)
            {
                MST(to,0);
                FOR(y,0,n)
                {
                    //prev
                    if(y>0)to[y][1] = (to[y][0]+from[y-1][1])%MOD;
                    //none
                    to[y][1] = (to[y][1]+(from[y][0]+from[y][1])%MOD)%MOD;
                    //next
                    if(x+k<=n&&y>0)to[y][0] = (to[y][0]+(from[y-1][0]+from[y-1][1])%MOD)%MOD;
                }
                swap(from,to);
            }
            FOR(j,0,n)
            {
                from[j][0] = (from[j][0]+from[j][1])%MOD;
                from[j][1] = 0;
            }
        }
        fac[0] = 1;
        FOR(i,1,n)fac[i] = fac[i-1]*i%MOD;

        ll ans = 0;
        FOR(i,0,n)
        {
            //cout<<i<<" "<<from[i][0]<<endl;
            ans = (ans+(i%2?-1:1)*fac[n-i]*from[i][0])%MOD;
        }
        cout<<((ans+MOD)%MOD+MOD)%MOD<<endl;
    }
    return 0;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;




int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> counts(26, 0);
    for (char c : s) counts[c - 'a']++;
    ll ans = 0;
    rep(i, n) {
        counts[s[i] - 'a']--;
        ll l = s.size() - i - 1;
        ll now = l - counts[s[i] - 'a'];
        ans += now;
    }
    ans++;
    cout << ans << endl;
}

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

using namespace std;
typedef unsigned long long ull;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ull n, k;
    cin >> n >> k;

    ull hist[100001] = {0};
    for (int i = 0; i < n; i ++) {
        ull a, b;
        cin >> a >> b;
        hist[a] += b;
    }

    for (int i = 1; i < 100001; i ++) {
        if (hist[i] >= k) {
            cout << i;
            break;
        }
        k -= hist[i];
    }

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int x, l[4] = {0};
	for (int i = 0; i < 6; i++) {
		scanf("%d", &x);
		l[x - 1]++;
	}
	qsort(l, 4, sizeof(int), cmpint);
	if (l[0] == 1 && l[1] == 1 && l[2] == 2 && l[3] == 2) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
def examE(mod):
    N = I()
    A = LI()
    a =[0,0,0]
    cur = 1
    for i in A:
        if a[0]==i:
            if a[0]==a[1]:
                if a[1]==a[2]:
                    cur *= 3
                else:
                    cur *=2
            a[0]+=1
        elif a[1]==i:
            if a[1] == a[2]:
                cur *= 2
            a[1] +=1
        elif a[2]==i:
            a[2]+=1
        else:
            cur *=0
        a.sort(reverse=True)
        cur %=mod
    print(cur)
    return

def examF():
    return

import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examE(mod)


Measured memory_bytes: 54896
#include<bits/stdc++.h>
using namespace std;
                                                                                                                                     
int main(){
        int a, b, c;
        cin >> a >> b >> c;

        if(a == b && b == c || (a != b && a != c && b != c)) cout << "No" << endl;
        else                 cout << "Yes" << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
 
int main(){
  int i, n, count = 0;
  cin >> n;
  vector<int> a(n);
  
  for (i=0; i<n; i++){
    cin >> a[i];
  }
  
  i = 0;
  while(a[i] % 2 == 0){
    a[i] = a[i] / 2;
    if (i == n-1){
      i = 0;
      count++;
    }
    i++;
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
  ll N;
  cin >> N;
  if(N % 1000 == 0){
    cout << 0 << endl;
  }
  else{
    cout << 1000 - N % 1000 << endl;
  }
}

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

long long N,arr[200001];

int main(){
	cin>>N;
	long long total=0;
	for(int i=0; i<N; i++){
		cin>>arr[i];
		total=total^arr[i];
	}
	long long tmp=total^arr[0];
	cout<<tmp;
	for(int i=1; i<N; i++){
		tmp=total^arr[i];
		cout<<" "<<tmp;
	}
	cout<<'\n';
}

Measured memory_bytes: 5120
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
  int a, b;
  cin >> a >> b;

  int i;
  for(i = 1;;i *= 10) {
    if(b - i < 0) {
      break;
    }
  }

  if(sqrt(a * i + b) - (int)sqrt(a * i + b) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
H,W,D = map(int,input().split())
Point = {}
for y in range(H) :
    line = list(map(int,input().split()))
    for x,p in enumerate(line) :
        Point[p] = (y,x)

Q = int(input())

def dist(ny,nx,py,px) :
    return abs(ny-py) + abs(nx-px)

Cost = [0]*(H*W+1)
for i in range(D+1, H*W+1) :
    yi,xi = Point[i-D]
    yj,xj = Point[i]
    Cost[i] = Cost[i-D] + dist(yi,xi,yj,xj)


for i in range(Q) :
    l,r = map(int,input().split())
    print(Cost[r] - Cost[l])


Measured memory_bytes: 67036
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin >> s;
	long long sum = 0;
	int n = s.size()-1;

	for (int bit = 0; bit < (1 << n); bit++) {
		long long t = s[0] - '0';

		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				sum += t;
				t = s[i+1] - '0';
			} else {
				t *= 10;
				t += s[i+1] - '0';
			}
		}
		sum += t;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 100000;
ll mod = INF;

int n;
int h[maxn];

int main(){
    cin >> n;
    rep(i,n)cin >> h[i];
    int ans=0;
    int streak=0;
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            streak++;
        }else{
            ans=max(ans,streak);
            streak=0;
        }
        if(i==n-2)ans=max(ans,streak);
    }

    cout << ans<<endl;

    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;


int H, N;
int ans;
pair<double,pair<int,int>> A[10001];
int dp[20001];

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


	FOR(i, 0, 20001)dp[i] = INF;

	cin >> H >> N;

	dp[0] = 0;

	FOR(i, 0, N) {
		cin >> A[i].second.first>>A[i].second.second;
		A[i].first = double(A[i].second.second) / double(A[i].second.first);
	}
	sort(A, A+ N);
	
	for (int i = 0; i < N;i++) {
		pair<int, int> cur = A[i].second;
		

		dp[cur.first] = min(dp[cur.first],cur.second);
		for (int k=1;k<=H;k++){
			if (dp[k] != INF)dp[k + cur.first] = min(dp[k + cur.first], dp[k] + cur.second);
		}

	}
	int ans = INF;
	for (int i = H; i <= 20000; i++) {
		ans = min(dp[i], ans);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
while(1){
  int n,m;
  int p[10000];
  int sum=0;
  cin>>n>>m;
  if(n==0 && m==0) break;
  for(int i=0;i<n;i++){
    cin>>p[i];
    }
  for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++){
      if(p[j]<p[j+1]) swap(p[j],p[j+1]);
      }
    }
  for(int i=0;i<n;i++){
    if(i%m==m-1) p[i]=0;
    }
  for(int i=0;i<n;i++){
    sum+=p[i];
    }
  cout<<sum<<endl;
}

  return 0;
}


Measured memory_bytes: 3020
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>

using namespace std;

#define N 100001

int dsu[N],numUnsat[N];
long long sum[N];
int f(int x) {
  return dsu[x] ==x ? x : dsu[x] = f(dsu[x]);
}
void merge(int &ret,int x,int y,int wei) {
  x = f(x),y = f(y);
  if(x==y) {
    ++numUnsat[x];
  } else {
    sum[x] += sum[y];
    dsu[y] = x;
    numUnsat[x] = numUnsat[x] + numUnsat[y] + 1;
  }
  if(sum[x]>=wei) {
    ret += numUnsat[x];
    numUnsat[x] = 0;
  }
}
void solve() {
  int n,m;scanf("%d %d",&n,&m);
  pair<int,pair<int,int> > edge[N];
  for(int i=1;i<=n;++i) {
    int x;scanf("%d",&x);
    dsu[i] = i;
    numUnsat[i] = 0;
    sum[i] = x;
  }
  for(int i=0;i<m;++i) {
    int a,b,w;scanf("%d %d %d ",&a,&b,&w);
    edge[i] = make_pair(w,make_pair(a,b));
  }
  sort(edge,edge+m);
  int ret = 0;
  for(int i=0;i<m;++i) {
    merge(ret, edge[i].second.first,edge[i].second.second,edge[i].first);
  }
  printf("%d\n",m-ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

using namespace std;

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

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

	int input[100000];
	int index = 0, res= 0, f = 0;
	rep(i, N) scanf("%d", &input[i]);
	sort(input, input + N);
	while (index < N){
		int tem = input[index];
		while(tem == input[index]) f++, index++;
		res += f%2;
		f = 0;
	}
	printf("%d\n", res);
	return 0;
}

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

int main() {
    int N, x = 0;
    string S;
    cin >> N >> S;

    vector<int> mem(N, 0);

    for (int i = 0; i < N; i++) {
        if (S.at(i) == 'I') {
            x++;
            mem.at(i) = x;
        }
        else {
            x--;
            mem.at(i) = x;
        }
    }

    sort(mem.begin(), mem.end());
    reverse(mem.begin(), mem.end());
    if (0 <= mem.at(0)) {
        cout << mem.at(0) << endl;
    }
    else {
        cout << 0 << endl;
    }
    
}

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

#define MOD 1000000007
#define MAX 2000001// [n+1] 1_origin
ll fac[MAX]; // 階乗 n!
ll inv[MAX]; // 逆元 1/n
ll finv[MAX]; // 逆元の階乗 (n^-1)! = (1/n)!

// n 個の配列に、mod p で前処理する
void init(int n, int p){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<=n; ++i){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p/i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}

// nCr(mod m)
ll nCr(int n, int r, int m){
	if(n<r || n<0 || r<0) return 0;
	return fac[n] * (finv[n-r] * finv[r] % m) % m;
}

// a^n mod m
ll modpow(ll a, ll n, ll m) {
	ll x = 1;
	while(n > 0){
		if(n & 1) x = x * a % m;
		a = a * a % m;
		n >>= 1;
	}
	return x;
}

int main(){
	int K; string S; cin>>K>>S;
	init(K + S.size(), MOD);
	ll ans = 0;
	for(int i=0; i<=K; ++i){
		ll a = modpow(25, i, MOD);
		ll b = modpow(26, K-i, MOD);
		ll c = nCr(i+S.size()-1, S.size()-1, MOD);
		a *= b * c % MOD;
		a %= MOD;
		ans += a;
		ans %= MOD;
	}
	cout<< ans <<endl;
}


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

int main()
{
    long long int L,R,d,c;
    L = R = d = c = 0;

    cin>>L>>R>>d;

    for( ;L<=R;L++)
    {
        if(L%d == 0)
        {
            c++;
        }
    }

    cout<<c;
    return 0;
}


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

using namespace std;

//#define FILE_IO

const int mod = 1e9 + 7;

int N;
int a[200005], b[200005];
int dp[4005][4005];

int fct[8005], ifct[8005];

int power(int x, int y)
{
    int p = x, r = 1;
    while(y)
    {
        if(y & 1)   r = (1LL * r * p) % mod;
        p = (1LL * p * p) % mod;
        y >>= 1;
    }
    return r;
}

int C(int N, int K)
{
    int ans = fct[N];
    ans = (1LL * ans * ifct[K]) % mod;
    ans = (1LL * ans * ifct[N - K]) % mod;
    return ans;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    fct[0] = 1;
    for(int i = 1; i <= 8000; i++)
        fct[i] = (1LL * fct[i - 1] * i) % mod;
    ifct[8000] = power(fct[8000], mod - 2);
    for(int i = 8000 - 1; i >= 1; i--)
        ifct[i] = (1LL * ifct[i + 1] * (i + 1)) % mod;
    ifct[0] = 1;

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d%d", &a[i], &b[i]);
        dp[ 2000 - a[i] ][ 2000 - b[i] ]++;
    }

    for(int i = 0; i <= 4000; i++)
        for(int j = 0; j <= 4000; j++)
        {
            if(i > 0)   (dp[i][j] += dp[i - 1][j]) %= mod;
            if(j > 0)   (dp[i][j] += dp[i][j - 1]) %= mod;
        }

    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        (ans += dp[ a[i] + 2000 ][ b[i] + 2000 ]) %= mod;
        int mns = C(2 * a[i] + 2 * b[i], 2 * a[i]);
        ans = (ans - mns + mod) % mod;
    }

    int inv2 = power(2, mod - 2);
    ans = (1LL * ans * inv2) % mod;

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

    return 0;
}


Measured memory_bytes: 64512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    ll n,x,m;
    cin >> n >> x >> m;
    vector<vector<ll>> sum(40,vector<ll>(m));
    vector<vector<ll>> doubling(40,vector<ll>(m));

    for(ll i = 0; i < m; i++){
        sum[0][i] = i;
        doubling[0][i] = i*i%m;
    }

    for(int i = 0; i < 40-1; i++){
        for(int j = 0; j < m; j++){
            doubling[i+1][j] = doubling[i][doubling[i][j]];
            sum[i+1][j] = sum[i][j]+sum[i][doubling[i][j]];
        }
    }

    ll now = x, ans = 0;
    for(ll i = 40-1; i >= 0; i--){
        if(n >> i & 1){
            ans += sum[i][now];
            now = doubling[i][now];
        }
    }

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

Measured memory_bytes: 66616
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline ll ri()
{
	register ll x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(ll x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=1e5+7;
ll x[N],cx[N],v[N],f0[N],f1[N],cf0[N],cf1[N],mf0[N],mf1[N],mcf0[N],mcf1[N];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ll n=ri(),c=ri(),i,ans=0;
	for(i=1;i<=n;i++)	x[i]=ri(),v[i]=ri(),cx[i]=c-x[i];
	for(i=1;i<=n;i++)
	{
		f1[i]=f1[i-1]+v[i]-(x[i]-x[i-1]);
		f0[i]=f0[i-1]+v[i]-2*(x[i]-x[i-1]);
		mf0[i]=max(mf0[i-1],f0[i]);
		mf1[i]=max(mf1[i-1],f1[i]);
		ans=max(ans,f1[i]);
	}
	for(i=n;i>=1;i--)
	{
		cf1[i]=cf1[i+1]+v[i]-(cx[i]-cx[i+1]);
		cf0[i]=cf0[i+1]+v[i]-2*(cx[i]-cx[i+1]);
		mcf0[i]=max(mcf0[i+1],cf0[i]);
		mcf1[i]=max(mcf1[i+1],cf1[i]);
		ans=max(ans,cf1[i]);
	}
	for(i=1;i<n;i++)
	{
		ans=max(ans,mf0[i]+mcf1[i+1]);
		ans=max(ans,mf1[i]+mcf0[i+1]);
	}
	wi(ans);putchar('\n');
	return 0;
}
/*
3 20
2 80
9 120
16 1

191

3 20
2 80
9 1
16 120

15 10000000000
400000000 1000000000
800000000 1000000000
1900000000 1000000000
2400000000 1000000000
2900000000 1000000000
3300000000 1000000000
3700000000 1000000000
3800000000 1000000000
4000000000 1000000000
4100000000 1000000000
5200000000 1000000000
6600000000 1000000000
8000000000 1000000000
9300000000 1000000000
9700000000 1000000000

*/

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

using namespace std;

#define pii pair<int,int>
#define pb push_back
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define MOD 1000000007


int main() {
//     fstream fin,fout;
//     fin.open("sample.txt");
//     fout.open("res.txt");
   int n,k;
   cin>>n>>k;
   
   vi v(n);
   for(int i=0;i<n;i++) cin>>v[i];
   sort(v.begin(),v.end());
   
   int sum = 0;
   for(int i=0;i<k;i++) sum+=v[i];
   
   cout<<sum;
//     cout << duration.count() << endl;
//     fin.close();
//     fout.close();
    return 0;
}



Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 1000000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int minn = MAX, maxx = -MAX, n;
	
	cin >> n;
	
	vector<int> ar(n);

	for (int i = 0; i < n; ++i) {
		cin >> ar[i];
		minn = min(minn,ar[i]);
		maxx = max(maxx,ar[i]);
	}

	int ans = MAX;

	for (int k = minn; k < maxx + 1; ++k) {
		int sum = 0;

		for (int i = 0; i < ar.size(); ++i) {
			sum += (ar[i] - k)*(ar[i] - k);
		}
		
		ans = min(sum, ans);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
cond1 = ['R','U','D']
cond2 = ['L','U','D']

S = list(input())

for i in range(len(S)):
  if i % 2 == 0:
    if not (S[i] in cond1):
      print('No')
      exit()
  else:
    if not (S[i] in cond2):
      print('No')
      exit()
      
print('Yes')

Measured memory_bytes: 3060
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(s: str, t: str) -> bool:
    if len(t) != len(s) + 1:
        return False
    return t[: len(s)] == s


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    S = input()
    T = input()
    result = solve(S, T)
    print("Yes" if result else "No")


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)


Measured memory_bytes: 82632
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;

int main() {
  int n, maxv, minv, r;

  scanf("%d", &n);
  maxv = INT_MIN;
  scanf("%d", &minv);

  for (int i = 1; i < n; i++) {
    scanf("%d", &r);
    maxv = max(maxv, r - minv);
    minv = min(minv, r);
  }

  printf("%d\n", maxv);
  return 0;
}

Measured memory_bytes: 2752
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int n, m, i, p = 0, k;
	vector<int> d, t;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &k);
		d.push_back(k);
	}
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%d", &k);
		t.push_back(k);
	}

	sort(d.begin(), d.end());
	sort(t.begin(), t.end());

	for (i = 0; i < n; i++) {
		if (d[i] == t[p]) {
			p++;
		}
		if (p == m) {
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");

	return 0;
}

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

struct seg {
  int balance, min;
};
bool operator<(seg a, seg b) {
  return a.min > b.min;
}

bool check(vector<seg> plus) {
  sort(plus.begin(), plus.end());
  int balance = 0;
  for (seg s : plus) {
    if (balance+s.min < 0) return 1;
    balance += s.balance;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<seg> plus, minus;
  int total = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int balance = 0, mi = 0;
    for (char c : s) {
      balance += (c == '(')-(c == ')');
      mi = min(mi, balance);
    }
    total += balance;
    if (balance >= 0)
      plus.push_back({balance, mi});
    else
      minus.push_back({-balance, mi-balance});
  }
  if (total || check(plus) || check(minus)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 18832
n, m = map(int, input().split())
*c, = map(int, input().split())
c.sort()
dp = [2**32 for _ in range(n+1)]
for i in range(n+1):
    dp[i] = i
for i in range(1, m):
    for j in range(n+1):
        if (j-c[i]) >= 0:
            dp[j] = min([
                dp[j],
                dp[j-c[i]]+1
            ])
        else:
            dp[j] = dp[j]
print(dp[n])



Measured memory_bytes: 7636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n;
		int a;
		int b;
		n = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();

		int taxi = b;
		int train = a * n;
		int ans = taxi < train ? taxi : train;

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define int long long
using namespace std;
const int N=1e5+100;
int n,m,v,p,a[N],sum[N],ans;
signed main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	a[n+1]=inf;
	for (int i=n;i>=1;i--)
	{
		if (i>=v)
		{
			int pos=upper_bound(a+1,a+2+n,a[i]+m)-a;
			if (n-pos+1<p) ans++;
		}
		else
		{
			int pos=upper_bound(a+1,a+2+n,a[i]+m)-a;
			if (n-pos+1>=p) continue;
			if (v-i-p+1<=0)
			{
				ans++;
				continue;
			}
			int cnt=v-i-p+1;
			int l=i+1,r=min(n-p+1,pos-1);
			if (r-l+1>=cnt && cnt*m<=(a[i]+m)*(r-l+1)-(sum[r]-sum[l-1])) ans++;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#include "string"

int32_t main(){
	boost;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n,greater<int>());
	int sum = a[0];
	int i = 1;
	n -= 2;
	while(n>0){
		if(n > 1)
			sum += 2*a[i];
		else
			sum += a[i];
		i++;
		n-=2;
	}
	cout<<sum<<endl;
}



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

int main() {
  string S;cin>>S;
  bool can=true;
  for(int i=0;i<3;i++){
    char X=S.at(i);
    char Y=S.at(i+1);
    if(X==Y){
      can=false;
      break;
    }
  }
  if(can) cout<<"Good"<<endl;
  else cout<<"Bad"<<endl;
  
}


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

using namespace std;

#define ll long long

int main(){
    ll n, t;
    cin >> n;
    vector<ll> a(n),b,c;
    if(n % 2 == 0){
        for(int i = 0; i < n; i++){
            cin >> t;
            if(i % 2 == 0) b.push_back(t);
            else c.push_back(t);
        }
        reverse(c.begin(), c.end());

        for(int i = 0; i < c.size(); i++){
            cout << c[i] << " ";
        }
        for(int i = 0; i < b.size(); i++){
            cout << b[i] << " ";
        }
        cout << endl;
    }
    if(n % 2 == 1){
        for(int i = 0; i < n; i++){
            cin >> t;
            if(i % 2 == 0) b.push_back(t);
            else c.push_back(t);
        }
        reverse(b.begin(), b.end());
        for(int i = 0; i < b.size(); i++){
            cout << b[i] << " ";
        }
        for(int i = 0; i < c.size(); i++){
            cout << c[i] << " ";
        }
        cout << endl;
        }
}


Measured memory_bytes: 6116
#include <stdio.h>

int main(){
  int n,s[10001],q,t[500],count=0,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);
  for(i=0;i<q;i++){
    s[n]=t[i];
    j=0;
    while(s[j]!=t[i]) j++;
    if(j<n) count++;
  }
  printf("%d\n",count);
  return 0;
}
  
      



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A,B;
  cin >> A >> B;
  if (A == B) cout << "EQUAL";
  if (A.size() > B.size()){
    cout << "GREATER";
  } else if (A.size() < B.size()){
    cout << "LESS";
  } else {
    if (A > B) cout << "GREATER";
    if (A < B) cout << "LESS";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    ll n, a, b;
    cin >>n >> a >> b;

    ll diff = abs(a - b);
    if(diff % 2 == 0){
        cout << diff / 2 << endl;
    }
    else{
        if(a > b){
            swap(a, b);
        }

        vector <ll> v(3);
        v[0] = max(a, b) - 1;
        v[1] = n - min(a, b) ;
        ll d1 = a;
        ll d2 = n - b + 1;
        if(d1 < d2){
            v[2] = a + (b - a - 1) / 2 ;
        }
        else{
            v[2] = (n - b + 1) + (b - a - 1) / 2;
        }
        cout << *min_element(all(v)) << endl;
    
    }

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010,Mo=1000000007;
int fac[N],rev[N];
inline int Pow(int x,int y) {
    int ret=1;
    while(y) {
	if(y&1) ret=1LL*ret*x%Mo;
	x=1LL*x*x%Mo,y>>=1;
    }
    return ret;
}
inline int C(int n,int m) {
    return 1LL*fac[n]*rev[m]%Mo*rev[n-m]%Mo;
}
int main() {
    int n,m,x,y,ans=0;
    cin>>n>>m>>x>>y,--n,--m;
    for(int i=fac[0]=1;i<=n+m;i++) fac[i]=1LL*fac[i-1]*i%Mo;
    rev[n+m]=Pow(fac[n+m],Mo-2);
    for(int i=n+m;i;i--) rev[i-1]=1LL*rev[i]*i%Mo;
    for(int i=y;i<=m;i++) ans=(ans+1LL*C(i+n-x,i)*C(x-1+m-i,x-1))%Mo;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){
long long n,k;
cin>>n>>k;
vector<long long> a(n+1);

for(int i=1;i<=n;i++){
    cin>>a[i];
}
vector<vector<long long > > dp(n+1,vector<long long>(k+1,0));
for(int i=1;i<=n;i++)
dp[i][0]=1;
dp[0][0]=1;
for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++)
       dp[i-1][j]=(dp[i-1][j]%mod+dp[i-1][j-1]%mod)%mod;
    for(int j=1;j<=k;j++){
        if(j-a[i]-1<0)
        dp[i][j]=dp[i-1][j];
        else
        dp[i][j]=(dp[i-1][j]-dp[i-1][j-a[i]-1]+mod)%mod;
    }
}

cout<<dp[n][k]<<"\n";

}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define re(i,n) for(int i=n-1;i>=0;i--)
using namespace std;
int c7[10][10],h,w,s,t;
int visit[10][10];
int ax[]={1,0,-1,0},ay[]={0,1,0,-1};
int bx[]={1,0,-1,0},by[]={0,1,0,-1};
int dfs(int y1,int x1,int y2,int x2){
  s-=2;
  if(s==0)return 1;
  visit[y1][x1]=visit[y2][x2]=1;
  r(i,4){
    int y3=ay[i]+y1,x3=ax[i]+x1;
    int y4=by[i]+y2,x4=bx[i]+x2;
    if(y3<0||x3<0||y4<0||x4<0)continue;
    if(y3>=h||x3>=w||y4>=h||x4>=w)continue;
    if(y3==y4&&x3==x4)continue;
    if(c7[y3][x3]&&c7[y4][x4]&&(!visit[y3][x3])&&(!visit[y4][x4]))
      if(dfs(y3,x3,y4,x4)){return 1;}
  }
  return 0;
}
int solve(){
  if(s%2)return 0;t=s;
  r(i,h)r(j,w)if(c7[i][j])
    re(k,h)re(l,w)if(c7[k][l])
      r(n,2){if(i==k&&j==l)break;
        r(m,4){
          r(p,10)r(pp,10)visit[p][pp]=0;
          if(dfs(i,j,k,l))return 1;s=t;
          rotate(by,by+1,by+4);
          rotate(bx,bx+1,bx+4);
        }
        swap(by[1],by[3]);
      }
  return 0;
}
int main(){
  while(cin>>w>>h,w){
    s=0;
    r(i,4)ax[i]=ay[i]=bx[i]=by[i]=0;
    ax[0]=ay[1]=bx[0]=by[1]=1;
    ax[2]=ay[3]=bx[2]=by[3]=-1;
    r(i,h)r(j,w)cin>>c7[i][j];
    r(i,h)r(j,w)if(c7[i][j])s++;
    if(solve())cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

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

const int maxn=1e6+7;
int a[maxn],b[maxn];

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


Measured memory_bytes: 7040
#include<bits/stdc++.h>
//#define local
#define forn(a,n) for(int i = a; i < n; i++)


using namespace std;

typedef long long int ll;
typedef vector<int> vec;
typedef vector<ll> vecl;
typedef unsigned long long int ull;
typedef vector<ull> vecu;


void print(const vec &a)
{
    forn(0,a.size())
        cout << a[i];
    cout << "\n";
}
void solve()
{
    int d, t, s;
    cin >> d >> t >> s;
    float s1 = d/t;
    if(d % t == 0)
    {
        if(d/t > s)
            cout << "No";
        else
        {
            cout << "Yes";
        }
        
    }
    else
    {
        if(d/t + 1 > s)
            cout << "No";
            else
            {
                cout << "Yes";
            }
            
    }
    
}



int main()
{
    #ifdef local
        freopen("input.txt", "r", stdin);
    #endif
            solve();
}

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

int main() {
	int A[2];
	cin >> A[0] >> A[1];
	sort(&A[0], &A[2]);
	if (A[0] == 2) {
		cout << 1 << endl;
	} else if (A[1] == 3) {
		cout << 2 << endl;
	} else {
		cout << 3 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

int main(){
    int h, n; cin >> h >> n;
    vector<int> ar(n);
    int cnt = 0;
    rep(i,n) {
        cin >> ar[i];
        cnt += ar[i];
    }
    if (cnt >= h) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> white(N + 1, 0), black(N + 1, 0);
    int w = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == '.') {
            w++;
        }
    }
    bool bla = false;
    for (int i = 0; i < N; i++)
    {
        white[i + 1] = white[i];
        black[i + 1] = black[i];
        if (S[i] == '#') {
            black[i + 1]++;
        }
        else {
            bla = true;
            white[i + 1]++;
        }
    }
    int ans = INF;
    for (int i = 0; i < N; i++)
    {
        ans = min(ans, black[i] + w - white[i+1]);
    }
    if (bla) {
        cout << ans << endl;
    }
    else {
        cout << 0 << endl;
    }
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 2180
n,k = list(map(int,input().split()))
data = [int(s) for s in input().split()]

data.sort(reverse = True)
ans = 0
if k >= len(data):
  print(0)
  exit()
else:
  for i in range(k,len(data)):
    ans += data[i]
  print(ans)



Measured memory_bytes: 26024
import java.util.Scanner;

public class Main {
	
	public static int BS(int[] arr, int l, int r, int target) {
		if (l <= r) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == target) {
				return mid;
			}
			if (arr[mid] > target) {
				return BS(arr, l, mid - 1, target);
			}
			return BS(arr, mid + 1, r, target);
		}
		return -1;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] sequence = new int[n];
		for (int i = 0; i < n; i++) {
			sequence[i] = in.nextInt();
		}
		
		int m = in.nextInt();
		int[] set_integer = new int[m];
		for (int i = 0; i < m; i++) {
			set_integer[i] = in.nextInt();
		}
		
		int res = 0;
		for (int i = 0; i < set_integer.length; i++) {
			int num = set_integer[i];
			if (BS(sequence, 0, n - 1, num) != -1) {
				res++;
			}
		}
		System.out.println(res);
		in.close();
	}
}


Measured memory_bytes: 68716
A, B, C = map(int, input().split())
K = int(input())
while A >= B and K > 0:
    B *= 2
    K -= 1
while B >= C and K > 0:
    C *= 2
    K -= 1
# print(A, B, C, K)
if A < B and B < C:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<pair<int,int>,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};
long long a,b;

int main()
{
    long long N;
    cin >> a >> b >> N;
    
    if(N > b-2)
    {
        cout << a * (b-1) / b << endl;
    }
    else
    {
        cout << a * N / b << endl;
    }
    
    
    /*
    int N,M,Q;
    cin >> N >> M >> Q;
    
    vector<int> data(N);
    vector<pair<int,P>> p(Q);
    
    for(int i=0;i<Q;i++)
    {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        p[i] = {d,{{a,b},c}};
    }
    
    sort(p.begin(),p.end());
    
    for(int i=0;i<Q;i++)
    {
        
    }
        
    */
    
    return 0;
}
/*
 if(data[a] == data[b])
 {
 cout << "Yes" << endl;
 }
 else
 {
 cout << "No" << endl;
 }
 */

/*
 int main()
 {
 int N;
 cin >> N;
 
 
 return 0;
 }
 */


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

int main()
{
    long long X;
    cin >> X;

    if (X == 2)
    {
        cout << 2 << endl;
        exit(0);
    }

    long long P = X;
    bool prime = false;

    while (true)
    {
        for (int i = 2; i < P; i++)
        {
            if (P % i == 0)
            {
                prime = false;
                break;
            }

            else
            {
                prime = true;
            }
        }

        if (prime)
        {
            break;
        }

        else
        {
            P++;
        }
    }

    cout << P << endl;
}

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

int main(){
    long long x; cin >> x;
    for(int i=-1000;i<=1000;i++){
        for(int j=-1000;j<=1000;j++){
            long long a=pow(i,5);
            long long b=pow(j,5);
            if(a-b==x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

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

int proj(char a)
{
   if(a=='R') return 0;
   else if(a=='G') return 1;
   else return 2;
}

int main() {
    int N;
    cin >> N;
    vector<char> S(N);
    rep(i,N) cin >> S.at(i); 
     
    /*
    vector<char> T = S;
    sort(all(T));
    int R = upper_bound(all(T),'R')-lower_bound(all(T),'R');
    int G = upper_bound(all(T),'G')-lower_bound(all(T),'G');
    int B = upper_bound(all(T),'B')-lower_bound(all(T),'B');
    */

    ll R=0, G=0, B=0;
    for(int i=0; i<N; i++){
        if(S.at(i)=='R') R++;
        else if(S.at(i)=='G') G++;
        else B++;
    }

    ll ans=R*G*B;

    for(int j=1;j<N-1;j++){
        for(int d=1;d<=min(j,N-1-j);d++) if(S.at(j-d)!=S.at(j+d) && S.at(j-d)!=S.at(j) && S.at(j+d)!=S.at(j)) ans--;
    }

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int n, r = 0;
    cin >> n;
    vector<int> l(n);
    for (int& i : l) cin >> i;
    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;
                int m = max({l[i], l[j], l[k]}), s = l[i] + l[j] + l[k];
                if (m < s - m) ++r;
            }
        }
    }
    cout << r;
}

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

char solve(int m, int n) {
    int divisors = 0;
    for (int x = -150; x <= 150; ++x) {
        for (int y = -150; y <= 150; ++y) {
            if (x == 0 && y == 0) { continue; }
            if ((m * x + n * y) % (x * x + y * y) == 0 &&
                (m * y - n * x) % (x * x + y * y) == 0) {
                ++divisors;
            }
        }
    }
    return (divisors == 8) ? 'P' : 'C';
}

int main() {
    int n_case, m, n;
    cin >> n_case;
    for (int _ = 0; _ < n_case; ++_) {
        cin >> m >> n;
        cout << solve(m, n) << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    int ans = 0;
    if(b!=1) {
        ++ ans;
        b -= a;
        while (b>0) {
            b -= a-1;
            ++ ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256