akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    private static long[] fact;

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        System.out.println(solve(n, k));
    }

    /**
     * https://algo-logic.info/abc156e/
     */
    private static long solve(int n, int k) {
        long count = 0;
        fact = factInit(n, MOD);

        for (int numZeroRoom=0; numZeroRoom<=Math.min(n-1, k); numZeroRoom++) {
            // ゼロ人の部屋の配置パターン数(nCz) * 1人以上の部屋の配置パターン数((n-z)Hz)
            // n-z H z = (n-z + z - 1) H z = (n-1)Hz
            count += combination(n, numZeroRoom, MOD) * combination(n-1, numZeroRoom, MOD) % MOD;
            count %= MOD;
        }

        return count;
    }

    public static long combination(int n, int r, long p) {
        if (n == 0 && r == 0) return 1;
        if (n < r || n < 0)   return 0;

        return (fact[n] * power((fact[r]), p-2, p) % p) * power(fact[n-r], p-2, p) % p;
    }

    public static long[] factInit(int n, long p) {
        long[] fact = new long[n+1];
        fact[0] = 1;
        fact[1] = 1;
        for (int i=2; i<=n; i++) {
            fact[i] = i * fact[i-1] % p;
        }

        return fact;
    }

    public static long power(long base, long t, long p) {
        long ans = 1;

        while (t > 0) {
            if (t%2 == 1) {
                ans = ans * base % p;
            }

            t /= 2;
            base = base * base % p;
        }

        return ans;
    }

}

Measured memory_bytes: 25940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef pair<string,int> P;
map<string,vector<string> > rm;
map<string,int> I;
int N,M;
//map<string,int> dp;
int solve(string S){
  // if(dp[S]!=0) return dp[S]; 
  if(rm[S].empty()) return I[S];
  int n = rm[S].size();
  int ret=0;
  for(int i=0;i<n;i++){
    ret+=solve(rm[S][i]);
  }
  ret = min(I[S],ret);
  return ret;
}

