akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define Maxn 10000
using namespace std;
int main()
{
    ll sum=1000000000000+10;
    ll n;
    cin>>n;
    for(ll i=1; i*i<=n; i++)
    {
        if(n%i==0)
        {
            ll t=n/i+i-2;
            if(sum>t)
                {
                    sum=t;
                }
        }
    }
        cout<<sum<<endl;

}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') counter++;
    if (s[1] == '1') counter++;
    if (s[2] == '1') counter++;
    cout << counter << endl;

    return 0;
}

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

int main()
{
    int n, i, count = 0;
    cin>>n;

    for(i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            if(i * j == n)
                {
                    count++;
                    break;
                }
        }
    }
    if(count >= 1)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
cnt=0
x=[]
i=0
b__=b.copy()
rev=0
while(b__):
     b_=b__.pop()
     while(1):
          try:
               c_=c.pop()
          except:
               rev+=cnt
               x.append(rev)
               cnt=0
               break
          if c_>b_:
               cnt+=1
          else:
               rev+=cnt
               x.append(rev)
               cnt=0
               c.append(c_)
               break
cnt=0
i=n-1
rev=0
ans=0
while(a):
     a_=a.pop()
     while(1):
          try:
               b_=b.pop()
          except:
               rev+=cnt
               ans+=rev
               cnt=0
               break
          if b_>a_:
               cnt+=x.pop(0)
          else:
               rev+=cnt
               ans+=rev
               cnt=0
               b.append(b_)
               break
print(ans)

Measured memory_bytes: 24180
N,M,Q = map(int,input().split())
num = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    l,r = list(map(int,input().split()))
    l -= 1
    r -= 1
    num[l][r] += 1
for i in range(N):
    for j in range(N-1):
        num[i][j+1] += num[i][j]
for i in range(N-1,0,-1):
    for j in range(N):
        num[i-1][j] += num[i][j]
for i in range(Q):
    p,q = map(int,input().split())
    print(num[p-1][q-1])


Measured memory_bytes: 9588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int X;
  cin>>X;
  
  if(X<100){
    co(0);
    return 0;
  }
  
  if((X%100)>(X/100)*5){
    co(0);
    return 0;
  }
  
  co(1);
  
  
  
}

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

constexpr long mod = 998244353;
vector<long> fact, inv;

long power(long n, long k) {
  if (k == 0) return 1;
  long res = power(n * n % mod, k / 2);
  if (k % 2) res = res * n % mod;
  return res;
}

void init(int n) {
  fact.push_back(1);
  inv.push_back(1);
  for (int i = 0; i < n; i++) {
    fact.push_back(fact.at(i) * (i + 1) % mod);
    inv.push_back(power(fact.at(i + 1), mod - 2));
  }
}

