akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    int a;
    int out = 0;
    for(int i=1;i<=N;i++){
        cin >> a;
        if(i%2==1 && a%2==1) out++;
    }
    cout << out << endl;

    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}
const ll MOD = 1e9 + 7;

struct matrix {
    ll a[4][4];
    matrix() {
        for (int i = 0; i < 4; ++i)
            for (int j = 0; j < 4; ++j)
                a[i][j] = 0;
    }
    matrix operator*(matrix x) {
        matrix ans;
        for (int i = 0; i < 4; ++i)
            for (int j = 0; j < 4; ++j) {
                if (a[i][j] == 0)
                    continue;
                for (int k = 0; k < 4; ++k) {
                    ans.a[i][k] = (ans.a[i][k] + a[i][j] * x.a[j][k]) % MOD;
                }
            }
        return ans;
    }
};

matrix pw(matrix a, ll b) {
    matrix ans;
    for (int i = 0; i < 4; ++i)
        ans.a[i][i] = 1;
    while (b) {
        while (!(b & 1))
            b >>= 1, a = (a * a);
        --b;
        ans = ans * a;
    }
    return ans;
}

ll v[4];
ll v2[4];
void mult(matrix X) {
    for (int i = 0; i < 4; ++i) {
        v2[i] = 0;
        for (int j = 0; j < 4; ++j)
            v2[i] += v[j] * X.a[i][j];
        v2[i] %= MOD;
    }
    for (int i = 0; i < 4; ++i)
        v[i] = v2[i];
}

int xa[4][4] = {{0, 1, 1, 2},
    {0, 1, 1, 2},
    {0, 1, 2, 2},
    {0, 0, 1, 1}};

int xb[4][4] = {{0, 0, 0, 0},
    {0, 1, 1, 2},
    {0, 0, 1, 0},
    {0, 0, 1, 1}};



int main() {
    matrix A;
    for (int i = 0; i < 4; ++i)
        for (int j = 0; j < 4; ++j)
            A.a[i][j] = xa[i][j];
    matrix B;
    for (int i = 0; i < 4; ++i)
        for (int j = 0; j < 4; ++j)
            B.a[i][j] = xb[i][j];
    v[0] = 1;
    v[1] = 0;
    v[2] = 1;
    v[3] = 0;
    ll n;
    int m;
    scanf("%lld%d", &n, &m);
    ll lst = 0;
    for (int i = 0; i < m; ++i) {
        ll x;
        scanf("%lld", &x);
        ll g = x - lst - 1;
        mult(pw(A, g));
        mult(B);
        lst = x;
    }
    ll g = n - lst;
    mult(pw(A, g));
    cout << v[0] << "\n";
	return 0;
}




Measured memory_bytes: 256
N,M = map(int,input().split())
P = []
for _ in range(N):
    x,y,z = map(int,input().split())
    P.append([x,y,z])
ans = 0
for X in(1,-1):
    for Y in (1,-1):
        for Z in (1,-1):
            A = []
            for i in range(len(P)):
                val = X*P[i][0] + Y*P[i][1] + Z*P[i][2]
                A.append(val)
            A.sort(reverse = True)
            ans = max(ans,sum(A[:M]))
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    int n,m; cin >> n >> m;
    vector<vector<pint>> data(n);
    rep(i,m){
        int p,y; cin >> p >> y;
        data.at(p-1).push_back(make_pair(y,i));
    }
    map<int,string> mp;
    rep(i,n){
        sort(all(data.at(i)));
        rep(j,data.at(i).size()){
            string ans = "";
            string ken = to_string(i+1);
            rep(i,6-ken.size()) ans += '0';
            ans += ken;
            string ban = to_string(j+1);
            rep(i,6-ban.size()) ans += '0';
            ans += ban;
            mp[data.at(i).at(j).second] = ans;
        }
    }
    rep(i,m) cout << mp.at(i) << endl;
    return 0;
}


Measured memory_bytes: 17920
import sys
sys.setrecursionlimit(10**8)

N,K = map(int,input().split(' '))
l = [list(map(int,input().split())) for _ in range(N-1)]
p = 10**9+7
MAP = [[] for i in range(N + 1)]

for a, b in l:
    MAP[a].append(b)
    MAP[b].append(a)
visited = [False]*(N+1)

