akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

string Ascending(string s);
string Descending(string s);

int main(void){
	while(1){
		string a;
		int l;
		int cnt = 0;
		vector<string> seq;

		cin >> a >> l;
		if(l == 0) break;
	
		int size = a.size();
		for(int i=0; i< l - size; i++){
			a = '0' + a;
		}

		while(1){
			cnt++;
			string small, big;
			char tmp[100];
			seq.push_back(a);

			small = Ascending(a);
			big = Descending(a);

			sprintf(tmp, "%d", atoi(big.c_str()) - atoi(small.c_str()) );

			a = tmp;
			for(int i=0; i< l - a.size(); i++){
				a = '0' + a;
			}


			//cout << a << endl;
			
			vector<string>::iterator pos;
			pos = find(seq.begin(), seq.end(), a);
			if(pos != seq.end()){
				cout << pos - seq.begin();
				printf(" %d ", atoi(a.c_str()));
				cout << cnt - (pos - seq.begin()) << endl;
				break;	
			}
		}
	}

	return 0;
}

string Ascending(string s){
	for(int j=0; j<s.size() - 1; j++){
		for(int i=0; i<s.size() - 1; i++){
			if(s[i] > s[i+1]){
				char t = s[i+1];
				s[i+1] = s[i];
				s[i] = t;
			}
		}
	}

	return s;
}

string Descending(string s){
	for(int j=0; j<s.size() - 1; j++){
		for(int i=0; i<s.size() - 1; i++){
			if(s[i] < s[i+1]){
				char t = s[i+1];
				s[i+1] = s[i];
				s[i] = t;
			}
		}
	}

	return s;
}

Measured memory_bytes: 1268
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

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



