akhauriyash/Code-Regression huggingface dataset:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
def cmb(n, r):
    if n-r<0:
        return 0
    return factorial(n) // factorial(r) // factorial(n - r)

def main():
    n,a,b,*v=map(int,open(0).read().split())
    v.sort(reverse=1)
    m=sum(v[:a])/a
    print(m)
    n=v[a-1]
    x,y=v[:a].count(n),v.count(n)
#    print(x,y)
    ans=0
    if m==n and y-x>0:
        for i in range(x,x+b-a+1):
            ans+=cmb(y,i)
        print(ans)
    else:
        print(cmb(y,x))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	int h[n] = {};
	for (int i = 0; i < n; i++)
		cin >> h[i];
	sort(h, h + n);
	cout << accumulate(h, h + max(0, n - k), 0LL);
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int h[100002], rem[100002];
int main()
{
	int n, m,a,b,sum = 0;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> h[i];
	for (int i = 1; i <= m; i++) {
		cin >> a >> b;
		if (h[a] > h[b]) {
			if(!rem[a])  rem[a] = 1;
			rem[b] = -1;
		}
		else if (h[a] < h[b]) {
			if (!rem[b]) rem[b] = 1;
			rem[a] = -1;
		}
		else rem[a] = -1,rem[b] = -1;
	}
	for (int i = 1; i <= n; i++)
		if (rem[i] == 1 || !rem[i]) sum++;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4400
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
//
// Created by karayuu on 2018-12-24.
//
void call(int n) {
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
            continue;
        } else {
            while (x > 0) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}

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

    call(a);
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

ll getDiv(long long A, long long B, long long C){
	ll div1 = A/2;
	ll div2 = A-div1;

	return abs(div1-div2) * C * B;
}

void solve(long long A, long long B, long long C){
	ll A_d = getDiv(A,B,C);
	ll B_d = getDiv(B,A,C);
	ll C_d = getDiv(C,A,B);

	cout << min(C_d,min(A_d,B_d)) << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long A;
	long long C;
	long long B;
	cin >> A;
	cin >> B;
	cin >> C;
	solve(A, B, C);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1LL << 30;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vi a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n + 1][401][401]; // min cost, a, b
    for (int i = 0; i < n + 1; ++i) {
        for (int j = 0; j < 401; ++j) {
            for (int k = 0; k < 401; ++k) {
                dp[i][j][k] = INF;
            }
        }
    }
    for (int i = 0; i < n + 1; ++i) {
        dp[i][0][0] = 0;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 401; ++j) {
            for (int k = 0; k < 401; ++k) {
                chmin(dp[i][j][k], dp[i - 1][j][k]);
                if (j - a[i - 1] >= 0 && k - b[i - 1] >= 0) {
                    chmin(dp[i][j][k], dp[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]);
                }
            }
        }
    }
    int ret = INF;
    int thisma = ma;
    int thismb = mb;
    while (thisma < 401 && thismb < 401) {
        chmin(ret, dp[n][thisma][thismb]);
        thisma += ma;
        thismb += mb;
    }
    if (ret == INF) {
        cout << -1 << "\n";
    } else {
        cout << ret << "\n";
    }
    return 0;
}

Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define int long
  int N,K;cin>>N>>K;
  vector<int> A(N),F(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)cin>>F[i];
  sort(A.begin(),A.end());
  sort(F.begin(),F.end(),std::greater<int>());
  
  int l=0,r=A[N-1]*F[0]; //l,rは探索範囲の端点(含む)
  
  while(r-l>0){
    int X=(r+l)/2;//中点をとる
    int sum=0;
    for(int i=0;i<N;i++)sum+=(0>A[i]-floor(X/F[i])?0:A[i]-X/F[i]);
    
    if(sum<=K)r=X;//条件を満たすなら, 
    else l=X+1;
  }
  cout<<l;
}












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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
void solve(){
	cin >> n;
	cout << (n+2-1)/2 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> s(n, 0);
    for (int i = 0; i < q; i++)
    {
        int a;
        cin >> a;
        s[a - 1]++;
    }
    for (int i = 0; i < n; i++)
    {
        s[i] = k - (q - s[i]);
        if (s[i] <= 0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
using namespace std;
typedef long long ll;
ll a,b,k; 
int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	scanf("%lld%lld",&a,&b);
	if (a<b) swap(a,b);
	if ((a-b)%2) printf("IMPOSSIBLE\n");
	else printf("%lld\n",(a+b)/2);
	return 0;
}

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

int n, u, v, ans, level[100005];
vector<int> adj[100005];

void dfs1(int root, int parent, int lvl)
{
    level[root] = lvl;
    for (auto x : adj[root])
    {
        if (x == parent) continue;

        dfs1(x, root, lvl + 1);
    }
}

void dfs2(int root, int parent, int dist)
{
    if (level[root] <= dist) return;

    for (auto x : adj[root])
    {
        if (x == parent) continue;

        dfs2(x, root, dist + 1);
    }
    ans = max(ans, level[root] - 1);
}

int main()
{
    cin >> n >> u >> v;
    for (int in = 0; in < n - 1; in++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    dfs1(v, -1, 0);
    dfs2(u, -1, 0);

    cout << ans << endl;
}

Measured memory_bytes: 13400
import math

n = int(input())
keta = int(math.log(n)/math.log(26)) + 1
name = [0]*keta

for i in range(keta):
    name[i] = n % 26
    n = n // 26

alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

ans = ''

for j in range(keta):
    if name[j] == 0 and j != keta-1:
        name[j] = 26
        name[j+1] -= 1
        ans = alp[name[j]-1] + ans
    elif name[j] == -1 and j != keta-1:
        name[j+1] -= 1
        name[j] += 26
        ans = alp[name[j]-1] + ans
    elif j == keta-1 and name[j] == 0:
        pass
    else:
        #name[j] != 0
        ans = alp[name[j]-1] + ans

#print(name)
print(ans)


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005; 
int N, K;
int A[MAX_N];

vector<II> vec;

int sumA1[MAX_N], sumA2[MAX_N];
int sumA[MAX_N];

int calcD[MAX_N];

int myPow(int n, int m) 
{
  int ret = 1;
  int tmp = n;
  while(m) {
    if(m&1) {
      ret *= tmp;
      ret %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
    m /= 2;
  }
  return ret;
}

int calcC(int n, int k)
{
  return (calcD[n] * myPow(calcD[k] * calcD[n-k] % MOD, MOD-2)) % MOD;
}

signed main()
{
  calcD[0] = calcD[1] = 1;
  FOR(n,2,MAX_N) {
    calcD[n] = (n * calcD[n-1]) % MOD;
  }

  cin >> N >> K;
  REP(n,N) {
    cin >> A[n];
  }

  sort(A, A+N);

  int sumMin = 0, sumMax = 0;
  // 最小値
  REP(n,N) {
    int cnt = N-n;
    if(cnt >= K) {
      int tmp = A[n] * (calcC(cnt-1, K-1)) % MOD;
      sumMin += tmp;
      sumMin %= MOD;
    } else {
      break;
    }
  } 
  // 最大値
  REP(n,N) {
    int cnt = n+1;
    if(cnt >= K) {
      int tmp = (A[n] * ((calcC(cnt-1, K-1)) % MOD));
      sumMax += tmp;
      sumMax %= MOD;
    }
  } 

  cout << (sumMax + MOD - sumMin) % MOD << endl;

  return 0;
}


Measured memory_bytes: 1792
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;

    priority_queue<pii, vii, greater<pii>> pq;

    for(int i=0;i<n;i++){
        int a, b;
        cin>>a>>b;

        pq.push({b, a});
    }

    int curr = 0;
    while(pq.size()){
        pii p = pq.top();
        pq.pop();

        curr += p.y;
        if(curr > p.x){
            cout<<"No";
            return 0;
        }
    }

    cout<<"Yes";
} 

Measured memory_bytes: 7392
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

bool check(const vector<ll> &a, const vector<ll> &b, int i1, int i2, int i3){
	ll a1 = a[i1], a2 = a[i2], a3 = a[i3];
	ll b1 = b[i1], b2 = b[i2], b3 = b[i3];
	return (a2 - a1) * (b3 - b2) >= (b2 - b1) * (a3 - a2);
}

int deq[200010], s, t;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; ll c; cin >> n >> c;
	vector<ll> h(n); rep(i, n) cin >> h[i];
	vector<ll> a, b, dp(n, 1e18);
	dp[0] = 0;
	
	rep(i, n){
		while(s + 1 < t &&
			a[deq[s    ]] * h[i] + b[deq[s    ]] >=
			a[deq[s + 1]] * h[i] + b[deq[s + 1]]) s++;
		if(i) dp[i] = a[deq[s]] * h[i] + b[deq[s]] + h[i] * h[i];
		
		a.pb(-2ll * h[i]);
		b.pb(dp[i] + c + h[i] * h[i]);
		while(s + 1 < t && check(a, b, deq[t - 2], deq[t - 1], i)) t--;
		deq[t++] = i;
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 8172
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <queue>
using namespace std;
using pii = pair<int, int>;
const int N = 1e5+1;
pii arr[N];

int main(){
    int n,m;
    scanf("%d%d", &n, &m);
	for(int i=0;i<n;++i) scanf("%d%d", &(arr[i].first), &(arr[i].second));
	sort(arr, arr+n);
	priority_queue<int> q;
	int ans = 0;
	for(int i=1,j=0;i<=m;++i){
		while(j<n&&arr[j].first<=i) q.push(arr[j++].second);
		if(!q.empty()){
			ans += q.top();
			q.pop();
		}
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1660
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  debug_print(B-A+1);
  debug_print(B/C - (A-1)/C);
  debug_print(B/D - (A-1)/D);
  ll t = C*D/gcd(C,D);
  debug_print(B/t - (A-1)/t);
  cout << B-A+1 - (B/C - (A-1)/C) - (B/D - (A-1)/D) + (B/(t) - (A-1)/(t));
  return 0;
}


Measured memory_bytes: 256
W, H, N = map(int, input().split())

S = W*H
h = list(range(1, H+1))
w = list(range(1, W+1))
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        w = list(filter(lambda num: num > x, w))
    elif a == 2:
        w = list(filter(lambda num: num <= x, w))
    elif a == 3:
        h = list(filter(lambda num: num > y, h))
    else:
        h = list(filter(lambda num: num <= y, h))

print(len(w)*len(h))


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

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

const int N = 2e5 + 5;
int n, m;
vector <int> adj[N];
set <ii> alive;
bool mark[N];

struct obj {
	int a, b, c;
};

vector <obj> res;

void dfs(int u, int par) {
	mark[u] = 1;
	for (int v : adj[u]) if (!mark[v]) {
		dfs(v, u);
	}
	int pre = -1, cnt = 0;
	for (int v : adj[u]) if (alive.find({u, v}) != alive.end() && par != v) {
		++cnt;
		alive.erase({u, v});
		alive.erase({v, u});
		if (~pre) {
			res.push_back({pre, u, v});
			pre = -1;
		} else pre = v;
	}
	// cerr << u << " : " << cnt << endl;
	if (~pre && ~par) {
		res.push_back({pre, u, par});
		alive.erase({u, par});
		alive.erase({par, u});
	}
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> n >> m;
	if (m & 1) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1; i <= m; ++i) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		alive.insert({u, v});
		alive.insert({v, u});
	}
	for (int i = 1; i <= n; ++i) if (!mark[i]) 
		dfs(i, -1);
	for (obj D : res) {
		cout << D.b << ' ' << D.a << endl;
		cout << D.b << ' ' << D.c << endl;
	}

	return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c,d; cin >> a >> b >> c >> d;
  int ans = 0;
  
  if(a>=b) ans += b;
  else ans += a;

  if(c>=d) ans += d;
  else ans += c;

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


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  cin>>S;
  int N=S.size();
  
  if(S[N-1]=='s') S+="es";
  else S+="s";
  cout<<S<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define ld long double
#define int long long
signed main() {
    ios::sync_with_stdio;
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    vector<int>a(n),dp(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n-1];

}

Measured memory_bytes: 1792
n=int(input())
arr=list(map(int,input().split()))
one=two=three=0
for i in arr:
    if i==1:
        one+=1
    elif i==2:
        two+=1
    elif i==3:
        three+=1
max_one=one+two+three
max_two=two+three
max_three=three
dp=[[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)]
for k in range(max_three+1):
    for j in range(max_two+1-k):
        for i in range(max_one+1-j-k):
            if i+j+k==0:
                continue
            else:
                dp[i][j][k]=n/(i+j+k)
            if i>0:
                dp[i][j][k] += (dp[i-1][j][k]*i)/(i+j+k)
            if j>0:
                dp[i][j][k] += (dp[i+1][j-1][k]*j)/(i+j+k)
            if k>0:
                dp[i][j][k] += (dp[i][j+1][k-1]*k)/(i+j+k)
print(dp[i][j][k])
    
    

Measured memory_bytes: 295244
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	string s, a;
	cin >> s >> a;
	ll S = s.size(), A = a.size();
	bool f = 0, yojo = 0;
	if (S<A)cout << "UNRESTORABLE" << endl;
	else {
		for (int i = S - A; i >= 0; i--) {
			for (int j = 0; j < A; j++) {
				if (!(a[j] == s[i + j] || s[i + j] == '?')) {
					f = 1;
					break;
				}
			}
			if (f)f = 0;
			else {
				for (int j = 0; j < A; j++) {
					s[i + j] = a[j];
				}
				yojo = 1;
				break;
			}
		}
		if (yojo) {
			for (int i = 0; i < S; i++) {
				if (s[i] == '?')s[i] = 'a';
			}
			cout << s << endl;
		}
		else {
			cout << "UNRESTORABLE" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

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

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N - i; j++){
            int man = i;
            int gos = j;
            int sen = (N - i - j);
            if(man * 10000 + gos * 5000 + sen * 1000 == Y){
                cout << man << ' ' << gos << ' ' << sen << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

var strMaxLen = 10

// mCn = combinations[m][n]
var c [][]int

func main() {
	prepare()

	var str string
	fmt.Scan(&str)

	ans := 0
	// 部分文字列str[i:j]
	for i := 0; i < len(str); i++ {
		for j := i + 1; j < len(str)+1; j++ {
			targetStr := str[i:j]
			targetNum, _ := strconv.Atoi(targetStr)

			beforeStrLen := i
			combiBeforeStr := 0
			if beforeStrLen == 0 {
				combiBeforeStr = 1
			} else {
				for k := 0; k <= beforeStrLen-1; k++ {
					combiBeforeStr += combi(beforeStrLen-1, k)
				}
			}

			afterStrLen := len(str) - j
			combiAfterStr := 0
			if afterStrLen == 0 {
				combiAfterStr = 1
			} else {
				for k := 0; k <= afterStrLen-1; k++ {
					combiAfterStr += combi(afterStrLen-1, k)
				}
			}

			ans += targetNum * combiBeforeStr * combiAfterStr
		}
	}

	fmt.Println(ans)
}

func prepare() {
	c = make([][]int, strMaxLen)
	for i := 0; i < strMaxLen; i++ {
		c[i] = make([]int, strMaxLen)
		for j := 0; j < strMaxLen; j++ {
			c[i][j] = combi(i, j)
		}
	}
}

func combi(n, k int) int {
	ans := 1
	for i := 0; i < k; i++ {
		ans *= n - i
	}

	for i := 1; i <= k; i++ {
		ans /= i
	}

	return ans
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();
		String tmp = s;
		boolean match = false;

		for (int i = 0; i<s.length(); i++){
			tmp = Rotate(tmp);
			if (tmp.equals(t)){
				match = true;
				break;
			}
		}
		if (match){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	public static String Rotate(String source){
		String ret = source.substring(source.length() - 1) + source.substring(0, source.length()-1);
		return ret;
	}
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		long a = scanner.nextLong();
		long b = scanner.nextLong();
		long x = scanner.nextLong();
		long ans = 0;

		if (a == 0) {
			ans = (b / x + 1);
		} else {
			ans = (b / x) - ((a - 1) / x);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static void Main(){
        var n = Console.ReadLine();
        var b = ReadList();
        var a = new int[b.Count + 1];
        
        for(int i = 0; i <= b.Count; i++){
            a[i] = (int)1e5;
        }
        
        for(int i = 0; i < b.Count; i++){
            if(a[i] > b[i]){
                a[i] = b[i];
            }
            
            if(a[i + 1] > b[i]){
                a[i + 1] = b[i];
            }
        }
        
        long sum = 0;
        
        for(int i = 0; i <= b.Count; i++){
            sum += a[i];
        }
        
        Console.WriteLine(sum);
    }
    
    public static List<int> ReadList(){
        var a_text = Console.ReadLine().Split(' ');
        return a_text.Select(x => int.Parse(x)).ToList();
    }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main()
{
    int a, b, c = 0;
    cin >> a >> b;
    for (int i = min(a,b); i <= max(a,b); i++){
        if ((a * b * i) % 2 == 1){
            c = i; break;
        }
    }
    if (c == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


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

int n;
vector<int> a, h;
vector<ll> bit;

void update(int i, ll v)
{
  while (i <= n)
  {
    bit[i] = max(bit[i], v);
    i += i & -i;
  }
}

ll query(int i)
{
  i -= 1;
  ll ret = 0;
  while (i > 0)
  {
    ret = max(ret, bit[i]);
    i -= i & -i;
  }
  return ret;
}

int main()
{
  cin >> n;
  h.resize(n);
  a.resize(n);
  rep(i, n)
    cin >> h[i];
  rep(i, n)
    cin >> a[i];
  bit.resize(n + 1);
  rep(i, n)
    update(h[i], query(h[i]) + a[i]);
  cout << query(n + 1) << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
int main()
{
  int  i, j, k;
  int  so[100000] = {0}, ni[1000] = {0};
  int  q, l, r;

  so[2] = 1;
  for(i = 3; i < 100000; i += 2){
    so[i] = 1;
  }

  k = 0;
  for(i = 3; i < 100000; i += 2){
    if(so[i] == 1){
      if(so[(i+1)/2] == 1 ){
          ni[k] = i;
          k++;
      }
      for(j = i+i; j < 100000; j += i){
        so[j] = 0;
      }
    }
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++){ 
    scanf("%d %d", &l, &r);
    for(j = 0; ni[j] != 0; j++){
       if( ni[j] >= l ) break;
    }
    for(k = j; ni[k] != 0; k++){
       if( ni[k] > r ) break;
    }
    printf("%d\n", k - j );
  }

  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
    ll N,M=0;
    string A,B,C;
    cin >> N >> A >> B >> C;
    rep(i,N){
        if(A[i]==B[i] && B[i] == C[i]){
            M+=0;
        }
        else if(A[i]!=B[i] && B[i]!=C[i] && A[i]!=C[i]){
            M+=2;
        }
        else{
            M+=1;
        }
    }
    cout << M << endl;
}

Measured memory_bytes: 256
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
n = ni()
A = []
B = []
for i in range(n):
    a,b = ma()
    A.append(a)
    B.append(b)
A.sort()
B.sort(reverse=True)
if n%2==1:
    mi = A[n//2]
    ma = B[n//2]
    print(ma-mi+1)
else:
    mi = A[(n-1)//2] + A[n//2]
    ma = B[(n-1)//2] + B[n//2]
    print(ma-mi+1)

#print(ma,mi,d)


Measured memory_bytes: 25744
n, m = map(int, input().split())
vertex_dic = {}
def add_dic(p):
    if not p in vertex_dic:
        vertex_dic[p] = 1
    else:
        vertex_dic[p] += 1
for i in range(m):
    line = list(map(int, input().split()))
    add_dic(line[0])
    add_dic(line[1])
ans = "YES"
for key, item in vertex_dic.items():
    if item%2 == 1:
        ans = "NO"
print(ans)


Measured memory_bytes: 51288
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    map<string,int> map;
    rep(i,n){
        string s;
        cin>>s;
        SORT(s);
        map[s]++;
    }
    int ans=0;
    for(auto i:map)ans+=i.se*(i.se-1)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int n, m;
    vi u(2);
    cin >> n >> u[0] >> u[1] >> m;
    vector<map<int, Pii>> mp(2);
    rep(k, 2) rep(i, n) rep(j, n) {
        int p;
        cin >> p;
        mp[k][p] = Pii(i, j);
    }
    vvi row(2, vi(n, n));
    vvi col(2, vi(n, n));
    vi diag1(2, n); // x = y
    vi diag2(2, n); // x + y = n - 1
    rep(i, m) {
        int p;
        cin >> p;
        rep(k, 2) {
            if (mp[k].count(p)) {
                int x, y;
                tie(x, y) = mp[k][p];
                row[k][x]--;
                if (row[k][x] == 0) u[k]--;
                if (n == 1) continue;
                col[k][y]--;
                if (col[k][y] == 0) u[k]--;
                if (x == y) {
                    diag1[k]--;
                    if (diag1[k] == 0) u[k]--;
                }
                if (x + y == n - 1) {
                    diag2[k]--;
                    if (diag2[k] == 0) u[k]--;
                }
            }
        }

        if (u[0] <= 0 && u[1] > 0) {
            cout << "USAGI" << endl;
            return 0;
        } else if (u[0] > 0 && u[1] <= 0) {
            cout << "NEKO" << endl;
            return 0;
        } else if (u[0] < 0 && u[1] < 0) {
            cout << "DRAW" << endl;
            return 0;
        }
    }

    cout << "DRAW" << endl;

}

Measured memory_bytes: 21012
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  int n,y;
  cin >> n >> y;
  y /= 1000;
  REP(i,n+1){
    for(int j = 0; i+j <= n;j++){
      int k = n - i - j;
      if(i+j*5+k*10 == y){
	cout << k << " " << j << " " << i << endl;
	return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
const int mod = 1e9+7;
vector<vector<int>> grid;
int main(){

    int r, c;
    cin >> r >> c;
    grid.assign(r+1, vector<int>(c+1, 1));
    for(int i = 1; i <= r ; ++i){
        for(int j = 1; j <= c ; ++j){
            char ch;
            cin >> ch;
            if(ch == '#') grid[i][j] = 0;
        }
    }
    vector<vector<int>> dp(r+1, vector<int>(c+1, 0));
    int dx[]={1,0}, dy[]={0,1};
    dp[1][1] = 1;
    for(int i = 1; i <= r ; ++i){
        for(int j = 1; j<= c ; ++j){
            for(int k = 0; k < 2 ; ++k){
                int nx = i+dx[k];
                int ny = j+dy[k];
                if(nx < 1 || ny < 1 || nx > r || ny > c) continue;
                if(!grid[nx][ny]) continue;
                dp[nx][ny] = (dp[nx][ny]+dp[i][j])%mod;
            }
        }
    }
    printf("%d\n", dp[r][c]);

    return 0;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
  long long N, M, K;
  cin >> N >> M >> K;
  long long A, B, C, T;
  cin >> A >> B >> C >> T;
  vector<long long> S(M);
  for(int i = 0; i < M; ++i) cin >> S[i], --S[i];
  S.push_back(N);
  K -= M;
  vector<long long> D;
  long long b = 0;
  for(int i = 0; i < M; ++i){
    long long s = S[i]*B, l = S[i];
    long long d = T - s;
    if(d < 0) break;
    long long r = l + d/A;
    r = min(r,S[i+1]-1);
    b += r - l + 1;
    // printf("i, l, r = %lld, %lld, %lld\n",i,l,r);
    l = r+1;
    for(int j = 0; j < K; ++j){
      if(l >= S[i+1]) break;
      long long t = s + (l-S[i])*C, d = T - t;
      if(d < 0) break;
      r = l + d/A;
      r = min(r,S[i+1]-1);
      long long c = r - l + 1;
      // printf("i, j, l, r = %lld, %lld, %lld, %lld\n",i,j,l,r);
      D.push_back(c);
      l = r + 1;
    }
  }
  sort(D.rbegin(), D.rend());
  long long ans = b;

  for(int i = 0; i < min(K,(long long)D.size()); ++i)
    ans += D[i];
  cout << ans-1 << endl;
}



Measured memory_bytes: 7104
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long ans = 0;
        for(long i=1;i<N;i++){
            for(long j=1;j<N;j++){
                if(i*j>=N) break;
                else{
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}


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

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
using ll = long long;

int main(){
	fastIO;
	ll x;
	cin >> x;
	ll lo=1,hi=1e4,mid;
	while(lo<=hi){
		mid=(lo+hi)/2;
		if(mid >= 4000){
			hi = mid-1;
			continue;
		}
		ll tot = 100;
		for(int i=0;i<mid;++i){
			tot*=1.01;
		}
		//cout << "mid = " << mid << " tot = " << tot << '\n';
		if(tot >= x)
			hi = mid-1;
		else
			lo = mid+1;
	}
	cout << lo << '\n';
	return 0;
}

Measured memory_bytes: 3648
import java.util.*;


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

        Scanner s = new Scanner(System.in);
        long a = s.nextInt();
        long b = s.nextInt();

        long ans = 0;
        if ((a * b)%2 == 0) {
            ans = (a * b)/2;
        } else {
            ans = (a * b)/2 + 1;
        }

        if (a == 1 || b == 1) {
            ans = 1;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
// https://atcoder.jp/contests/abc177/tasks/abc177_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};

void solve() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v(M);
    UnionFind uf(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[i] = {a, b};
        uf.unite(a, b);
    }
    int maxv = 0;
    REP(i, N) { maxv = max(maxv, uf.size(i)); }
    cout << maxv << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 7948
K = int(input())
L = [list(range(1, 10))]
A = list(range(1, 10))
for _ in range(9):
    M = []
    for m in L[-1]:
        m = str(m)
        i = int(m[-1])
        cand = []
        if i == 0:
            cand = ['0', '1']
        elif i == 9:
            cand = ['8', '9']
        else:
            cand = [str(i - 1), str(i), str(i + 1)]
        for c in cand:
            M += [int(m + c)]
    L += [M]
    A += M
print(A[K - 1])


Measured memory_bytes: 18488
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, t = map(int, input().split())
    A = list(map(int, input().split()))

    MAX_S = []
    max_s = 0
    for a in A[::-1]:
        if max_s < a:
            max_s = a
        MAX_S.append(max_s)
    MAX_S = MAX_S[::-1]

    cnt = defaultdict(int)
    for a, s in zip(A, MAX_S):
        cnt[s - a] += 1

    res = sorted(cnt.items(), reverse=True)
    print(res[0][1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 73748
# -*- coding: utf-8 -*-
import math
import datetime

# 入力
#N = int(input())
#S = str(input())
#H, W = map(int, input().split())
A, B = map(int, input().split())

if A >= 13 :
  print (B)
elif A >= 6 :
  print (int(B/2))
else :
  print (0)

Measured memory_bytes: 3312
#include <iostream>
#include <algorithm>
using namespace std;
pair <int,int> a[100005];
int main(int argc, char** argv) {
	int n,m;
	cin >> n >> m;
	long long ans=0;
	for(int i=1;i<=n;i++)
		cin >> a[i].first >> a[i].second;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		ans+=(long long)a[i].first*min(a[i].second,m);
		m-=min(m,a[i].second);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanString()
	k := scanInt()

	dp := make([][][]int, len(n)+1)

	for i := 0; i < len(n)+1; i++ {
		dp[i] = make([][]int, 2)
		dp[i][0] = make([]int, k+1)
		dp[i][1] = make([]int, k+1)
	}

	dp[0][0][0] = 1
	ans := 0

	// fmt.Println(dp[0][0])
	// fmt.Println(dp[0][1])

	for i := 0; i < len(n); i++ {
		num, _ := strconv.Atoi(string(n[i]))
		
		if num != 0 {
			for j := 0; j < k; j++ {
				if dp[i][0][j] == 0 {
					continue
				}
				dp[i+1][0][j+1] = dp[i][0][j]
				dp[i+1][1][j+1] = dp[i][0][j]*(num-1)
				dp[i+1][1][j] = dp[i][0][j]
			}
			dp[i+1][1][k] += dp[i][0][k]
		} else {
			for j := 0; j < k+1; j++ {
				dp[i+1][0][j] = dp[i][0][j]
			}
		}
		dp[i+1][1][0] = 1

		for j := 0; j < k; j++ {
			dp[i+1][1][j+1] += dp[i][1][j]*9+dp[i][1][j+1]
		}

		// fmt.Println(num)
		// fmt.Println(dp[i+1][0])
		// fmt.Println(dp[i+1][1])
		ans += dp[i+1][0][k] + dp[i+1][1][k]
	}

	fmt.Println(dp[len(n)][0][k] + dp[len(n)][1][k])
}

Measured memory_bytes: 640
#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,m,k;
	cin >> n >> m >>k;
	int time = 0;
	int counts = 0;
	vector<int> a(n);
	vector<int> b(m);
	rep(i,n) cin >> a[i];
	rep(j,m) cin >> b[j];

	ll t = 0;
	rep(i,m) t += b[i];

	int j = m;
	int ans = 0;
	rep(i,n+1){
		while(j > 0 && t > k){
			j--;
			t -= b[j];
		}
		if(t > k) break;
		ans = max(ans, i+j);
		if(i == n) break;
		t += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4828
#include <stdio.h>
int main(void){
    int i1,i2,i3,i4,n;
    scanf("%d\n",&n);
    char c[n],ansc[52];
    int x[n],ansx[52];
    for(i1=0;i1<=n-1;i1++){
        scanf("%c %d\n",&c[i1],&x[i1]);
    }
    i2=0;
    for(i3=0;i3<=51;i3++){
        if(0 <=i3 && i3<=13-1)ansc[i3]='S';
        if(13<=i3 && i3<=26-1)ansc[i3]='H';
        if(26<=i3 && i3<=39-1)ansc[i3]='C';
        if(39<=i3 && i3<=52-1)ansc[i3]='D';
        if(i2>12)i2=0;
        i2=i2+1;
        ansx[i3]=i2;
        for(i1=0;i1<=n-1;i1++){
            for(i4=0;i4<=n-1;i4++){
                if(c[i4]==ansc[i3] && x[i4]==ansx[i3])ansx[i3]=0;
            }
        }
        if(ansx[i3]!=0)printf("%c %d\n",ansc[i3],ansx[i3]);
    }
    return 0;
}

Measured memory_bytes: 600