def dfs(i,f,s):
    if visited[i]:
        return 1
    b = f + s
    res = K - b
    s = f
    f = 1
    visited[i] = True
    for v in MAP[i]:
        if visited[v]:
            continue
        res *= dfs(v,f,s)
        res %= p
        s += 1
    return res if res > 0 else 0
print(dfs(1,0,0))

Measured memory_bytes: 101636
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}


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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
    }

    auto f = [&](long double key){
        int cnt = 0;
        rep(i,n){
            cnt += ceil(a[i] / key) - 1;
        }
        return (cnt);
    };

    int ok = 1e9 + 1, ng = 0;
    
    while(ok - ng > 1){
        auto mid = (ok + ng) / 2;
        if(f(mid) <= k){
            ok = mid;
        }else{
            ng = mid;
        }
    }

    cout << ok << '\n';

    return 0;
}



Measured memory_bytes: 4756
stack = Array.new

data = gets.split
ans=0
data.each do |dt|
if dt!="+"&&dt!="-"&&dt!="*"
	stack.push(dt.to_i)
else
	num=0
	case dt
	when "+"
	num += stack.pop
	num += stack.pop
	stack.push(num)
	when "-"
	num -= stack.pop
	num += stack.pop
	stack.push(num)
	when "*"
	num = stack.pop
	num *= stack.pop
	stack.push(num) 
	end
	end
end

stack.each do |n|
	ans+= n
end

puts ans

Measured memory_bytes: 8692
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int s; cin>>s;
    int counter=1;
    while(!(s==4||s==2||s==1)) {
        if(s%2==0) s/=2;
        else s=3*s+1;
        counter++;
    }
    cout<<counter+3<<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem139b(a, b))
}

fun problem139b(a: Int, b: Int): Int {
    var sum = 1
    var count = 0
    for (i in 1..20) {
        if (sum >= b) break
        sum += a - 1
        count++
    }
    return count
}

Measured memory_bytes: 31396
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << b + min(a+b+1,c) << endl;

}

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

Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

typedef long long ll;

ll f(int a){
	ll ofset=0;
	for(ll c=9,d=1;;c*=10,d++){
		if(a<=c) return ofset+(a-1)*d+1;
		a-=c;
		ofset+=c*d;
	}
}

int main(){
	for(int n,k;scanf("%d%d",&n,&k),n;){
		int lo=1,hi=1e9;
		while(lo<hi){
			int mi=(lo+hi+1)/2;
			if(f(mi)<=n) lo=mi; else hi=mi-1;
		}

		int a=lo;
		for(int c=f(a)-n;c<k;a++){
			char s[16]; sprintf(s,"%d",a);
			for(int i=0;s[i];i++){
				if(0<=c && c<k) putchar(s[i]);
				c++;
			}
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
  #define N 101
  #define I 987654321
  #define A -1
  #define B 0
  #define C 1

  int X[N][N];

void search(int a,int *D);
 
  int main(void){
    int n,i,j,x,y,z,v[N];

    scanf("%d",&n);
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
        X[i][j] = I;
      }
    }

    for(i = 0; i < n; i++){
      scanf("%d%d",&z,&x);
      for(j = 0; j < x; j++){
        scanf("%d",&y);
        scanf("%d",&X[i][y]);
      }
    }

    search(n,v);

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

      printf("%d ",j);

      if(v[j] == I) printf("%d",-1);

      else printf("%d\n",v[j]);
    }
    return 0;
  }

 void search(int a,int *D){
   int min,i,j,y[N],l,m;

    for(i = 0; i < a; i++){
      y[i] = A;
      D[i] = I;
    }

    D[0] = 0;
    y[0] = B;

    while(1){
      min = I;
      l = -1;

      for(i = 0; i < a; i++){
        if(min > D[i] && y[i] != C){
          l = i;
          min = D[i];
        }
      }

      if(l == -1) break;

      y[l] = C;

      for(m = 0; m < a; m++){
        if(y[m] != C && X[l][m] != I){
          if(D[m] > X[l][m] + D[l]){
            D[m] = X[l][m] + D[l];
            y[m] = B;
          }
        }
      }
    }

    return;

  }




Measured memory_bytes: 1996
a, b, c = map(int, input().split())
k = int(input())
s = a+b+c