int main(){
    int x;
    cin >> x;
    REP(i, 1, 600000){
        if( i * 108 / 100 == x ){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int sum=1000000000000;
//    cout<<sum<<endl;
    for(int i=1;i<=sqrt(n);i++)
    {
//        cout<<i<<endl;
        if(i*(n/i)== n)
        {
//            cout<<sum<<endl;
//            cout<<i*(n/i)<<endl;
            if(i+n/i-2<sum) sum=i+n/i-2;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,c,b[30];
int main()
{
	cin>>n>>m>>c;
	for(int i=0;i<m;i++)
		cin>>b[i];
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int s=0;
		for(int j=0;j<m;j++)
		{
			int cur;
			cin>>cur;
			s+=b[j]*cur;
		}
		if(s+c>0) ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ll n;cin >> n;vector<ll> a(3 * n);
	rep(i,3 * n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	ll sum = 0;
	rep(i,n) {
		sum += a[2 * i + 1];
	}
	cout << sum << endl;
}

Measured memory_bytes: 2560
import sys

def main():
  input = sys.stdin.readline
  K, A, B = map(int, input().split())

  if B < (A+2):
    ans = K + 1
  else:
    rest = K - (A - 1)
    n = rest // 2
    ans = A + n * (B - A) + rest % 2
  print(ans)


if __name__ == '__main__':
  main()

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

using namespace std;

template<class INT>
std::vector<INT> factorize(INT n){
    std::vector<INT> res;
    for (INT i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i * i != n)
                res.push_back(n / i);
        }
    }
    return res;
}

template<class INT>
std::map<INT, int> prime_factorize(INT n){
    std::map<INT, int> res;
    for (INT i = 2; i * i <= n; i++){
        while (n % i == 0){
            res[i]++;
            n /= i;
        }
    }

    if (n > 1)
        res[n]++;

    return res;
}

int main(){
    int64_t n;
    cin >> n;
    int64_t ans = 0;
    auto F = factorize(n - 1);
    ans += F.size() - 1;

    auto F2 = factorize(n);
    for (const auto &f: F2){
        if (f == 1) continue;
        int64_t m = n;
        while (m % f == 0 and m != 1)
            m /= f;
        if (m % f == 1)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

#define MAXV 100001

int main(int argc, char const *argv[])
{
    unsigned int n; cin >> n;
    unsigned int a;
    unsigned int e[MAXV], o[MAXV];
    for(unsigned int i=0;i<MAXV;++i) e[i]=o[i]=0;

    for(unsigned int i=0;i<n;++i) {
        cin >> a;
        if(i&1) ++o[a];
        else ++e[a];
    }
    unsigned int em1=0, om1=0, em2=0, om2=0;
    unsigned int ev=0, ov=0;
    unsigned int ec=0, oc=0;
    a=n;
    for(unsigned int i=0;i<MAXV;++i) {
        if(e[i]>em1) {
            em2=em1; em1=e[i];
            ev=i; ec=1;
        } else if(e[i]==em1) {
            ++ec;
        } else if(e[i]<em1 && e[i]>em2) {
            em2=e[i];
        }
        if(o[i]>om1) {
            om2=om1; om1=o[i];
            ov=i; oc=1;
        } else if(o[i]==om1) {
            ++oc;
        } else if(o[i]<om1 && o[i]>om2) {
            om2=o[i];
        }
    }

    if(ec==1 && oc==1 && ev==ov) {
        a -= max(em1+om2, em2+om1);
    } else {
        a -= em1+om1;
    }
    cout << a << endl;
    //cout << ev << " " << ov << endl;
    return 0;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    auto A = make_vector(3, 3, 0);
    cin >> A;
    
    int N = input();
    range(i, 0, N) {
        int b = input();
        range(j, 0, 3) range(k, 0, 3) if (A[j][k] == b) A[j][k] = -1;
    }

    range(i, 0, 3) {
        bool f = true;
        range(j, 0, 3) f = f && (A[i][j] == -1);
        
        if (f) {
            cout << "Yes" << endl;
            return;
        }
    }
    
    range(j, 0, 3) {
        bool f = true;
        range(i, 0, 3) f = f && (A[i][j] == -1);
        
        if (f) {
            cout << "Yes" << endl;
            return;
        }
    }

    bool f = true;
    range(i, 0, 3) f = f && (A[i][i] == -1);
    
    if (f) {
        cout << "Yes" << endl;
        return;
    }
    
    f = true;
    range(i, 0, 3) f = f && (A[i][2 - i] == -1);
    
    if (f) {
        cout << "Yes" << endl;
        return;
    }
    
    cout << "No" << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

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

int main(){
    ll N,x;
    cin >> N >> x;
    if (x==1||x==2*N-1){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
        if (N==2&&x==2){
            cout << 1 << endl;
            cout << 2 << endl;
            cout << 3 << endl;
        }
        ll now=1;
        if (x!=2){
            rep2(i,1,2*N){
                if (i==N-1){
                    cout << x-1 << endl;
                    cout << x << endl;
                    cout << x+1 << endl;
                    cout << x-2 << endl;
                    if (now==x-2){
                        now+=4;
                    }
                    i+=3;
                }
                else if (now==x-2){
                    cout << now+4 << endl;
                    now+=5;
                }
                else {
                    cout << now << endl;
                    now++;
                }
            }
        }
        else if(N!=2){
            now=5;
            rep2(i,1,2*N){
                if (i==N-1){
                    cout << 3 << endl;
                    cout << 2 << endl;
                    cout << 1 << endl;
                    cout << 4 << endl;
                    i+=3;
                }
                else {
                    cout << now << endl;
                    now++;
                }
            }
        }
    }
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	while(1){
		scanf("%d %c %d", &a, &op, &b);
		if(op == '?') break;
		if(op == '+') printf("%d\n", a+b);
		if(op == '-') printf("%d\n", a-b);
		if(op == '*') printf("%d\n", a*b);
		if(op == '/') printf("%d\n", a/b);
	}
	return 0;
}


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

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *Node;

Node r,NIL;


void insert(int k){
  Node y = NIL;
  Node x = r;

  Node z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }else{
      x = x->r;
    }
  }
  z->p = y;
  if(y == NIL){
    r = z;
  }else if(z->key < y->key){
    y->l = z;
  }else{
    y->r = z;
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(Node u){
  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

void print(){
  inorder(r);
  printf("\n");
  preorder(r);
  printf("\n");
}

int main(){
  int n,i,j,z;
  char s[10];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%d",s,&z);
    if(s[0] == 'i'){
      insert(z);
    }else{
      print();
    }
  }

  return 0;
}


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

using namespace std;

int main(){
  int N, L;
  cin >> N >> L;
  vector<string> str(N);
  for (int i = 0; i< N;i++){
    cin >> str.at(i);
  }
  sort(str.begin(), str.end());
  
  for (int i = 0; i<N; i++){
    cout << str.at(i);
  }
  cout << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <functional>
#include<stdio.h>
using namespace std;
#define ll       	long long int
#define dd      	long double
#define pb          push_back
#define pf          push_front
#define pi         pair<ll,ll>
#define vi          vector<ll>
#define vpi        vector<pi>
#define mi          map<ll,ll>
#define vvi         vector<vector<ll>>
#define mpi         map<pi,ll>
#define pipi        pair<ll,pair<ll,ll> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x         first
#define y         second
#define sz(x)       (ll)x.size()
#define u        	'\n'
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define rf(s)       for(auto &c : s)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++) //use Iterator
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           998244353
#define ef          else if
#define yes       cout<<"YES"<<'\n';
#define no        cout<<"NO"<<'\n';
#define C         continue;
#define wa(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<'\n'
#define debugp(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i.x<<","<<i.y<<" | "; cout<<'\n'
#include <ext/pb_ds/tree_policy.hpp>     
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>     
using namespace __gnu_pbds;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key
const ll N = 350;
 
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); } 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) 
    { 
        if (y & 1) 
        res = res*x; 
        y = y>>1; 
        x = x*x;  
    } 
    return res; 
}

signed main()
{
	tezz
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n,k,j,i;
		cin>>n>>k;
		vpi v(k);
		fo(i,0,k)
		{
			ll l,r;
			cin>>l>>r;
			v[i]={l,r};	
		}
		vi t1(n+1,0);
		t1[1]=1;
		t1[2]=-1;
		fo(i,1,n+1)
		{
			t1[i]=(t1[i]+t1[i-1])%M;
			fo(j,0,k)
			{
				if(i+v[j].x<=n)
				t1[i+v[j].x]=(t1[i+v[j].x]+t1[i])%M;
				
				if(i+v[j].y+1<=n)
				t1[i+v[j].y+1]=(t1[i+v[j].y+1]-t1[i]+M)%M;
			}
		}
		cout<<t1[n]<<u;
	}
	return 0;
} 

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

char in[120];
pair<pair<string,int>,int> p[110];
int main(){
  int a;scanf("%d",&a);
  for(int i=0;i<a;i++){
    int t;scanf("%s%d",in,&t);
    string tmp=in;
    p[i]=make_pair(make_pair(in,-t),i);
  }
  std::sort(p,p+a);
  for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);
}

    

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,i,j;
double x;
int d[6]={0};
scanf("%d",&n);
for(i=0;i<n;i++){
		scanf("%lf",&x);
		if(x<165.0)d[0]++;
		else if(x<170.0)d[1]++;
		else if(x<175.0)d[2]++;
		else if(x<180.0)d[3]++;
		else if(x<185.0)d[4]++;
		else if(x<190.0)d[5]++;
	}for(i=0;i<6;i++,j=0){printf("%d:",i+1);for(j=0;j<d[i];j++)printf("*");printf("\n");}exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, count = 0, ans = 0;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.at(i) -= a;
        if (A.at(i) == 0) {
            count++;
        }
    }
    int i = 0;
    while (count != N) {
        if (A.at(i) != 0) {
            for (int j = i; j < N; j++) {
                if (A.at(j) == 0) {
                    ans++;
                    break;
                }
                else {
                    A.at(j)++;
                    if (A.at(j) == 0) {
                        count++;
                    }
                }
                if (j == N - 1) {
                    ans++;
                }
            }
        }
        else {
            i++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

vector<int> m = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

string comp(string a, string b) {
    if(a.length() > b.length()) return a;
    else if(a.length() < b.length()) return b;
    else {
        return a > b ? a : b;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M, 0);
    for(int i = 0; i < M; i++) cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());

    vector<string> dp(max(N+1,10), "");
    for(int i = 0; i < M; i++) dp[m[A[i]]] = comp(dp[m[A[i]]], to_string(A[i]));
    for(int j = 0; j <= N; j++) {
        for(int i = 0; i < M; i++) {
            if(j - m[A[i]] >= 0 && dp[j-m[A[i]]] != "") dp[j] = comp(dp[j], dp[j-m[A[i]]] + to_string(A[i]));
        }
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 32896
N,M = map(int,input().split())
ts = []
for i in range(M):
    a,b = map(int,input().split())
    ts.append([b,a])
ts.sort()
tmp = 0
count = 0
for i in range(M):
    if ts[i][1]>=tmp:
        tmp = ts[i][0]
        count += 1
print(count)

Measured memory_bytes: 20168
#include <stdio.h>

// Sunny, Cloudy, Rainy
int main () {
  char s[100];
  scanf("%s", s);
  if (s[0] == 'S') {
    printf ("Cloudy\n");
  } else if (s[0] == 'C') {
    printf ("Rainy\n");
  } else {
    printf ("Sunny\n");
  }
}


Measured memory_bytes: 128
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    x, k, d = in_nl()

    if x < 0:
        x = -x
    if d * k <= x:
        ans = abs(x - d * k)
    else:
        cnt = x // d
        if cnt % 2 == k % 2:
            ans = abs(x - d * cnt)
        else:
            ans = abs(x - d * (cnt + 1))

    print(ans)


if __name__ == '__main__':
    main()


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

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

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() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<vector<int>> dp(n + 1, vector<int>(h + 1, 1001001001));

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

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= h; j++) {
            if (j - a[i] <= 0)
                if (j <= a[i])
                    dp[i + 1][j] = min(b[i], dp[i][j]);
                else
                    dp[i + 1][j] = dp[i][j];
            else
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i]);
        }
    }

    cout << dp[n][h] << endl;
    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    bool found = false;
    for (int i = n; i <= m / 2; i++)
    {
        if (m % i == 0)
        {
            cout << m / i;
            found = true;
            break;
        }
    }
    if (!found)
    {
        cout << 1;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <queue>
#include <cassert>
#include <stack>

using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

void print(const vi &a) {
    for (auto item : a) {
        cout << item << " ";
        flush(cout);
    }
}

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

    int a, b;
    cin >> a >> b;

    cout << max((a - b - b), 0);


    return 0;
}


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