long ncr(long n, long r) {
  return fact.at(n) * inv.at(r) % mod * inv.at(n - r) % mod;
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  init(N);
  long ans = 0;
  for (int i = 0; i <= K; i++) {
    (ans += M * power(M - 1, N - i - 1) % mod * ncr(N - 1, i) % mod) %= mod;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6560
#include<iostream>
#include<random>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


#define NUM_CNT 100
#define Q_CNT 100
#define IN_BIT 1000
#define OUT_BIT 30


/*
#define NUM_CNT 2
#define Q_CNT 2
#define IN_BIT 3
#define OUT_BIT 10
*/

vector<int> group;
void init_group(){
    mt19937 mt(12345);
    for(int i = 0;i < IN_BIT;i++)group.push_back(mt() & ((1<<OUT_BIT)-1));
}

Int into_Int(string str){
    Int ans = 0;
    for(int i = 0;i < str.size();i++){
        if(str[i] == '1')ans ^= group[i];
    }
    return ans;
}

void alice(){
    string a;
    for(int i = 0;i < NUM_CNT;i++){
        cin >> a;
        Int ans  = into_Int(a);
        for(int i = 0;i < OUT_BIT;i++){
            cout << ((ans >> i) % 2);
        }
    }
    cout << endl;    
}

void bob(){
    alice();
}

Int a[NUM_CNT], b[NUM_CNT];
void charlie(){
    string X, c;
    cin >> X;
    for(int i = 0;i < NUM_CNT * OUT_BIT;i++){
        a[i/OUT_BIT] += (X[i] - '0') << (i %OUT_BIT);
    }
    cin >> X;
    for(int i = 0;i < NUM_CNT * OUT_BIT;i++){
        b[i/OUT_BIT] += (X[i] - '0') << (i %OUT_BIT);
    }
    int ansi = 1, ansj = 1;
    for(int i = 0;i < Q_CNT;i++){        
        cin >> c;
        Int ans = into_Int(c);
        for(int i = 0;i < NUM_CNT;i++){
            for(int j = 0;j < NUM_CNT;j++){
                if ((a[i]^b[j] )== ans){
                    ansi = i+1;
                    ansj = j+1;
                }

            }
        }
        cout << ansi << " " << ansj << endl;
    }
}

int main(){
    init_group();
    string name;
    cin >> name;
    if(name == "Alice")alice();
    if(name == "Bob")bob();
    if(name == "Charlie")charlie();
    return 0;
}


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

template <typename T>
class node {
public:
	node<T> *l, *r;
	T val;
	node() {}
	node(T val_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) : l(l_), r(r_), val(val_) {}
	void init(T val_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) {
		val = val_;
		l = l_;
		r = r_;
	}
};

template <typename T>
class DynamicSegmentTree {
	using func_t = function<T(T, T)>;
	const ll n;
	const T id;
	func_t merge;
	node<T> *root;
	vector<node<T>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node() {
		pool[it].init(id);
		return &pool[it++];
	}
	T sub(ll l, ll r, node<T>* n, ll lb, ll ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return n->val;
		return merge(n->l != nullptr ? sub(l, r, n->l, lb, (lb + ub) / 2) : id, n->r != nullptr ? sub(l, r, n->r, (lb + ub) / 2, ub) : id);
	}
	void suc(ll v, node<T>* n, ll lb, ll ub, T val) {
		if (ub - lb <= 1) {
			n->val = val;
			return;
		}
		ll c = (lb + ub) / 2;
		if (v < c) {
			if (n->l == nullptr) n->l = new_node();
			suc(v, n->l, lb, c, val);
		}
		else {
			if (n->r == nullptr) n->r = new_node();
			suc(v, n->r, c, ub, val);
		}
		n->val = merge(n->l != nullptr ? n->l->val : id, n->r != nullptr ? n->r->val : id);
	}
public:
	DynamicSegmentTree(ll n_, int max_, T id_, func_t merge_) :
		n(size(n_)), id(id_), merge(merge_), pool(max_)
	{
		it = 0;
		root = new_node();
	}
	void Update(ll p, T val) {
		suc(p, root, 0, n, val);
	}
	T Find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, q, com, x, y;
	cin >> n >> q;
	DynamicSegmentTree<int> dst(1000000000000ll, 10000000, 0x7fffffff, [](int l, int r) { return min(l, r); });
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", dst.Find(x, y));
		}
		else {
			dst.Update(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 5860
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CantWaitForHoliday | diff CantWaitForHoliday.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CantWaitForHoliday.cpp && ./a.out

/*
 
 11/24/2019
 
 4:00-
 
 */

string S;

vector<string> ds={"SUN","MON","TUE","WED","THU","FRI","SAT","SUN","MON","TUE","WED","THU","FRI","SAT"};
void solve() {
  int a=-1,b=-1;
  REP(i,SZ(ds)) {
    if(a==-1&&ds[i]==S) a=i;
    else if(a!=-1&&ds[i]=="SUN") b=i;
  }
  cout<<(b-a)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

struct node{
    int d, l, r;
    node(int d) : d(d) {
        l = r = -1;
    }
};

vector<node> trie;

void add(string s, int id){
    while(SZ(s) > trie[id].d){
        if(s[trie[id].d] == '0'){
            if(trie[id].l == -1){
                trie[id].l = SZ(trie);
                trie.push_back(node(trie[id].d + 1));
            }
            id = trie[id].l;
        }else{
            if(trie[id].r == -1){
                trie[id].r = SZ(trie);
                trie.push_back(node(trie[id].d + 1));
            }
            id = trie[id].r;
        }
    }
}

int grundy(int h){
    if(h == 0){
        return 0;
    }

    int x = 1;
    while(h % (x * 2) == 0){
        x *= 2;
    }
    return x;
}

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

    int n, l;
    cin >> n >> l;

    trie.push_back(node(0));
    rep(i, n){
        string s;
        cin >> s;
        add(s, 0);
    }

    int sum = 0;
    stack<int> st;
    st.push(0);
    while(not st.empty()){
        int id = st.top();
        st.pop();

        if(trie[id].l == -1 && trie[id].r == -1){
            continue;
        }

        if(trie[id].l != -1){
            st.push(trie[id].l);
        }else{
            int h = l - trie[id].d;
            sum ^= grundy(h);
        }
        if(trie[id].r != -1){
            st.push(trie[id].r);
        }else{
            int h = l - trie[id].d;
            sum ^= grundy(h);
        }
    }

    cout << (sum == 0 ? "Bob" : "Alice") << endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    //入力
    int a,b; cin >> a >> b;

    //処理
    if((a+b)%2==0) cout << (a+b)/2 << '\n';
    else cout << "IMPOSSIBLE" << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_N = (int)3e5 + 777;

struct Cell
{
	ll val;
	int r, c;

	bool operator<(const Cell& other) const
	{
		return val > other.val;
	}
};

int n, h, w;
Cell cells[MAX_N];

int dsu[MAX_N], cntE[MAX_N], cntV[MAX_N];

inline int get_parent(int v)
{
	for(; dsu[v] != v; v = dsu[v]);

	return v;
}

inline int connect(int v, int u)
{
	v = get_parent(v);
	u = get_parent(u);

	if(v == u)
	{
		if(cntE[v] + 1 <= cntV[v])
		{
			++cntE[v];
			return 1;
		}

		return 0;
	}
	else
	{
		if(cntE[v] + cntE[u] + 1 <= cntV[v] + cntV[u])
		{
			if(cntV[v] > cntV[u]) // make sure cntV[v] <= cntV[u]
				swap(v, u);

			dsu[v] = u;
			cntV[u] += cntV[v];
			cntE[u] += cntE[v] + 1;

			return 1;
		}

		return 0;
	}
}

void solve()
{
	cin >> n >> h >> w;

	for(int i = 0; i < n; ++i)
		cin >> cells[i].r >> cells[i].c >> cells[i].val;

	sort(cells, cells + n);

	for(int v = 0; v < w + h; ++v)
	{
		dsu[v] = v;
		cntE[v] = 0;
		cntV[v] = 1;
	}

	ll answ = 0;

	for(int i = 0; i < n; ++i)
	{
		int v = cells[i].r;
		int u = h + cells[i].c;

		answ += cells[i].val * connect(v, u);
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 5888
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
points = []
for i in range(N):
    a = int(input())
    points.append([a,True])
for i in range(N):
    b = int(input())
    points.append([b,False])
points.sort()

ans = 1
an = bn = 0
for x,c in points:
    if c:
        if bn > 0:
            ans = (ans*bn)%mod
            bn -= 1
        else:
            an += 1
    else:
        if an > 0:
            ans = (ans*an)%mod
            an -= 1
        else:
            bn += 1

print(ans%mod)


Measured memory_bytes: 31940
#include <stdio.h>
#include <stdlib.h>
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int n, m;
    long a[100010];
    long long sum = 0;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        scanf("%ld", &a[i]);
    }
    qsort(a, n, sizeof(a[0]), dis);
    for (int i = 0; i < m;)
    {
        a[0] >>= 1;
        i++;
        long temp = a[0];
        int j = 1;
        for (; a[j] > temp && i < m; j++)
        {
            a[j] >>= 1;
            i++;
        }
        qsort(a, n, sizeof(a[0]), dis);
    }
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
    }
    printf("%lld", sum);
    return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX/10;


int main(void){
  ll T; cin >> T;
  int N; cin >> N;
  vector<ll> s(N), t(N);
  for(int i = 0; i < N; i++) cin >> s[i] >> t[i];

  vector<ll> sum(N+1, 0);
  for(int i = 0; i < N; i++){
    sum[i+1] = sum[i] + t[i] - s[i];
  }
  

  ll ans = 0;
  for(int i = 0; i < N; i++){
    ll l = i, r = N;
    while(l+1 < r){
      ll mid = (l+r)/2;
      if(s[mid]-s[i] >= T){
	r = mid;
      }else{
	l = mid;
      }
    }
    
    ll ansp = sum[l] - sum[i] + min(T-(s[l] - s[i]), t[l] - s[l]);
    ans = max(ans, ansp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int h,w,a,b;

int main(){
	cin>>h>>w>>a>>b;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++) cout<<(i<b^j<a?'0':'1');
		cout<<endl;
	}
}

Measured memory_bytes: 1280
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll now = 100;
	ll x; cin >> x;
	int cnt = 0;
	while (now < x)
	{
		now *= 1.01;
		++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
     String[] nyu=sc.nextLine().split(" ");

//     String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu);



//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



if(C>=A && C<=B){
//double res=Math.ceil((AB)/2);

System.out.println("Yes");
//}else if((C-B)<A){
//System.out.println("safe");

}else{
System.out.println("No");

}




	}
}

Measured memory_bytes: 21844
import java.util.Scanner;
 
public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		
		int D[][] = new int[n][n];
		int C[][] = new int[c][c];

		for(int i=0;i<c;i++){
			for(int j=0;j<c;j++){
				C[i][j] = sc.nextInt();
			}
		}

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				D[i][j] = sc.nextInt();
			}
		}

		int J[][] = new int[3][c];

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				int k = (i+j)%3;
				for(int l=0;l<c;l++){
					J[k][l] += C[D[i][j]-1][l];
				}
			}
		}

		int min = Integer.MAX_VALUE;

		for(int i=0;i<c;i++){
			for(int j=0;j<c;j++){
				for(int k=0;k<c;k++){
					if(i==j || j==k || k==i) continue;
					min = Math.min(min,J[0][i] + J[1][j] + J[2][k]);
				}
			}
		}

		System.out.println(min);
	}
 
}