for i in range(k):
    s += max(a,b,c)
    if max(a,b,c) == a:
        a*=2
    elif max(a,b,c) == b:
        b*=2
    else:
        c*=2        
print(s)


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

int main(int argc, char *argv[])
{
    int a,b;
    std::cin >> a >> b;

    if(a > b){
        std::cout << "a > b" << std::endl;
    }
    else if(a < b){
        std::cout << "a < b" << std::endl;
    }
    else{
        std::cout << "a == b" << std::endl;
    }
}

Measured memory_bytes: 3036
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(s.size() <= n){
        cout << s << endl;
    }else {
        cout << s.substr(0,n) << "..." << endl;
    }

}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,x,cnt;
  cin >> n >> x;
  long long a[2*n],ans[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i+n]=a[i];
    ans[i]=i*x;
  }
  for(int i=0;i<n;i++){
    cnt=0;
    priority_queue<long long,vector<long long>,greater<long long> > pq;
    for(int j=i+n;j>=i;j--){
      pq.push(a[j]);
      ans[cnt]+=pq.top();
      cnt++;
    }
  }
  sort(ans,ans+n);
  cout << ans[0] << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#define F(i,l,r)for(int i=l;i<=r;i++)
int m=1e9+7,n,k,d[2333][2333];main(){std::cin>>n>>k;d[1][1]=1;F(i,2,n)F(j,1,i)d[i][j]=(d[i][j-1]+d[i-1][j])%m;F(i,1,n-k-1)(d[n][k]*=2)%=m;std::cout<<d[n][k];}

Measured memory_bytes: 15104
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // double
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
using vi6 = vector<in6>;
using vii6 = vector<vi6>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ios::sync_with_stdio(false);
  in6 n,m,l;
  cin >> n >> m >> l;
  vii6 a (n,vi6(m));
  vii6 b (m,vi6(l));
  vii6 ans (n,vi6(l));
  rep(i,n) {
      rep(j,m) cin >> a[i][j];
  }
  rep(i,m) {
      rep(j,l) cin >> b[i][j];
  }
  rep(i,n) {
      rep(j,l) {
          in6 sum = 0;
          rep(k,m) sum += a[i][k] * b[k][j];
          ans[i][j] = sum;
      }
  }
  rep(i,n) {
      rep(j,l) {
          if(j <= l - 2) cout << ans[i][j] << " ";
          else cout << ans[i][j] << "\n";
      }
  }
}


Measured memory_bytes: 3268
#include <iostream>
#include <vector>
#include <utility>
#include <unordered_map>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    unordered_map <int, int> odd;
    unordered_map <int, int> even;
    int max_odd = 0, max_even = 0, sec_odd = 0, sec_even = 0;
    int odd_num, even_num;
    for (int i;i<n;i++){
        cin >> v[i];
        if (i % 2){
            if (odd.find(v[i]) == odd.end()){
                odd.insert(make_pair(v[i], 1));
                if (odd[v[i]] > max_odd){
                    max_odd = odd[v[i]];
                    odd_num = v[i];
                }
                else if(odd[v[i]] > sec_odd){
                    sec_odd = odd[v[i]];
                }
            }

            else{
                odd[v[i]]++;
                if (odd[v[i]] > max_odd){
                    if (v[i] != odd_num)
                        sec_odd = max_odd;
                    max_odd = odd[v[i]];
                    odd_num = v[i];
                }
                else if(odd[v[i]] > sec_odd){
                    sec_odd = odd[v[i]];
                }
            }

        }
        else{
            if (even.find(v[i]) == even.end()){
                even.insert(make_pair(v[i], 1));
                if (even[v[i]] > max_even){
                    max_even = even[v[i]];
                    even_num = v[i];
                }
                else if(even[v[i]] > sec_even){
                    sec_even = even[v[i]];
                }
            }

            else{
                even[v[i]]++;
                if (even[v[i]] > max_even){
                    if (v[i] != even_num)
                        sec_even = max_even;
                    max_even = even[v[i]];
                    even_num = v[i];
                }
                else if(even[v[i]] > sec_even){
                    sec_even = even[v[i]];
                }
            }
        }
    }
    int ret = n - max_odd - max_even;
    if (odd_num == even_num){
        if ((max_even + sec_odd) > (max_odd + sec_even))
            ret = n - max_even - sec_odd;
        else
            ret = n - max_odd - sec_even;
    }

    cout << ret;
    return 0;

}