int main(){
	int n,f;
	
	cin>>n;
	
	int a[n],s=0,i;
	
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	
	do{
		f=0;
		for(i=0;i<n;i++){
			if(a[i]%2==0){
				a[i]=a[i]/2;
			}else{
				f=1;
				break;
			}
		}
		if(f==0){
			s++;
		}
		
	}while(f==0);
	
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())

a = [False]*n
b = [0]*n

for i in range(m):
  x,y = input().split()
  x = int(x)
  if y == 'AC':
    a[x-1] = True
  elif y == 'WA' and a[x-1] == False:
    b[x-1] += 1

ac = 0
wa = 0
for i in range(n):
  if a[i] == True:
    ac += 1
    wa += b[i]
    
print(ac, wa)

Measured memory_bytes: 4724
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

bool check(const string& s) {
  if (s[0] != 'A') return false;
  int n = s.size();
  int cnt = 0;
  for (int i = 2; i <= n - 2; i++) {
    if (s[i] == 'C')
      cnt++;
    else if (!isalpha(s[i]) || !islower(s[i]))
      return false;
  }
  if (cnt != 1) return false;
  if (!islower(s[n - 1]) || !islower(s[1])) return false;
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (check(s))
    cout << "AC" << endl;
  else
    cout << "WA" << endl;

  return 0;
}


Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int, input().split()))
q = int(input())