main(){
  while(1){
    cin >> N;
    if(!N) break;
    for(int i=0;i<N;i++){
      string Is;
      int Ii;
      cin >> Is >> Ii;
      I[Is]=Ii;
    }
    cin >> M;
    for(int i=0;i<M;i++){
      string s;
      int k;
      cin >> s >> k;
      for(int i=0;i<k;i++){
	string si;
	cin >> si;
	rm[s].push_back(si);
      }
    }
    string Q;
    cin >> Q;
    cout << solve(Q) << endl;
    rm.clear();
    I.clear();
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}


ll count_power(ll n,ll prime){
    ll ans = 0;
    ll now = prime;
    while(now<=n){
       ans = ans+(n/now);
       now = now*prime;
    }
    return ans;
}


int main(){
  ll n;
  cin>>n;
  ll power_two,power_five;
  if(n%2==0){
     power_two = count_power(n/2ll,2ll)+n/2ll;
     power_five = count_power(n/2ll,5ll);
  }
  else{
    power_two = count_power(n,2ll)-count_power(n/2ll,2ll)-(n/2ll);
    power_five = count_power(n,5ll)-count_power(n/2ll,5ll);
  }
    cout<<min(power_five,power_two)<<endl;
}

Measured memory_bytes: 256
import math

n = int(input())
x_lst = map(int, input().split())
y_lst = map(int, input().split())

xy_lst = list(zip(x_lst, y_lst))

p1 = 0
p2 = 0
p3 = 0
p4 = []
for x, y in xy_lst:
    # マンハッタン距離
    p1 += abs(x - y)
    # ユークリッド距離
    p2 += (abs(x - y)) ** 2
    p3 += (abs(x - y)) ** 3
    # チェビシェフ距離
    p4.append(abs(x - y))
print(p1)
print(math.sqrt(p2))
print(math.pow(p3, 1 / 3))
print(max(p4))


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

#include <bits/stdc++.h>
using namespace std;

template<typename T>
struct edge {
    int src, to;
    T cost;

    // to, costで初期化
    edge (int to, T cost) : src(-1), to(to), cost(cost) {}

    // src, to, costで初期化
    edge (int src, int to, T cost) : src(src), to(to), cost(cost) {}

    // toにxを代入？
    edge &operator=(const int &x) {
        to = x;
        return *this;
    }
    
    // edge()でtoを返す？
    operator int() const {return to;}
};

// templates
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<Edges<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/*
 * Dijkstra
 * input: WeightedGraph<T> &g: グラフ
 *        int s: 始点
 * output: vector<T>: sから各要素への最短経路長
 */
template<typename T>
vector<T> dijkstra(WeightedGraph<T> &g, int s) {
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(g.size(), INF);

    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        T cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

double distance(double x1, double y1, double x2, double y2) {
  return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  double xs, ys, xt, yt; int n;
  cin >> xs >> ys >> xt >> yt >> n;
  vector<double> x(n), y(n), r(n);
  REP(i, n) {
    cin >> x[i] >> y[i] >> r[i];
  }
  x.pb(xs); y.pb(ys); r.pb(0);
  x.pb(xt); y.pb(yt); r.pb(0);

  WeightedGraph<double> graph(n+2);
  REP(i, n+2) {
    REP(j, n+2) {
      if(i != j) {
        edge<double> e(j, max(0.0, distance(x[i], y[i], x[j], y[j]) - r[i] - r[j]));
        graph[i].pb(e);
      }
    }
  }

  vector<double> dist = dijkstra(graph, n);
  cout << dist[n+1] << endl;
}


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

int main(void) {
  int K, T;
  cin >> K >> T;
  vector<int> a(T);
  for (int i = 0; i < T; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  cout << max(a[0] - accumulate(a.begin() + 1, a.end(), 0) - 1, 0) << endl;
  return 0;
}

Measured memory_bytes: 3612
import sys

n = int(input())
a = list(map(int, input().split()))


def multiple(l):
    ans = 1
    if 0 in l:
        return 0
    for i in l:
        if ans * i > 10 ** 18:
            return -1
        else:
            ans *= i
    return ans


print(multiple(a))

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

int main(){
  int a, b, k;
  
  cin >> a >> b >> k;
  if (a < b){ 
    int temp = b;
    b = a;
    b = temp;
  }
  
  int max = a;
  while(k>0){
    if(a % max == 0 && b % max == 0){
     k--; 
    }
    max--;
  }
  cout << max + 1;
  
  return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int w, h;
vector<vector<char>> c;
int ans;

void dfs(int i, int j) {
    c[i][j] = '#';
    ++ ans;
    rep(k, 4) {
        int ni = i + dx[k], nj = j + dy[k];
        if(0 <= ni and ni < h and 0 <= nj and nj < w and c[ni][nj] == '.') {
            dfs(ni, nj);
        }
    }
}

void solve() {
	while(cin >> w >> h) {
        if(w == 0 and h == 0) break;
        c.assign(h, vector<char>(w));
        int si, sj;
        rep(i, h) {
            rep(j, w) {
                cin >> c[i][j];
                if(c[i][j] == '@') {
                    c[i][j] = '.';
                    si = i, sj = j;
                }
            }
        }
        ans = 0;
        dfs(si, sj);
        cout << ans << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;

 
int main() {
	
	int N;
	std::cin>>N;
	
	int o=N/2;
	int e=N/2;
	if(N%2==1){o++;}
	ce(o*e)
}

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

using namespace std;

int main(){
    while(true){
        string s,t;
        cin>>s;
        if(s==".")break;
        cin>>t;
        int si=0,ti=0;
        bool dq=false;
        int stat=0;//0:IDENTICAL 1:CLOSE 2:DIFFERENT
        while(si<s.size()&&ti<t.size()){
            if(dq){
                if(s[si]!=t[ti]){
                    ++stat;
                    if(stat>=2)break;
                    while(s[si]!='"')++si;
                    while(t[ti]!='"')++ti;
                    dq=false;
                }
                if(s[si]=='"')dq=false;
            }
            else{
                if(s[si]!=t[ti]){
                    stat=2;
                    break;
                }
                else if(s[si]=='"')dq=true;
            }
            ++si;++ti;
        }
        if(si>=s.size()){
            if(stat==0||stat==1){
                if(ti<t.size())stat=2;
            }
        }
        else if(ti>=t.size()){
            if(stat==0||stat==1){
                if(si<s.size())stat=2;
            }
        }
        end:;
        if(stat==0&&s.size()!=t.size())stat=2;
        if(s==t)stat=0;
        switch(stat){
            case 0:
                cout<<"IDENTICAL"<<endl;
                break;
            case 1:
                cout<<"CLOSE"<<endl;
                break;
            default:
                cout<<"DIFFERENT"<<endl;
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define repf(i,s,e)  for(int i=s;i<e;i++)
#define repb(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set


void solve(){
	int n;
	cin>>n;

	string s;
	set<string> S;
	repf(i,0,n){
		cin>>s;
		S.insert(s);
	}

	cout<<S.size()<<endl;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	if(fopen("input.txt", "r")){
	    freopen("input.txt", "r", stdin),
	    freopen("output.txt", "w", stdout);
	}
	
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int a,b,c;

void input(){
    cin >> a >> b >> c;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    if(a+b>=c){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool dp[21][2005];
int A[21];
int n;
bool solve(int i,int m){
	if(dp[i][m])	return true;
	if(m==0)	dp[i][m]=true;
	else if(i>=n+1)	dp[i][m]=false;
	else if(solve(i+1,m))	dp[i][m]=true;
	else if(solve(i+1,m-A[i]))	dp[i][m]=true;
	else dp[i][m]=false;
	return dp[i][m];
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>A[i];
	int q;
	cin>>q;
	while(q--){
		int m;
		cin>>m;
		if(solve(1,m))	cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
	
} 


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

int main() {
  int n, k;
  cin >> n >> k;
  int x[n];
  for ( int i = 0; i < n ; i++ ) {
    cin >> x[i];
  }

  int mn = 1e9;
  for ( int l = 0; l+k-1 < n; l++ ) {
    int r = l+k-1;
    int tmp = min(abs(x[l])+abs(x[r]-x[l]), abs(x[r])+abs(x[r]-x[l]));
    if ( tmp < mn ) { mn = tmp; }
  }

  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>

#define Flash ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define F first
#define S second
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define sz size()
#define mp make_pair
#define y1 asdf
#define rc(x) return cout << x, 0

const long long MXN = 2e3 + 1;
const long long MNN = 1e5 + 1;
const long long MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const long long OO = 1e9 + 500;

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, cnt = 1, a[100], sum;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        if(a[i] == a[i - 1]) cnt ++;
        else{
            sum += cnt / 2;
            cnt = 1;
        }
    }
    sum += cnt / 2;
    cout << sum;
    EX;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k,x;
  cin>>k>>x;
  for(int i=x-k+1;i<x+k;i++) cout<<i<<" ";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        
        int prizeX = 0;
        int prizeY = 0;
        int bonus = 0;
        if (X == 1) {
            prizeX += 300000;
            
        } else if (X == 2) {
            prizeX += 200000;
        } else if (X == 3) {
            prizeX += 100000;
        }
        if (Y == 1) {
            prizeY += 300000;
        } else if (Y == 2) {
            prizeY += 200000;
        } else if (Y == 3) {
            prizeY += 100000;
        }
        if (X == 1 && Y == 1) {
            bonus += 400000;
        }
        System.out.println(prizeX + prizeY + bonus);
    }
}

Measured memory_bytes: 24020
#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


int search(int l, int r, ll x, const ll* M) {
    // [l, r)
    if (r - l <= 1) return l;

    int mid = l + (r - l) / 2;

    if (M[mid] == x) {
        return mid;
    }else if (M[mid] > x) {
        return search(l, mid, x, M);
    } else {
        return search(mid, r, x, M);
    }
}


ll get_ans(ll x, ll s, ll t) {
    return min(abs(x-s) + abs(s-t), abs(x-t) + abs(t-s));
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int A, B, Q;
    cin >> A >> B >> Q;

    ll s[A+1], t[B+1];
    REP(i, A) {
        cin >> s[i];
    }
    s[A] = INF;

    REP(i, B) {
        cin >> t[i];
    }
    t[B] = INF;


    cout << fixed << setprecision(20);

    REP(i, Q) {
        ll x;
        cin >> x;

        int si = search(0, A, x, s);

        int ti = search(0, B, x, t);

        ll sl = s[si];
        ll sr = s[si+1];
        ll tl = t[ti];
        ll tr = t[ti+1];

        // sl tl
        ll ans = get_ans(x, sl, tl);

        // sr tl
        ans = min(ans, get_ans(x, sr, tl));

        // sl tr
        ans = min(ans, get_ans(x, sl, tr));

        // sr tr
        ans = min(ans, get_ans(x, sr, tr));

        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
a, b, c = io.read("*n", "*n", "*n")
r = 0
if a ~= b and b ~= c and c ~= a then
	r = 3
elseif a == b and c ~= a then
	r = 2
elseif b == c and a ~= b then
	r = 2
elseif c == a and b ~= c then
	r = 2
else
	r = 1
end
print(r)


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;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

int x, a;

int main(){
    cin >> x >> a;
    cout << (x < a ? 0 : 10);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np

a, b, c = map(int, input().split())
k = int(input())
t = -1
for i in range(k):
    if b > a:
        t = k-i
        break
    else:
        b *= 2
if t != -1:
    for j in range(t):
        if c >b:
            break
        else:
            c*= 2
            pass
if c > b:
    print("Yes")

else:
    print("No")


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

int main() {
     long L, R;
     cin >> L >> R;
     long answer = L*R;
     if (R - L + 1 >=2019) {
          cout << 0 << endl;
          return 0;
     }
     if (!(L*R < 2019)) {
          for (long i = L; i < R; i++) {
               for (long j = L+1; j <= R; j++) {
                    long mod = (i * j) % 2019;
                    if (answer > mod) {
                         answer = mod;
                    }
               }
          }
     }
     cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a;
    Cout((a-30)/2);
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a;
    cin >> a;
    map<char, int> mp;
    REP(i, a.size()) mp[a[i]]++;

    LL ans = 1;
    REP(i, a.size()){
        //cout << a.size() - i - 1 << " " <<  mp[a[i]] - 1 << endl;
        ans += a.size() - i - 1 - (mp[a[i]] - 1);
        mp[a[i]]--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(), b = scan.nextInt();
		if(b > a) {
			int c = a;
			a = b;
			b = c;
		}


		while(a % b != 0) {
			int c = a;
			a = b;
			b = c % b;
		}
		System.out.println(b);

	}

}



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

int main(){
  int a,b,k,cnt=0;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout << "OK" << endl;
      break;
    }
    else{
      cnt++;
    }
  }
  if(cnt==(b-a+1)){
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) c.begin(),c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

//????????????
class Dice {
private:
	map<char, string> mp;
public:
	//string d = "UFRLBD";
	string d = "RENSWL";
	vector<int> v; //UFRLBD:123456
	Dice() {
		init();
		v.resize(6);
	};
	Dice(vector<int> v) :v(v) {
		init();
	};
	void init(){
		mp[d[0]] = "2354";
		mp[d[1]] = "1463";
		mp[d[2]] = "1265";
		mp[d[3]] = "1562";
		mp[d[4]] = "1364";
		mp[d[5]] = "2453";
	}
	void input() { rep(i, 0, 6) { cin >> v[i]; } }
	void roll(char c) { roll(mp[c]); }
	void roll(string s) {
		int tmp = v[s[0] - '1'];
		rep(i, 1, s.size())v[s[i - 1] - '1'] = v[s[i] - '1'];
		v[s[s.size() - 1] - '1'] = tmp;
	}
	bool operator==(const Dice &D)const { return v == D.v; }
};

signed main() {
	int n; cin >> n;
	vector<Dice> D(n); rep(i, 0, n) { D[i].input(); }
	rep(i, 0, n) {
		rep(j, i + 1, n) {
			rep(k, 0, 100) {
				if (D[i] == D[j]) {
					cout << "No" << endl;
					return 0;
				}
				D[j].roll( D[j].d[rand() % 6] );
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3288
#include <iostream>

int main()
{
	int n, x;
	std::cin >> n;

	for(int i=1;i<=n;i++){
		if (i % 3 == 0) {
			std::cout << " " << i;
		}
		else {
			x = i;
			while (x > 0) {
				if (x % 10 == 3) {
					std::cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	std::cout << std::endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
const lli pINF=100000000000000000;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
const int INF = 0x3f3f3f3f ;
#define PII pair<int,int>
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
#define MAX 55556
vi primes;
bool isprime[MAX];
vi v;

int main() 
{
    memset(isprime,true,sizeof isprime);
    isprime[0]=isprime[1]=false;
    
    for(int i=2;i*i<MAX;i++){
        if(isprime[i]){
            for(int j=i+i;j<MAX;j+=i)
                isprime[j]=false;
        }
    }
    
    for(int i=2;i<MAX;i++)
        if(isprime[i]) primes.pb(i);
        
    for(int i:primes){
        if(i%5==1){
            v.pb(i);
        }
        if(v.size()==55) break;
    }
    
    int n;
    si(n);
    
    for(int i=0;i<n;i++) cout<<v[i]<<" ";
    
    cout<<endl;
    return 0;
}

Measured memory_bytes: 384
a = [int(i) for i in input().split()] 

if (a[0] == a[1]):
  if (a[1] == a[2]):
    sum = 1
  else:
    sum = 2
elif (a[0] == a[2]):
  sum = 2
elif (a[1] == a[2]):
  sum = 2
else:  
  sum = 3

print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;
const ll kMod = 1000000007;

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

  // init
  ll ans = N;
  ll x = 1;  // open
  ll y = 0;  // closed

  for (int i = 1; i < 2 * N; ++i) {
    int cond = S[i] == 'B' ? 1 : 0;
    if (x % 2 == cond) {
      if (x == 0) {
	cout << 0 << endl;
	return 0;
      }
      ans *= x;
      ans %= kMod;
      --x;
      ++y;
    } else {
      if (N - x - y <= 0) {
	cout << 0 << endl;
	return 0;
      }
      ans *= (N - x - y);
      ans %= kMod;
      ++x;
    }
    
  }

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


Measured memory_bytes: 640
def d_menagerie(N, S):
    s = S + S[0:2]  # 円環状に並んでいることを考慮
    for ans in ['SS', 'SW', 'WS', 'WW']:  # Sは羊、Wは狼。1番と2番の種類を仮定する
        for i in range(1, N + 1):
            if (ans[-1] == 'S' and s[i] == 'o') or (ans[-1] == 'W' and s[i] == 'x'):
                # この場合、今注目している動物の両隣は同じ種類。
                # よって、今注目している動物の右隣を左隣と同じにする。
                ans += ans[-2]
            else:
                # 両隣は違う種類。右隣を左隣と逆にする。
                ans += ('S' if ans[-2] == 'W' else 'W')
        if ans[:2] == ans[N:]:
            # sの最初の2文字(仮定)と最後の2文字が一致した文字列のみ受理する。
            # 1つ見つければ良いので、すぐにbreakする
            ans = ans[:N]
            break
    else:  # どの割り当て方も矛盾した
        ans = '-1'
    return ans

N = int(input())
S = input().strip()
print(d_menagerie(N, S))

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
	return 0;
}

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

//処理部分
//inital diameter=moti[0]
//if diameter!=moti[i]
//   diameter=moti[i]
//   dan+1
//
int main(){
    int N,dan=1,diameter=0;
    cin>>N;
    vector<int> moti(N);

    for(int i=0; N>i;i++){
        cin>>moti.at(i);
    }

    sort(moti.begin(),moti.end());
    reverse(moti.begin(),moti.end());

    diameter=moti.at(0);
    for(int i=0;i<N;i++){
        if (diameter!=moti.at(i)){
            diameter=moti.at(i);
            dan++;
        }
    }

    cout<<dan<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60];
           signed main(){
        
           	string s;
           	cin>>s;
           	int l=s.length();
           	
           	for(int i=(l-2)/2;i>=0;i--){
           		if(s.substr(0,i)==s.substr(i,i)){
           		cout<<i*2<<endl;
           			return 0;
           		}
           	
           	}
           	
           	return 0;
           	
           	
           }
             

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int[][][] count = new int[4][3][10];

    	int n = scan.nextInt();
    	int[] b = new int[n];
    	int[] f = new int[n];
    	int[] r = new int[n];
    	int[] v = new int[n];
    	
    	for(int i = 0; i < n; i++){
    		b[i] = scan.nextInt();
    		f[i] = scan.nextInt();
    		r[i] = scan.nextInt();
    		v[i] = scan.nextInt();
    	}
    	
    	for(int i = 0; i < n; i++){
    		count[b[i] - 1][f[i] - 1][r[i] - 1] += v[i];
    	}
    	
    	for(int k = 0; k < 4; k++){
    		for(int j = 0; j < 3; j++){
    			for(int i = 0; i < 10; i++){
    				System.out.print(" " + count[k][j][i]);
    	    	}	
    			System.out.println("");
        	}
    		if(k != 3)System.out.println("####################");
    	}
    }
}

Measured memory_bytes: 29612
def main():
    from bisect import bisect_right
    s=input()
    t=input()
    ls=len(s)
    lt=len(t)

    dic={i:[] for i in set(t)}
    for i in range(ls):
        st=s[i]
        if st in dic:
            dic[st].append(i)  

    cnt=0
    idx=-1
    for i in range(lt):
        st=t[i]
        if dic[st]==[]:
            print(-1)
            exit()

        tmp_idx=bisect_right(dic[st],idx)

        if tmp_idx==len(dic[st]):
            cnt+=1
            idx=dic[st][0]
        
        else:
            idx=dic[st][tmp_idx]
    
    print(cnt*ls+idx+1)  
 
if __name__=='__main__':
    main()

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

int main(){ 
 int a,b;
 cin >> a >> b;
 int c = min(a,b);
 int d = max(a,b);
 int ans = 0;
 rep(i,d){
     ans = ans + c;
     ans *= 10; 
 }
 cout << ans/10 << endl;
}

Measured memory_bytes: 256
//$ node B.js < B.txt
function Main(input) {
  input = input.split('\n') // 1行目がinput[0], 2行目がinput[1], …に入る
  for(var i=0;i<input.length;i++){
    var tmp = input[i].split(' ')
    input[i] = []
    for(var ii=0;ii<tmp.length;ii++){
      input[i].push(tmp[ii])
    }
  }
  var ans = 0
  input = input[0][0] *1 

  for(var i=1;i<input+1;i++){
    var num = i +''
    if(num.length%2) {
      ans++
    }
  }
  console.log(ans)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();
        double e=a*1.0/d;
        int e1=a/d;
        if(e>e1){
            e1++;
        }
        double f=c*1.0/b;
        int f1=c/b;
        if(f>f1){
            f1++;
        }
       if(e1>=f1){
           System.out.println("Yes");
       }
        if(e1<f1){
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll n,k;
ll f[2002][2002],s[2005],ans;
int main(){
	scanf("%lld%lld",&n,&k);
	f[0][n+1]=1;	
	for(int i=1;i<=k;i++)
		for(int j=n+1;j;j--)
			s[j]=(s[j+1]+f[i-1][j])%mod,f[i][j]=(j<=n-i+1)?s[j]:0;
	ans=(f[k][1]-f[k-1][1]+mod)%mod;
	for(int i=1;i<n-k;i++)ans=(ans+ans)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31488
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int Maxn=8;
bool flag[Maxn][Maxn];
bool a[Maxn],b[Maxn];
int n,m,k,ans;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;++i)
	{
		char s[Maxn];
		scanf("%s",s+1);
		for(int j=1;j<=m;++j)
		if(s[j]=='#')flag[i][j]=1;
	}
	for(int x=0;x<(1<<n);++x)
	for(int y=0;y<(1<<m);++y)
	{
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		for(int i=0;i<n;++i)
		if((x>>i) & 1)a[i+1]=1;
		for(int i=0;i<m;++i)
		if((y>>i) & 1)b[i+1]=1;
		int cnt=0;
		for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		if(flag[i][j] && !a[i] && !b[j])++cnt;
		if(cnt==k)++ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3808
mass = input()
mass = list(mass) #入力した文字列をリストで管理する
mass = [int(n) for n in mass]
count = 0

for i in range(0, len(mass)):
        if(i == len(mass) - 1):
            break
        if(mass[i] == mass[i+1]): #同じ数字が続くか判定する
            mass[i+1] = (mass[i+1] + 1) % 2 #0なら1に、1なら0に数字を入れ替える
            count += 1

print(count)


Measured memory_bytes: 4652
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
struct node
{
  int data;
  struct node*lchild;
  struct node*rchild;
};
typedef struct node;
typedef node *tree;
tree root;

void in(tree &bt,int n)
{
  if(bt)
  {
    if(n<bt->data)
      in(bt->lchild,n);
    else if(n>bt->data)
      in(bt->rchild,n);
  }
  else
  {
    bt=new node;
    bt->data=n;
    bt->lchild=NULL;
    bt->rchild=NULL;
  }
}
void out1(tree bt)
{
  if(bt)
  {
    out1(bt->lchild);
    cout<<" "<<bt->data;
    out1(bt->rchild);
  }
}
void out2(tree bt)
{
  if(bt)
  {
    cout<<" "<<bt->data;
    out2(bt->lchild);
    out2(bt->rchild);
  }
}
int main()
{
  root=NULL;
  int m;
  cin>>m;
  for(int i=1;i<=m;i++)
  {
    string zl;
    cin>>zl;
    if(zl=="insert")
    {
      int num;
      cin>>num;
      in(root,num);
    }
    else if(zl=="print")
    {
      out1(root);
      cout<<endl;
      out2(root);
      cout<<endl;
    }
  }
  return 0;
}

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

int main(){
    char x, y;
    cin >> x >> y;
    if (x < y) cout << "<" << endl;
    else if (x == y) cout << "=" << endl;
    else cout << ">" << endl;
    return 0;
}

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int w[ N ] , v[ N ];
LL dp[ N ];

int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        int n , cap;
        cin >> n >> cap;
        for( int i = 1; i <= n; i++ ) cin >> w[i] >> v[i];
        for( int i = 1; i <= n; i++ ) {
                for( int j = 100000; j - w[i] >= 0; j-- ) {
                            dp[j] = max( dp[j] , dp[ j - w[i] ] + v[i] );
                }
        }
        cout << dp[cap]<< endl;
        return 0;
}














Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
  long long k,n,temp,t;
    cin>>k>>n;
   long long a[n],m[n-1];
        for (long long i=0;i<n;i++)
        {
            cin>>a[i];
        }

      t=(a[0]+(k-a[n-1]));

     for (long long j=0;j<n-1;j++)
        {
            m[j]=abs(k-(abs(a[j]-a[j+1])));
        }
     long long max=m[0];
     for (long long i=0;i<n-1;i++)
        {
            if(m[i]<max)
                max=m[i];
        }

        if((k-t)<=max)
        cout<<k-t<<"\n";
        else if((k-t)>=max)
        cout<<max<<"\n";
        return 0;
}

Measured memory_bytes: 3328
N = int(input())
S = [['a',1]]
import copy

for i in range(N-1):
    tmp = []
    for j in S:
        s = j[0]
        n = j[1]
        for k in range(n+1):
            tmp.append([''.join([s,chr(k+97)]), max(n,k+1)])
    S = copy.deepcopy(tmp)
for i in S:
    s = i[0]
    print(s)

Measured memory_bytes: 130812
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Stream;
public class Main {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				PrintWriter pw = new PrintWriter(System.out);) {
			int[] AB = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			String[] S = br.readLine().split("-");
			if (S.length == AB.length && AB[0] - AB[1] == S[0].length() - S[1].length()) {
				pw.println("Yes");
			} else {
				pw.println("No");
			}
			pw.flush();
		} catch (Exception e) {
		}
	}
}

Measured memory_bytes: 29524
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const int inf=1e9;

int n;
char wcz[nax];
int tab[nax];
vi graf[nax];

int wyn=inf;

vi dfs(int v, int oj)
{
	int ile=0;
	int suma=0;
	int mini=0;
	if (tab[v])
		ile++;
	for (int i : graf[v])
	{
		if (i==oj)
			continue;
		vi wez=dfs(i, v);
		ile+=wez[0];
		int a=mini;
		int b=wez[2];
		
		int sa=suma;
		int sb=wez[1];
		
		suma=sa+sb;
		if (a>=sb)
		{
			mini=a-sb;
			continue;
		}
		if (b>=sa)
		{
			mini=b-sa;
			continue;
		}
		mini=(suma&1);
	}
	return {ile, suma+ile, mini+ile};
}

int main()
{
	scanf("%d", &n);
	scanf("%s", wcz+1);
	for (int i=1; i<n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		graf[a].push_back(b);
		graf[b].push_back(a);
	}
	for (int i=1; i<=n; i++)
		tab[i]=wcz[i]-'0';
	for (int i=1; i<=n; i++)
	{
		vector <pii> wek;
		int s=0;
		for (int j : graf[i])
		{
			vi wez=dfs(j, i);
			wek.push_back({wez[1], wez[2]});
			s+=wez[1];
		}
		sort(wek.begin(), wek.end());
		if (s&1)
			continue;
		if (wek.back().first*2<=s)
		{
			wyn=min(wyn, s/2);
			continue;
		}
		int x=wek.back().first-s/2;
		debug() << imie(s) << imie(x) << wek;
		if (wek.back().second<=wek.back().first-2*x)
			wyn=min(wyn, s/2);
		
		//~ vi wek;
		//~ for (int j : graf[i])
			//~ wek.push_back(dfs(j, i, 1));
		//~ sort(wek.begin(), wek.end());
		//~ int s=0;
		//~ for (int j : wek)
			//~ s+=j;
		//~ if (2*wek.back()>s || (s&1))
			//~ continue;
		//~ wyn=min(wyn, s/2);
	}
	
	
	if (wyn==inf)
		wyn=-1;
	printf("%d\n", wyn);
	return 0;
}


Measured memory_bytes: 25088
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main() {
	
	string s;
	cin >> s;

	int n = s.length();

	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'p') {
			--ans;
		}
	}

	ans += n / 2;
	cout << ans << endl;


}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int result = 0;
        for (int i = 1; i < n + 1; i++) {
            result += i;
        }
        System.out.println(result);
    }

}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> H(N), good(N);
    for(int i=0;i<N;i++){
        cin >> H.at(i);
        good.at(i) = 1;
    }

    for(int i=0;i<M;i++){
        int h_a, h_b;
        cin >> h_a >> h_b;

        if(H.at(h_a-1)==H.at(h_b-1)){
            good.at(h_a-1) = 0;
            good.at(h_b-1) = 0;
        }
        else if(H.at(h_a-1)>H.at(h_b-1)){
            good.at(h_b-1) = 0;
        }
        else{
            good.at(h_a-1) = 0;
        }
    }

    int cnt;
    for(int i=0;i<N;i++){
        if(good.at(i)==1)cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256