Measured memory_bytes: 4760
import bisect
import sys
readline = sys.stdin.buffer.readline


def main():
    n = int(readline())
    a = list(map(int,readline().rsplit()))
    b = list(map(int,readline().rsplit()))
    c = list(map(int,readline().rsplit()))
    a.sort()
    c.sort()
    ans = 0
    for i in b:
        d = bisect.bisect_left(a, i)
        e = n - bisect.bisect_right(c, i)
        ans += d * e
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 71020
def make_num(n, k):
    if k == 0 or len(n)<k:
        return 0
    else:
        if int(n[0]) == 0:
            return make_num(n[1:], k)
        else:
            ln = len(n)
            if k == 3:
                return (((ln-1)*(ln-2)*(ln-3))//6)*(9**3) + (int(n[0])-1)*81*(((ln-1)*(ln-2))//2) + make_num(n[1:], k-1)
            elif k == 2:
                return (((ln-1)*(ln-2))//2)*81 + (int(n[0])-1)*9*(ln-1)  + make_num(n[1:], k-1)
            elif k == 1:
                return 9 * (ln-1) + int(n[0])

n = list(input())
k = int(input())

print(make_num(n,k))

Measured memory_bytes: 3064
#include<iostream>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  int n,money;
  while(cin >>n>>money &&( n>0||money>0)){
    pair<int,int> PD[10010];
    int p,d;
    for(int i=0;i<n;i++){
      cin >>d>>p;
      PD[i]=make_pair(p,d);
    }

    sort(PD,PD+n);
    int need;
    int ans=0;
    for(int i=0;i<n;i++){
      need=i;
      if(PD[n-1-i].second<=money){
	money-=PD[n-1-i].second;
      }else{
	ans+=PD[n-1-i].first*(PD[n-1-i].second-money);
	break;
      }
    }
    
    for(int j=0;j<n-1-need;j++){
      ans+=PD[j].first*PD[j].second;
    }
    cout << ans <<endl;
  }
}  

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    string s;
    ll n;
    cin>>s;
    n = s.length();
    VV g(26);
    rep(i,26){
        rep(j,n){
            if(s[j]=='a'+i){
                g[i].pb(j);
            }
        }
    }
    //dbg(g);

    ll b = -2;
    ll a = -2;
    rep(i,26){
        REP(j,1, g[i].size()){
            if(g[i][j]-g[i][j-1]<=2){
                b = g[i][j];
                a = g[i][j-1];
                goto here;
            }
        }
    }
    here:
    out2(a+1,b+1);
    return  0;
}


Measured memory_bytes: 1608
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ints = new int[n];
		for (int i=n-1; i>=0; i--) {
			ints[i] = sc.nextInt();
		}
		for (int i=0; i<n; i++) {
			System.out.print(ints[i]);
			if (i<n-1) {System.out.print(" ");}
		}
		System.out.println();
	}
}


Measured memory_bytes: 26364
//#pragma optimize("Ofast")
#include<bits/stdc++.h>
#define MAXN 200005
#define inf int(16843009)
using namespace std;
typedef long long ll;


int N,M;

int a[MAXN], b[MAXN];
int dp[MAXN];
vector<int> adj[MAXN];

struct Node{
	int l,r;
	int d;
	Node *ls, *rs;
	
	void update(){
		d = min(ls->d, rs->d);
	}
} pool[2*MAXN], *rt;

int top = 0;

Node* buildT(int l, int r){
	Node *p = pool + (++top);
	p->l = l; p->r = r;
	if(l==r){
		p->d = dp[l];
		return p;
	}
	
	int mid = (l+r)/2;
	p->ls = buildT(l, mid);
	p->rs = buildT(mid+1, r);
	
	p->update();
	return p;
}

void change(Node *p, int id, int x){
	if(p->l==id && p->r==id){
		p->d = min(p->d, x);
		return;
	}
	
	int mid = (p->l + p->r)/2;
	if(id <= mid) change(p->ls, id, x);
	else change(p->rs, id, x);
	
	p->update();
}