cnt = collections.Counter(a)

sum = sum(a)
sl = []
for i in range(q):
    b, c = map(int, input().split())
    bc = cnt[b]
    sum = sum - b*bc + c*bc
    sl.append(sum)

    if cnt[b] > 0:
        cnt[c] += cnt[b]
        cnt[b] = 0

for j in range(len(sl)):
    print(sl[j])

Measured memory_bytes: 22156
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int a, b, c;
int main(){
	scanf("%d%d%d", &a, &b, &c);
	if(c >= a && c <= b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
H=list(map(int,input().split()))

ANS=[1]*N
path=[]

for i in range(M):
    A,B = map(int,input().split())
    if H[A-1]==H[B-1]:
        ANS[A-1]=0
        ANS[B-1]=0
    elif H[A-1]>H[B-1]:
        ANS[B-1]=0
    else:
        ANS[A-1]=0

print(sum(ANS))

Measured memory_bytes: 20116
a = [input().split() for l in range(3)]
n = int(input())
b = [input() for i in range(n)]
c = [a[0][0],a[1][1],a[2][2]]
d = [a[0][2],a[1][1],a[2][0]]
tate1 = len(set(a[0]) & set(b))
tate2 = len(set(a[1]) & set(b))
tate3 = len(set(a[2]) & set(b))
yoko1 = len(set([x[0] for x in a]) & set(b))
yoko2 = len(set([x[1] for x in a]) & set(b))
yoko3 = len(set([x[2] for x in a]) & set(b))
naname1 = len(set(c) & set(b))
naname2 = len(set(d) & set(b))
bingo = [tate1,tate2,tate3,yoko1,yoko2,yoko3,naname1,naname2]
if 3 in bingo:
  print("Yes")
else:
  print("No")

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

#define FOR(i,m,n) for(int i=(m); i<(n); ++i)
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef vector<P> vp;
typedef queue<P> Q;
inline int in() { int x; cin >> x; return x; }

void solve() {
  int n = in(), d2 = in()*2, a = in();
  vp p(n); for(auto &a : p) a = {in(),in()}; sort(all(p));
  int ans = 0, damage = 0;
  Q q;
  FOR(i,0,n) {
    int x, h; tie(x,h) = p[i];
    while (!q.empty() && q.front().first < p[i].first) {
      damage -= q.front().second; q.pop();
    }
    h -= damage;
    if (h>0) {
      int t = (h+a-1)/a;
      int at = a*t;
      ans += t;
      damage += at;
      q.push({x+d2, at});
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define RI register int
using namespace std;
typedef long long LL;
int const MAXN = 1e5 + 5;
LL a[MAXN], b[MAXN], f[MAXN], fa[MAXN], size[MAXN];
template <typename T>
inline void read(T &n){
	n = 0 ; register char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	for( ; isdigit(ch) ; ch = getchar())
		n = n * 10 + (ch ^ 48);
}
inline LL Find(LL k){
	if(fa[k] == k) return k;
	fa[k] = Find(fa[k]);
	size[k] = size[fa[k]];
	return fa[k];
}
inline LL link(LL a, LL b){
	LL t1 = Find(a), t2 = Find(b);
	if(t1 == t2) return 0;
	else{
		fa[t1] = t2;
		LL t = size[t1] * size[t2];
		size[t2] += size[t1];
		return t;
	}
}
int main(){
	LL n, m; read(n), read(m);
	for(RI i = 1 ; i <= n ; ++i)
		fa[i] = i, size[i] = 1;
	for(RI i = 1 ; i <= m ; ++i)
		read(a[i]), read(b[i]);
	f[m] = n * (n - 1) / 2;
	for(RI i = m - 1 ; i >= 1 ; --i)
		f[i] = f[i + 1] - link(a[i + 1], b[i + 1]);
	for(RI i = 1 ; i <= m ; ++i)
		printf("%lld\n", f[i]);
	return 0;
}

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

const ll mod = 1e9+7;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

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

mint mpow(ll x, ll n){//x^n(mod M)
    mint ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

mint comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    mint tmp = ifac[a-b]* ifac[b];
    return tmp * fac[a];
}

int main() {
    int x, y;
    cin >> x >> y;
    if((x+y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<1000000; i++){
        fac[i+1] = fac[i]*(i+1); // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, mod-2); // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    int x1 = (2*x-y) / 3;
    int y1 = (2*y-x) / 3;
    // cout << "dd " << endl;
    if(x1 < 0 || y1 < 0){
        cout << 0 << endl;
        return 0;
    }
    
    // cout << y1 << " " << x1 << endl;
    cout << comb(x1+y1, x1) << endl;

    return 0;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;
typedef pair<int,int> ii;

int n;
vector<int> al[105];
vector<ii> edges;

int deg[105];

void dfs(int i,int p,int depth){
    deg[depth]=max(deg[depth],(int)al[i].size()-1);
    for (auto &it:al[i]){
        if (it==p) continue;
        dfs(it,i,depth+1);
    }
}

int main(){
    scanf("%d",&n);
    
    if (n==2){
        printf("1 2\n");
        return 0;
    }
    int a,b;
    for (int x=1;x<n;x++){
        scanf("%d%d",&a,&b);
        al[a].push_back(b);
        al[b].push_back(a);
        edges.push_back(ii(a,b));
    }

    int color=1000000;
    long long best=-1;

    for (int x=1;x<=n;x++){
        memset(deg,-1,sizeof(deg));
        dfs(x,-1,0);
        int c;
        long long v=1;

        deg[0]=al[x].size();

        for (int x=0;deg[x];x++){
            c=x;
            v*=deg[x];
        }

        if (c<color){
            color=c;
            best=v;
        }
        else if (c==color){
            best=min(best,v);
        }
    }

    for (auto &it:edges){
        memset(deg,-1,sizeof(deg));
        dfs(it.first,it.second,0);
        dfs(it.second,it.first,0);
        int c;
        long long v=2;

        for (int x=0;deg[x];x++){
            c=x;
            v*=deg[x];
        }

        if (c<color){
            color=c;
            best=v;
        }
        else if (c==color){
            best=min(best,v);
        }
    }

    printf("%d %lld\n",color+2,best);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC85 C

n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(i,j,n-i-j)
            quit()
print(-1,-1,-1)


Measured memory_bytes: 40684
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,c,k = LI()
    t = IR(n)
    t.sort()
    i = 0
    ans = 0
    while i < n:
        i = min(i+c,bisect.bisect_right(t, t[i]+k))
        ans += 1
    print(ans)
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


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

using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int64 N, X;
  cin >> N >> X;
  vector< int > L(N);
  cin >> L;
  int ret = 0;
  int64 now = 0;
  for(int i = 0; i < N; i++) {
    if(now <= X) ++ret;
    now += L[i];
  }
  if(now <= X) ++ret;
  cout << ret << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans=0
for i in range(1,int(m**0.5)+1):
  if m%i>0:continue
  a=i
  b=m//i
  if a*n<=m:ans=max(ans,a)
  if b*n<=m:ans=max(ans,b)
print(ans)


Measured memory_bytes: 9368
#include<bits/stdc++.h>
using namespace std;
int du[100100];


int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        ++du[u]; ++du[v];
    }
    bool ok=true;
    for(int i=1;i<=n;++i)
        if(du[i]&1)
            ok=false;
    if(ok) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 640
n,  k = list(map(int, input().split()))
al = list(map(int, input().split()))
cnt = [0]*n*2
dif = [0]*n
MOD = 10**9+7

al = al + al
for i in range(len(al)-1):
    for j in range(i+1, len(al)):
        if al[j] < al[i]:
            cnt[i] += 1

for i in range(n):
    dif[i] = cnt[i] - cnt[i+n]
print((sum(cnt[n:])*k + sum(dif)*(1+k-1)*(k-1)//2) % MOD)


Measured memory_bytes: 41452
import java.util.Scanner;

class Main{
	public static void main(String[] arg){
	
		Scanner sc = new Scanner(System.in);
		int m=sc.nextInt();
		
		int t = 0,h=0;
		for(int i=0;i<m;i++){
			String taro,hana;
			taro=sc.next();
			hana=sc.next();
			//taro=taro.substring(0, 1);
			//hana=taro.substring(0, 1);
			if(taro.compareTo(hana)>0){
				t+=3;
				
			}else if(taro.compareTo(hana)<0){
				h+=3;
			}else{
				t+=1;
				h+=1;
			}
                   }
		System.out.println(t+" "+h);	
		
		
		
		
		
		
		}
}


Measured memory_bytes: 29696
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int X; cin >> X;
  int m=0;
  while (1){
    int s = m*(m+1)/2;
    if (s>=X) break;
    m++;
  }
  cout << m << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

typedef pair<ll, Pin> pa;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    ll A[X], B[Y], C[Z];
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];

    sort(A, A + X, greater<ll>());
    sort(B, B + Y, greater<ll>());
    sort(C, C + Z, greater<ll>());

    int m1 = min(K, X * Y);

    ll xy[m1];
    priority_queue<pa, vector<pa>, less<pa>> q1;
    q1.push(pa(A[0] + B[0], Pin(0, 0)));
    bool f1[X][Y];
    memset(f1, 0, sizeof(f1));

    int cnt = 0;
    while(cnt < m1) {
        pa cur = q1.top(); q1.pop();
        int cx = cur.se.fi, cy = cur.se.se;
        if (f1[cx][cy]) continue;
        f1[cx][cy] = true;
        xy[cnt++] = cur.fi;

        if (cx < X - 1){
            q1.push(pa(A[cx+1] + B[cy], Pin(cx + 1, cy)));
        }

        if (cy < Y - 1){
            q1.push(pa(A[cx] + B[cy+1], Pin(cx, cy + 1)));
        }
    }

    int m2 = min(K, X * Y * Z);
    ll xyz[m2];
    priority_queue<pa, vector<pa>, less<pa>> q2;
    q2.push(pa(xy[0] + C[0], Pin(0, 0)));
    bool f2[m1][Z];
    memset(f2, 0, sizeof(f2));

    cnt = 0;
    while(cnt < m2) {
        pa cur = q2.top(); q2.pop();
        int cx = cur.se.fi, cy = cur.se.se;
        if (f2[cx][cy]) continue;
        f2[cx][cy] = true;
        xyz[cnt++] = cur.fi;

        if (cx < m1 - 1){
            q2.push(pa(xy[cx+1] + C[cy], Pin(cx + 1, cy)));
        }

        if (cy < Z - 1){
            q2.push(pa(xy[cx] + C[cy+1], Pin(cx, cy + 1)));
        }
    }

    REP(i, m2) cout << xyz[i] << " ";
    cout << endl;

}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;
int main(){
	int a, b, ans;
	cin >> a >> b;
	for (int i = b - a + 1; i <= a + b - 1; i++) {
		cout << i;
		if (i == a + b - 1)cout << endl;
		else cout << " ";
	}

		please AC;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int sum(int n) {
	int ans = 0;
	while (n) {
		ans += (n % 10);
		n /= 10;
	}
	return ans;
}

int32_t main() {
	FIO;


	int n ;
	cin >> n ;


	int val = sum(n);


	if ( n % val == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}







	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n, i,j, t=0;
	int a[200000];
	
	cin >>n;
	for(i = 0;i<n;i++){
	    cin >>a[i];
	}
	sort(a, a+n);
	for(i=0;i<n;i++){
	    if(a[i]==a[i+1]){
	        t=1;
	        break;
	    }
	}
	if(t==1) cout << "NO";
	else cout<<"YES";
	
	return 0;
}

Measured memory_bytes: 1024
/* Author: shriamrut
 * Language: C++17
 * Made on:26.01.2020
 * */
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
using namespace std;
void ra(auto a[],int n) { for(int i=0;i<n;i++) cin>>a[i];}
void pa(auto a[],int n) { for(int i=0;i<n;i++) cout<<a[i]<<" ";}
void rv(vector<auto>&v,int n) {v.resize(n);for(int i=0;i<n;i++)	cin>>v[i]; }
void pv(vector<auto>&v) {for(size_t i=0;i<v.size();i++) cout<<v[i]<<" ";}
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
int main() {
	IOS;
	int h,n;
	cin>>h>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	int sum=accumulate(a.begin(),a.end(),0);
	if(sum>=h)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>


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


map<string, int> mp;

int main() {
    int a;
    cin >> a;
    if (a == 25) {
        cout << "Christmas" << endl;
    }
    else if (a == 24) {
        cout << "Christmas Eve" << endl;
    }
    else if (a == 23) {
        cout << "Christmas Eve Eve" << endl;
    }
    else if (a == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }

}

Measured memory_bytes: 256
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

li = [-1] * n

for s,c in sc:
    if li[s-1] == -1 or li[s-1] == c:
        li[s-1] = c
    else:
        print(-1)
        exit()
    if n != 1 and s == 1 and c == 0:
        print(-1)
        exit()

for i in range(n):
    if li[i] == -1:
        if i == 0 and n != 1:
            li[i] = 1
        else:
            li[i] = 0

ans = ''
for i in li:
    ans += str(i)

print(int(ans))


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	char c[3];
	int  n=0;
	scanf("%s\n", c);
	if(c[0] == '1') n += 900;
	else n+=100;
	if(c[1] == '1') n += 90;
	else n+=10;
	if(c[2] == '1') n += 9;
	else n+=1;
	printf("%d\n", n);
	return 0;
}

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

int main() {
  long N;
  cin >> N;
  vector<int> V;
  while (N) {
    V.push_back(N % 26), N /= 26;
  }
  for (int i = 0; i + 1 < V.size(); i++) {
    if (V.at(i) <= 0) {
      V.at(i + 1)--;
      if (i + 1 == V.size() - 1 && V.at(i + 1) == 0) V.erase(V.end() - 1);
    }
  }
  reverse(V.begin(), V.end());
  for (auto v : V) {
    if (v == 0) cout << 'z';
    else if (v == -1) cout << 'y';
    else cout << char('a' + v - 1);
  }
  cout << "\n";
}


Measured memory_bytes: 3624
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	auto n = read.to!long;
	auto a = read.to!long;
	auto b = read.to!long;
	
	long[] ps;
	foreach(i; 0 .. n) ps ~= read.to!long;
	
	long c1, c2, c3;
	foreach(p; ps){
		if(p <= a) c1 += 1;
		else if(p <= b) c2 += 1;
		else c3 += 1;
	}
	
	long ans = n;
	if(c1 < ans) ans = c1;
	if(c2 < ans) ans = c2;
	if(c3 < ans) ans = c3;
	if(ans == n) ans = 0;
	
	ans.writeln;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
W_C=int((7*a)+b)
#1週間の総コイン数

W=c//W_C
#何週間必要か

C=W_C*W
#W週間で得られたコイン数

if 7*a<c-C<W_C:
#1日で貰えるコイン×７<
#必要なコイン - W週間で得られたコイン数<
#1週間の総コイン数
    print((W+1)*7)

else:
    day=0
    coin=0
    while coin<c-C:
        coin+=a
        day+=1

    print(W*7+day)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
unsigned GetDigit(int A,unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= A;
        digit++;
    }
    return digit;
}

int main(){
    int N, K;
    cin >> N >> K;
    cout << GetDigit(K, N) << endl;    
}

Measured memory_bytes: 256
from itertools import accumulate

n, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

w1 = wv[0][0]
weights = [[] for _ in range(4)]

for w, v in wv:
    w_diff = w - w1
    weights[w_diff].append(v)

for i in range(4):
    weights[i].sort(reverse=True)

acc = [[0] + list(accumulate(li)) for li in weights]

l3 = len(weights[3])
ans = 0
for i, e1 in enumerate(acc[0]):
    for j, e2 in enumerate(acc[1]):
        for k, e3 in enumerate(acc[2]):
            w_sm = w1 * i + (w1 + 1) * j + (w1 + 2) * k
            if w_sm > W:
                break

            l = min((W - w_sm) // (w1 + 3), l3)
            val = acc[0][i] + acc[1][j] + acc[2][k] + acc[3][l]
            ans = max(ans, val)

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    long long int n,m,s,s1;
    scanf("%lld %lld",&n,&m);
    s=((n*(n-1))/2);
    s1=((m*(m-1))/2);

    printf("%lld\n",s+s1);
    return 0;
}


Measured memory_bytes: 128