Measured memory_bytes: 90680
k=input()
a=int(k[0])
b=int(k[1])
c=int(k[2])
d=int(k[3])
op1=["+","-"]
op2=["+","-"]
op3=["+","-"]
flag=0
for i in range(2):
  for j in range(2):
    for l in range(2):
      siki=k[0]+op1[i]+k[1]+op2[j]+k[2]+op3[l]+k[3]
      if (eval(siki)==7):
        print(siki+"=7")
        flag=1
      if (flag==1):
        break
    if (flag==1):
      break
  if (flag==1):
    break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/
using namespace std;

const int N = 100005, MOD = 1e9 + 7;




main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    if (n == 2){
        cout << 1 << endl;
        return 0;
    }
    int ans=0;
    for (int x = 2; x * x <= n && x < n; x++){
        int m = n;
        while (m % x == 0)
            m /= x;
        if (m % x == 1)
            ans++;
        if ((n-1)%x == 0)
            ans--;
    }
    n--;
    for (int x = 1; x * x <= n; x++){
        if (n % x == 0){
            ans++;
        if (n > x*x)
            ans++;}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
(N,M),*ps = [s.split() for s in open(0)]

ps = [(int(p),s=='WA') for p,s in ps]

from collections import Counter
cnt = Counter()
acs = set()

for p,s in ps:
    if p not in acs:
        if s:
            cnt[p] += 1
        else:
            acs.add(p)
a = len(acs)
b = sum(cnt[ac] for ac in acs)
print(a,b)

Measured memory_bytes: 48496
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
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(){
  ll n ; cin>> n ;
  ll k = n%1000 ;
  if(k!=0) k= 1000-k ;
  cout<<k<<endl ;
 return 0 ; 
}



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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < ll > vl;

const int MAXN = 1e5 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;

int dp[MAXN], h[MAXN];

int main() {
    int N;

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

    dp[1] = abs(h[1] - h[0]);
    dp[2] = abs(h[2] - h[0]);

    for(int i = 3; i < N; i++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));

    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	vector<int> ss(n); for (auto& s : ss) cin >> s;

	int sum = 0;
	FOR_LT(i, 0, n) {
		sum += ss[i];
	}

	int k = 0;
	FOR_LT(i, 0, n) {
		if (sum <= 4 * m * ss[i]) k++;
	}

	if (m <= k) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":	" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

int main() {
  ll n,m; cin>>n>>m;

  bool flg = false;
  for (int i=1; i<=m; i++) {
    ll l = i;
    ll r = n-i;
    if (n%2==0 && !flg && r-l <= n/2) flg = true;
    if (flg) r--;
    printf("%lld %lld\n", l, r);
  }

  return 0;
}


Measured memory_bytes: 3780
n,m = map(int,input().split())
li = list(map(int,input().split()))
li2 = []
li.sort()
for i in range(m-1):
    li2.append(abs(li[i]-li[i+1]))
li2.sort()

if n >= m:
    print(0)
else:
    print(sum(li2[0:m-n]))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    
        ll n,m,l,r,sum=0;
        vector<pair<ll,ll>> v;
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>l>>r;
            v.push_back({r,l});
        }
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++){
            sum+=v[i].second;
            if(sum>v[i].first){
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    
        
}


Measured memory_bytes: 6128
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const res = s.filter(e => e === 5).length === 2 && s.filter(e => e === 7).length === 1 ? 1 : 0

console.log(res ? 'YES' : 'NO')


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
	
	void run() {
		Scanner scan = new Scanner(System.in);
		char[] array1 = scan.next().toCharArray();
		char[] array2 = scan.next().toCharArray();
		outside : for(int i = 0; i < array1.length; i++) {
			if(array1[i] == array2[0]) {
				for(int j = 1; j < array2.length; j++) {
					int tmp = i+j >= array1.length ? i+j-array1.length : i+j;
					if(array2[j] != array1[tmp]) continue outside;
				}
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	int i=1;
  	while(true){
      int x;
      cin >> x;
      if(x==0)
      {cout << i; break;}
      i++;
    }
    return 0;
}

Measured memory_bytes: 3636
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr, tails, sort)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

isTriangle :: Int -> Int -> Int -> Bool
isTriangle a b c = a < b + c && b < c + a && c < a + b

naive = do
  n <- readLn :: IO Int
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ length [ (a,b,c) | a:xss <- tails xs, b:xsss <- tails xss, c <- xsss, isTriangle a b c ]

-- v は昇順にソートされているとする。
-- countGE a v は a 以上の要素の個数を数える。
countGE :: Int -> U.Vector Int -> Int
countGE !a = loop 0
  where
    loop !s !v | U.null v = s
               | U.length v == 1 = if a <= U.head v then
                                     s + 1
                                   else
                                     s
               | otherwise = let n = U.length v
                                 n2 = n `quot` 2
                             in if a <= v U.! n2 then
                                  loop (n - n2 + s) (U.take n2 v)
                                else
                                  loop s (U.drop n2 v)

main = do
  n <- readLn :: IO Int
  xs <- mergeSort . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let c = U.generate (2*10^3+1) $ \c_max -> countGE c_max xs
  print $ sum [ n - (j+1) - min (n - (j+1)) (c U.! c_max)
              | i <- [0..n-1]
              , let a = xs U.! i
              , j <- [i+1..n-1]
              , let b = xs U.! j
              , let c_max = a + b {- c < a + b, b - a < c, a - b < c -}
              ]

mergeSortBy :: (U.Unbox a) => (a -> a -> Ordering) -> U.Vector a -> U.Vector a
mergeSortBy !cmp !vec = doSort vec
  where
    doSort vec | U.length vec <= 1 = vec
               | otherwise = let (xs, ys) = U.splitAt (U.length vec `quot` 2) vec
                             in merge (doSort xs) (doSort ys)
    merge xs ys = U.create $ do
      let !n = U.length xs
          !m = U.length ys
      result <- UM.new (n + m)
      let loop !i !j
            | i == n = U.copy (UM.drop (i + j) result) (U.drop j ys)
            | j == m = U.copy (UM.drop (i + j) result) (U.drop i xs)
            | otherwise = let !x = xs U.! i
                              !y = ys U.! j
                          in case cmp x y of
                               LT -> do UM.write result (i + j) x
                                        loop (i + 1) j
                               EQ -> do UM.write result (i + j) x
                                        UM.write result (i + j + 1) y
                                        loop (i + 1) (j + 1)
                               GT -> do UM.write result (i + j) y
                                        loop i (j + 1)
      loop 0 0
      return result

mergeSort :: (U.Unbox a, Ord a) => U.Vector a -> U.Vector a
mergeSort = mergeSortBy compare


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353

template<int MAX>
struct Prime {
    vector<bool> is_prime;
    vector<int> primes, min_factor;
    Prime() : is_prime(MAX+1, true), min_factor(MAX+1, -1) {
        is_prime[0] = is_prime[1] = false;
        min_factor[0] = 0, min_factor[1] = 1;
        for (int i = 2; i <= MAX; i++) {
            if (!is_prime[i]) continue;
            primes.emplace_back(i);
            min_factor[i] = i;
            for (int j = i*2; j <= MAX; j += i) {
                is_prime[j] = false;
                if (min_factor[j] == -1) min_factor[j] = i;
            }
        }
    }

    vector<pair<int, int>> prime_factors(int n) {
        vector<pair<int, int>> ret;
        while (n != 1) {
            int p = min_factor[n], sz = 0;
            while (min_factor[n] == p) sz++, n /= p;
            ret.emplace_back(p, sz);
        }
        return ret;
    }

    vector<int> divisor(int n) {
        auto pf = prime_factors(n);
        vector<int> ret = {1};
        for (auto &f: pf) {
            int sz = ret.size(), k = 1;
            while (f.second--) {
                k *= f.first;
                for (int i = 0; i < sz; i++) {
                    ret.emplace_back(ret[i]*k);
                }
            }
        }
        return ret;
    }
};

template<int MAX>
struct ModInv {
    vector<long long> inv;
    ModInv() : inv(MAX+1) {
        for (int i = 1; i <= MAX; i++) {
            if (i == 1) inv[i] = 1;
            else {
                inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
                if (inv[i] < 0) inv[i] += mod;
            }
        }
    }
    const long long operator[](int i) const { return inv[i]; };
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    constexpr int M = 1000000;
    Prime<M> P; ModInv<M> inv;
    int n; cin >> n;
    vector<int> a(n);
    vector<long long> f(M+1, 0), w(M+1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (auto &x: P.divisor(a[i])) {
            f[x] += a[i];
        }
    }
    for (int i = 1; i <= M; i++) {
        w[i] = inv[i], f[i] %= mod;
        f[i] = f[i] * f[i] % mod;
    }
    for (auto &p: P.primes) {
        for (int k = M / p; k > 0; k--) {
            w[k*p] -= w[k];
            if (w[k*p] < 0) w[k*p] += mod;
        } 
    }
    long long ans = 0;
    for (int i = 0; i <= M; i++) ans += w[i] * f[i] % mod;
    for (int i = 0; i < n; i++) ans -= a[i];
    cout << (ans % mod + mod) * inv[2] % mod << "\n";
    return 0;
}

Measured memory_bytes: 28920
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  int sum = 0;
  rep(i, n) {
    cin >> s[i];
    sum += s[i];
  }
  if (sum % 10 != 0) {
    cout << sum << endl;
    return 0;
  }
  sort(all(s));
  rep(i, n) {
    if (s[i] % 10 != 0) {
      cout << sum - s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect

s = input()
t = input()

sset = set(s)
tset = set(t)

if not all(i in sset for i in tset):
    print(-1)
    exit()

d = {}

for x in tset:
    d[x] = sorted([j for j,y in enumerate(s) if x == y])

rep = 0
tmp = d[t[0]][0]

n = len(t)

for i in range(1,n):
    k = d[t[i]]
    x = bisect.bisect_right(k,tmp)
    if x == len(k):
        rep += 1
        tmp = k[0]
    else:
        tmp = k[x]

print(rep*len(s) + tmp +1)
    
    




Measured memory_bytes: 52704
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        int a = Integer.parseInt(scan.next());
        String strans = "";
        int intans = 0;

        int odd = 0;
        int eve = 0;
            if(a>999){
                strans = "ABD";
            }else{
                strans = "ABC";
            }
        PrintWriter out = new PrintWriter(System.out);
        out.println(strans);
        out.flush();
        scan.close();
    }
}

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

int main() {
  
  char b, c[128];
  c['A'] = 'T';
  c['T'] = 'A';  
  c['C'] = 'G';  
  c['G'] = 'C';
    cin >> b;
    cout << c[(int)b] << endl;
    
}


Measured memory_bytes: 256
#include <set>
#include <iostream>

using namespace std;

set<int> Hon = {2, 4, 5, 7, 9};
set<int> Pon = {0, 1, 6, 8};

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

    if (Hon.find(N % 10) != Hon.end())
    {
        cout << "hon\n";
    }
    else if (Pon.find(N % 10) != Pon.end())
    {
        cout << "pon\n";
    }
    else
    {
        cout << "bon\n";
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

int main()
{
	int q1,b,c1,c2,q2;
	while(cin>>q1,q1)
	{
		cin>>b>>c1>>c2>>q2;
		for(int aizu=q2;aizu>0;aizu--)
		{
			if(double(aizu)*c1>b)continue;
			int hutuu=(b-aizu*c1)/c2;
			if(aizu+hutuu<q1)continue;
			
			cout<<aizu<<" "<<hutuu<<endl;
			goto END;
		}
		cout<<"NA"<<endl;
		
		END:;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll llINF=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int n,l;
  cin>>n>>l;
  vi a(n);
  rep(i,n){
    a[i]=i+l;
  }
  sort(all(a));
  int sum=0;
  if(a[0]>=0){
    for(int i=1;i<n;i++){
      sum+=a[i];
    }
  }
  if(a[0]<0&&a[n-1]>=0){
    for(int i=0;i<n;i++){
      sum+=a[i];
    }
  }
  if(a[0]<0&&a[n-1]<0){
    for(int i=0;i<n-1;i++){
      sum+=a[i];
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(){
  int n,i,j,kati[10],hikiwake[10],a[9],b;
  char c[10],t;

  while(1){
    for(i = 0;i < 10;i++){
      kati[i] = 0;
      hikiwake[i] = 0;
    }
    scanf("%d",&n);
    if(n == 0)break;
    for(i = 0;i < n;i++){
      scanf("%c",&t);
      scanf("%c",&c[i]);
      for(j = 0;j < n-1;j++){
	scanf("%d",&a[j]);
	if(a[j] == 0){
	  kati[i]++;
	}
	else if(a[j] == 2){
	  hikiwake[i]++;
	}
      }
    }/*
 for(i = 0;i < n;i++){
      printf("%c ",c[i]);
      for(j = 0;j < n-1;j++){
	printf("%d ",a[j]);
      }
      printf("\n");
      }*/

    for(i = 0;i < n;i++){
      for(j = n-1;j > i;j--){
	if(kati[j] > kati[j-1]){
	  t = c[j-1];
	  c[j-1] = c[j];
	  c[j] = t;
	  b = kati[j-1];
	  kati[j-1] = kati[j];
	  kati[j] = b;
	  b = hikiwake[j-1];
	  hikiwake[j-1] = hikiwake[j];
	  hikiwake[j] = b;
	}
	else if(kati[j] == kati[j-1]){
	  if(hikiwake[j] > hikiwake[j-1]){
	    t = c[j-1];
	    c[j-1] = c[j];
	    c[j] = t;
	    b = kati[j-1];
	    kati[j-1] = kati[j];
	    kati[j] = b;
	    b = hikiwake[j-1];
	    hikiwake[j-1] = hikiwake[j];
	    hikiwake[j] = b;
	  }
	}
      }
    }
    for(i = 0;i < n;i++){
      printf("%c\n",c[i]);
    }
  }
  return 0;
}

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

using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define all(v) v.begin(), v.end()
#define debug(x) cout << x << endl
#define vout(v) rep(i, v.size()) cout << v[i] << " "

const int MAX = 1000000;
int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes";
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  ll N, D, A;
  cin >> N >> D >> A;
  vector<vector<ll>> M(N, vector<ll>(2));
  for (int i = 0; i < N; i++) {
    cin >> M[i][0] >> M[i][1];
  }
  sort(M.begin(), M.end());
  vector<ll> X(N), H(N);
  for (int i = 0; i < N; i++) {
    X[i] = M[i][0];
    H[i] = M[i][1];
  }
  ll res = 0;
  queue<pair<ll, ll>> st;
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    while (!st.empty() && st.front().first < X[i]) {
      sum -= st.front().second;
      st.pop();
    }
    if (H[i] > sum) {
      H[i] -= sum;
      ll bomb = ceil(double(H[i]) / A);
      res += bomb;
      ll damage = bomb * A;
      sum += damage;
      ll right = X[i] + 2 * D;
      st.push({right, damage});
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 16000
import java.util.Scanner;

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

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(Math.min(n * a, b));

		sc.close();
	}
}

Measured memory_bytes: 27028
import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	li=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
	print(li[int(input())-1])

if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n,a[2005],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=n;i>=3;i--)
		for(int j=i-1,k=1;j>=2&&j>k;j--){
			while(k<j&&a[i]>=a[j]+a[k]) k++;
			ans+=j-k;
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0,tmp,cmp;
  int a[4]={0,3,5,7};
  cin >> n;
  string s=to_string(n);
  int bit4[s.size()];

  for(int i=0;i<=pow(4,s.size());i++){
    tmp=i;
    cmp=0;
    map<int, int> mp;

    for(int j=0;j<=s.size();j++){
      bit4[j]=tmp%4;
      mp[tmp%4]++;
      tmp/=4;
    }

    for(int j=0;j<s.size();j++){
      cmp+=a[bit4[j]]*pow(10,j);
    }

    string t=to_string(cmp);
    bool f=true;
    for(int j=0;j<t.size();j++){
      if(t[j]=='0'){
        f=false;
        break;
      }
    }
	
    if(cmp<=n and mp[1] and mp[2] and mp[3] and f){
      ans++;
    }else if(cmp>n){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    long n=sc.nextLong();
    long a=sc.nextLong();//青
    long b=sc.nextLong();//赤

    long total=a+b;

    long am=n%total;

    long ans;

    if (am>a) {
      ans=n/total*a+a;
    }else{
      ans=n/total*a+am;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string S, T;
  	cin >> S >> T;
 	int N;
  	N=S.size();
  	for (int i = 0; i < N; i++) {
    	if( S.at(i)!=T.at(i) ){
        	cout << "No" << endl;
          	break;
        }
      
      	if( i==N-1 && S.at(i)==T.at(i) ){
        	cout << "Yes" <<endl;
          	break;
        }
    }
}

Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const int N=52;
int n,a,x[N];
LL ans,dp[N][N][N*N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
//	freopen("Tak and Cards.in","r",stdin);
	read(n,a);
	for(RG int i=1;i<=n;i++) read(x[i]);
	dp[0][0][0]=1;
	for(RG int i=1;i<=n;i++)
	 for(RG int j=i;j>=0;j--)
	  for(RG int k=a*n;k>=0;k--)
	  {
			dp[i][j][k]=dp[i-1][j][k];
			if(k>=x[i] && j) dp[i][j][k]+=dp[i-1][j-1][k-x[i]];
	  }
	for(RG int i=1;i<=n;i++) ans+=dp[n][i][a*i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 54272
A, B, X = map(int, input().split())
ANS = []
for i in range(X):
    if(A<=A+i<=B):
        ANS.append(A+i)

for i in range(X):
    if(B-X+i+1 not in ANS):
        if(B-X+i+1>=A):
            ANS.append(B-X+i+1)

for j in ANS:
    print(j)

Measured memory_bytes: 3060