int query(Node *p, int l, int r){
	if(p->l==l && p->r==r){
		return p->d;
	}
	
	int mid = (p->l + p->r)/2;
	if(r <= mid) return query(p->ls, l, r);
	else if(l >= mid+1) return query(p->rs, l, r);
	else return min(query(p->ls, l, mid), query(p->rs, mid+1, r));
}


int main(){
	
	cin>>N;
	
	int sum0 = 0;
	for(int i=1;i<=N;i++){
		cin>>b[i];
		sum0 += (b[i]==0);
	}
	
	cin>>M;
	
	int l,r;
	for(int i=1;i<=M;i++){
		cin>>l>>r;
		adj[l].push_back(r);
	}
	
	memset(dp, 1, sizeof(dp));
	dp[0] = 0;
	rt = buildT(0,N);
	
	for(l=1;l<=N;l++){
		//
		int m;
		for(int k=0;k<adj[l].size();k++){
			r = adj[l][k];
			m = query(rt, l-1, r);
			if(m < dp[r]) change(rt, r, m);
			dp[r] = min(dp[r], m);
		}
		dp[l] = min(dp[l], dp[l-1] + (b[l]==1?1:-1));
		change(rt, l, dp[l]);
	}
	cerr<<"dp[N]: "<<dp[N]<<endl;
	cout<<sum0 + dp[N]<<endl;
	return 0;
}

Measured memory_bytes: 22912
dic = {"1": ".,!? ", "2": "abc", "3": "def", "4": "ghi", "5": "jkl",
       "6": "mno", "7": "pqrs", "8": "tuv", "9": "wxyz"}

for _ in xrange(input()):
    L = raw_input().split("0")
    print "".join(dic[s[0]][(len(s)-1)%len(dic[s[0]])] for s in L if not s == "")

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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int a, b;
	sf("%d %d", &a, &b);
	printf("%d\n", a * b);

	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}
int main(){
  long long a,b;
  cin >> a >> b;
  long long ans=lcm(a,b);
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
AizuOnline A0095
Title
*/
#include <stdio.h>
#include <limits.h>
#define max(x,y) (((x)>(y))?(x):(y))

//Global data section
int chouka[101];
int num[101];
int n;

main()
{
  int i,p,ys,maxc;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d ",&num[i]);
      scanf("%d" ,&chouka[i]);
    }
  maxc=INT_MIN;
  ys = INT_MAX;
  for(i=0;i<n;i++)
    if(maxc < chouka[i])
      {
	maxc = chouka[i];
	ys = num[i];
      }
    else     if(maxc == chouka[i])
      {
	if(ys >num[i])
	  ys=num[i];
      }
  printf("%d %d\n",ys,maxc);

return(0);
}

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

int main() {
	long int A,B;
	cin>>A>>B;
	
    if((A+B)%2==1)cout<<"IMPOSSIBLE"<<endl;
	  else cout<<(A+B)/2<<endl;

    

    
    
    
    
    
    
    
    
    
    
    
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    rotate(s.begin(), s.begin() + 1, s.end());
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
from collections import Counter
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return 0

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        tmp = abs(self.parents[x]) * (abs(self.parents[x])-1) / 2 + abs(self.parents[y]) * (abs(self.parents[y])-1) / 2 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return abs(self.parents[x]) * (abs(self.parents[x])-1) / 2 - tmp

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def all_group_members_comb(self):
        tmp = 0
        self_roots = self.roots()
        for r in self_roots:
          len_member = len(self.members(r))
          if len_member > 1:
            tmp += len_member * (len_member-1) / 2
        return tmp
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(M)]
uf = UnionFind(N)
N_comb = N*(N-1)/2
ans = [N_comb]
for i in range(1,M):
  a,b = ab[-i]
  N_comb -= uf.union(a-1,b-1)
  ans.append(N_comb)

ans.sort()
for i in range(M):
  print(int(ans[i]))

Measured memory_bytes: 99260
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
typedef tuple<int,int> T; //'('cnt, ')'cnt

int main(){
    int N;
    cin>>N;
    vector<T> V;
    int L=0,R=0,cnt=0;;
    for(int i=0;i<N;i++){
        string S;
        cin>>S;
        int l=0,r=0;
        for(auto c:S){
            if(c=='('){
                l++;
            }else{
                if(l)l--;
                else r++;
            }
        }
        if(l||r) V.emplace_back(r,l);
        else cnt++;
    }
    sort(V.begin(), V.end());
    string ans;
    while(true){
        bool update = false;
        for(auto &v:V){
            int r,l;
            tie(r,l)=v;
            if(l==1000000&&r==1000000) continue;
            if(r<=L&&l>=r){
                L-=r;
                L+=l;
                v=T(1000000,1000000);
                update=true;
                cnt++;
            }
        }
        if(!update) break;
    }
    for(auto &v:V){
        int r,l;
        tie(r,l)=v;
        v=T(l,r);
    }
    while(true){
        bool update = false;
        for(auto &v:V){
            int l,r;
            tie(l,r)=v;
            if(l==1000000&&r==1000000) continue;
            if(l<=R&&r>=l){
                R-=l;
                R+=r;
                v=T(1000000,1000000);
                update=true;
                cnt++;
            }
        }
        if(!update) break;
    }
    if(L==R&&N==cnt){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if (a1 + a2 + a3 >= 22)
    {
        cout << "bust\n";
    }
    else
    {
        cout << "win\n";
    }
}
int main()
{
    func();
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

#define MAX_V 110000
#define MAX_LOG_V 20

vector<int> G[MAX_V];

int parent[MAX_LOG_V][MAX_V]; // 2^k th parent
int depth[MAX_V]; // distance from root
int root = 0;
 
void dfs(int v, int p, int d){
	parent[0][v] = p;
	depth[v] = d;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] != p){
			dfs(G[v][i], v, d + 1);
		}
	}
}
 
void init(int V){
	dfs(root, -1, 0);
	for(int k = 0; k < MAX_LOG_V - 1; k++){
		for(int v = 0; v < V; v++){
			if(parent[k][v] < 0){
				parent[k + 1][v] = -1;
			}else{
				parent[k + 1][v] = parent[k][parent[k][v]];
			}
		}
	}
}

int lca(int u, int v){
	if(depth[u] > depth[v]){
		swap(u, v);
	}
	for(int k = 0; k < MAX_LOG_V; k++){
		if((depth[v] - depth[u]) >> k & 1){
			v = parent[k][v];
		}
	}
	if(u == v){
		return u;
	}
	for(int k = MAX_LOG_V - 1; k >= 0; k--){
		if(parent[k][u] != parent[k][v]){
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}
 
int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		int k;
		cin >> k;
		for(int j = 0; j < k; j++){
			int x;
			cin >> x;
			G[x].push_back(i);
			G[i].push_back(x);
		}
	}
	
	init(N);
	
	int Q;
	cin >> Q;
	
	for(int i = 0; i < Q; i++){
		int x, y;
		cin >> x >> y;
		cout << lca(x, y) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 21748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
int a,b,k,l=0,ans = 0,i;
cin >> a >> b >> k;
for(i=min(a,b);i>0;i--){
    if(a%i==0 && b%i==0){
        l++;
    
    if(l==k){
            ans = i;
        }
    }
}
cout << ans << endl;


//////////////////////////////////////////////////////
return 0;}

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

#include <set>
#include <vector>

using namespace std;

bool ok(vector<int> moves, int g) {
  set<int> pos;
  pos.insert(0);
  for (int m : moves) {
    //fprintf(stderr, "m=%d\n", m);
    set<int> npos;
    for (int p : pos) {
      npos.insert(p + m);
      npos.insert(p - m);
    }
    pos = npos;
  }
  fprintf(stderr, "pos\n");
  for (int p : pos) {
    fprintf(stderr, "%d\n", p);
  }
  return pos.count(g);
}

int main() {
  char seq[9999];
  scanf("%s",seq);
  int gx, gy;
  scanf("%d%d",&gx,&gy);

  int sx = 0;
  int sy = 0;
  int i;
  for (i = 0; seq[i] && seq[i] == 'F'; i++)
    sx++;
  vector<int> verts;
  vector<int> horis;
  bool is_vert = false;
  int n = 0;
  for (; seq[i]; i++) {
    char c = seq[i];
    if (c == 'T') {
      //fprintf(stderr, "is_vert=%d n=%d i=%d\n", is_vert, n, i);
      if (n > 0) {
        if (is_vert)
          verts.push_back(n);
        else
          horis.push_back(n);
      }
      is_vert = !is_vert;
      n = 0;
    } else if (c == 'F') {
      n++;
    } else {
      abort();
    }
  }

  if (n > 0) {
    if (is_vert)
      verts.push_back(n);
    else
      horis.push_back(n);
  }

  fprintf(stderr, "vert=%zu horis=%zu\n", verts.size(), horis.size());

  if (ok(horis, gx - sx) && ok(verts, gy)) {
    puts("Yes\n");
  } else {
    puts("No\n");
  }
}


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

int main() {
  int X, Y;
  cin >> X>>Y;

  bool frag=true;


  while(Y>-1){
    if(Y%2==1||Y/4>X){
      break;
    }
    else if(Y/2==X){
      frag=false;
      break;
    }
    else if(Y/4==X&&Y%4==0){
      frag=false;
      break;
    }
    else{
      X--;
      Y-=2;
    }
  }

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


}


Measured memory_bytes: 3624
import heapq
import sys

input = sys.stdin.readline
INF = 100100100

class Info:
    def __init__(self, argNodeId, argSumCost):
        self.nodeId = argNodeId
        self.sumCost = argSumCost
    def __lt__(self, arg):
        return self.sumCost < arg.sumCost


class Edge:
    def __init__(self, argTo, argCost):
        self.to = argTo
        self.cost = argCost


def main():
    n = int(input())
    minDist = [INF] * n
    graph = [[] for _ in range(n)]
    for _ in range (n):
        u, k, *cv = map(int, input().split())
        for i in range(k):
            graph[u].append(Edge(cv[2 * i], cv[2*i + 1]))
    minDist[0] = 0
    Q = []
    heapq.heappush(Q, Info(0, 0))
    while len(Q) > 0:
        u = heapq.heappop(Q)
        if u.sumCost > minDist[u.nodeId]:
            continue
        for edge in graph[u.nodeId]:
            if minDist[edge.to] > u.sumCost + edge.cost:
                minDist[edge.to] = u.sumCost + edge.cost
                heapq.heappush(Q, Info(edge.to, minDist[edge.to]))
    for i in range(n):
        print('{} {}'.format(i, minDist[i]))


if __name__ == '__main__': main()


Measured memory_bytes: 120516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, r;
            string[] word = Console.ReadLine().Split(' '); 
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            //int ab = a + b;
            //int ac = a + c;
            //int bc = b + c;


            //if (ab < ac && ab < bc)
            //r = ab;
            // else if (ac < ab && ac < bc)
            //r = ac;
            // else
            //r = bc;
            int m = a;
            if (b > m) m = b;
            if (c > m) m = c;
            r = (a + b + c) - m; 
            Console.WriteLine(r);


            
             
        }
    }
}


Measured memory_bytes: 27368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> p;

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

    vector<bool> snuke(N, false);
    rep(i,K){
        int d; cin >> d;
        rep(j,d){
            int A; cin >> A; A--;
            snuke[A] = true;
        }
    }
    
    int ans = 0;
    rep(i,N) if(!snuke[i]) ans++;
    cout << ans << endl;
}


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

int dp[40];

int main(){
    dp[0] = 1;
    for(int x = 0; x <= 30; x++){
        dp[x+1] += dp[x];
        dp[x+2] += dp[x];
        dp[x+3] += dp[x];
    }
    int n;
    while( scanf(" %d", &n), n ){
        printf("%d\n", (int)ceil(dp[n]/3650.0));
    }
    return 0;
}

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

public class Hello
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        if (n == 1) { Console.WriteLine(0); goto exit; }
        if (IsPrime(n)) { Console.WriteLine(1); goto exit; }
        var a = GeneratePrime((int)Sqrt(n));
        var b = getPrime(n, a);
        getAns(b);
    exit:;
    }
    static void getAns(List<int> a)
    {
        var ans = 0;
        foreach (var x in a)
            ans += getN(x);
        Console.WriteLine(ans);
    }
    static int getN(int n)
    {
        var p = 1;
        while (true)
        {
            if (p * (p + 1) > 2 * n) return p - 1;
            else if (p * (p + 1) == 2 * n) return p;
            else p++;
        }
    }
    static bool IsPrime(long n)
    {
        if (n < 2) return false;
        else if (n == 2) return true;
        else if (n % 2 == 0) return false;
        double sqrtNum = Sqrt(n);
        for (int i = 3; i <= sqrtNum; i += 2)
            if (n % i == 0) return false;
        return true;
    }
    static List<int> getPrime(long n, List<int> a)
    {
        var ans = new List<int>();
        var t = n;
        for (int i = 0; i < a.Count(); i++)
        {
            if (a[i] > t) break;
            var count = 0;
            while (true)
            {
                if (t % a[i] == 0) 
                {
                    t /= a[i];
                    count++;
                    if (IsPrime(t) && t > a[i]) { t =1; ans.Add(1); }
                }
                else
                {
                    if (count > 0) ans.Add(count);
                    break;
                }
            }
        }
        return ans;
    }
    static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Math.Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
}

Measured memory_bytes: 32944
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<climits>
#include<string>
#include<sstream>

#define pii pair<int,int>
#define ll long long
#define MOD 1000000007
#define in2d(i,j,H,W)(0<=i&&i<H&&0<=j&&j<W)

using namespace std;
struct UFT{
	vector<int>par;
	int getpar(int i){
		if(par[i]==i)return i;
		return par[i]=getpar(par[i]);
	}
	void unite(int i,int j){
		int t=getpar(i);
		par[t]=getpar(j);
	}
	bool uf(int i,int j){
		return getpar(i)==getpar(j);
	}
	UFT(int n){
		par=vector<int>(n);
		for(int i=0;i<n;i++)par[i]=i;
	}
	~UFT(){
		delete &par;
	}
};
struct SegT{
	vector<ll>container;
	int n;
	void update(int i,ll x){
		int ii=i+n-1;
		container[ii]=x;
		while(ii>0){
			ii=(ii-1)/2;
			//////////////////////////////////////////
			container[ii]=max(container[2*ii+1],container[2*ii+2]);
			//////////////////////////////////////////
		}
	}
	ll get(int l,int r,int l2=0,int r2=-1,int k=0){
		if(r2==-1)r2=n;
		if(r2<=l||r<=l2)return 0;
		if(l<=l2&&r2<=r)return container[k];
		ll vl=get(l,r,l2,(l2+r2)/2,2*k+1);
		ll vr=get(l,r,(l2+r2)/2,r2,2*k+2);
		///////////////////////////
		return max(vl,vr);
		///////////////////////////
	}
	////////////////new///////////////////////
	SegT(vector<int> &A){
		n=pow(2,(int)log2(A.size())+1);
		container=vector<ll>(2*n,0);
		for(int i=0;i<A.size();i++)update(i,A[i]);
	}
	~SegT(){
		delete &container;
	}

};
int main(){
	cout<<fixed<<setprecision(11);
	int N;int K;cin>>N>>K;
	vector<int>h(N);for(int i=0;i<N;i++)cin>>h[i];
	int ans=0;
	for(int i=0;i<N;i++)if(h[i]>=K)ans++;
	cout<<ans<<endl;

	return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b ;
    if ((a * b) % 2 == 1){
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define rev(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;
using ull = unsigned long long;

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

	int count = 0;
	int num = n;
	while (num > 0) {
		count++;
		num /= 10;
	}
	
	if (count == 1) cout << n << endl;
	else if (count == 2) cout << 9 << endl;
	else if (count == 3) cout << 9 + (n - 100 + 1) << endl;
	else if (count == 4) cout << 909 << endl;
	else if (count == 5)cout << 909 + (n - 10000 + 1) << endl;
	else cout << 90909 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    ll n,k;
    cin >>n>>k;
    ll w[n],v[n];
    for(int i=0;i<n;i++) cin >>w[i]>>v[i];
    
    ll dp[n+1][k+1];
    for(int i=0;i<=n;i++){
    	for(int j=0;j<=k;j++){
    		if(i==0||j==0){
    			dp[i][j]=0;
			}
	else if(w[i-1]<=j){
				dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
				
			}
			else
			dp[i][j]= dp[i-1][j];
		}
	}

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

}


Measured memory_bytes: 79232
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
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;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	double w, h, x, y;
	cin >> w >> h>>x>>y;
	cout << w * h / 2 << " ";
	int cw = w, ch = h;
	if (x * 2 == cw && y * 2 == ch)
		cout << "1" << endl;
	else
		cout << "0" << endl;
}

Measured memory_bytes: 4992