akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

typedef struct UnionFindTree{
    vector<int> par;

    UnionFindTree(int n){
        par.resize(n, -1);
    }

    bool is_root(int x){
        return par[x]<0;
    }

    int find(int x){
        if(is_root(x)) return x;
        return par[x] = find(par[x]);
    }

    int size(int x){
        return -par[find(x)];
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
}UF;

int n, m;

void solve(){
    vector<pii> E[10010];
    rep(i, m){
        int a, b, w;
        scanf("%d%d%d", &a, &b, &w);
        --a; --b;
        E[w].emplace_back(a, b);
    }

    int ans = mod;
    rep(i, 10010)if(!E[i].empty()){
        UF uf(n);
        For(j, i, 10010){
            for(auto p: E[j]) uf.unite(p.fi, p.se);
            if(uf.size(0) == n){
                chmin(ans, j - i);
                break;
            }
        }
    }
    printf("%d\n", ans == mod ? -1 : ans);
}

int main(){
    while(scanf("%d%d", &n, &m) && n){
        solve();
    }
}


Measured memory_bytes: 3564
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};


int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> dp(1 << 12, INF);
    dp[0] = 0;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        int key = 0;
        rep(j, b){
            int c;
            cin >> c;
            key = key | 1 << (c-1);
        }
        rep(x, 1<<N){
            if(dp[x|key] > dp[x] + a) dp[x|key] = dp[x] + a;
        }
    }
    if(dp[(1 << N) - 1] == INF) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N)- 1] << endl;
}

Measured memory_bytes: 3664
#include<iostream> 
using namespace std;
int main(){
	int n;int d=0;
	cin>>n;
	for(int i=0;i<=25;i++){
		for(int j=0;j<=(100-4*i)/7;j++){
			if(n==4*i+j*7){d=1;break;}
		}
	}
	if(d==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
def f(abc,c):
    m = max(abc)
    a = 0
    for i in abc:
        a += (i < m)
    if a == 0:
        return c
    c += 1
    if a <= 1:
        for i,x in enumerate(abc):
            if x < m:
                abc[i] += 2
                break
        return f(abc,c)
    else:
        for i,x in enumerate(abc):
            if x < m:
                abc[i] += 1
        return f(abc,c)


abc = list(map(int, input().split()))
print(f(abc,0))


Measured memory_bytes: 9116
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad

main :: IO ()
main = do
    [a :: Int, b :: Int] <- map read . words <$> getLine
    putStrLn $ solve a b
      where
        solve a b 
          | c `mod` 2 == 1 = "Yes"
          | otherwise = "No"
            where c = a * b


Measured memory_bytes: 3768
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if n == 1:
  print(0)
  exit()

f = factorization(n)
count = 0

for i in range(len(f)):
  k = f[i][1]
  r = 1
  count += 1
  for j in range(2,k+1):
    r += j
    if k-r >= 0:
      count += 1

print(count)

Measured memory_bytes: 9504
import sys

n,x=map(int,input().split())
l=list(map(int,input().split()))
ans=[0]
num=0

for i in range(n):
  num+=l[i]
  ans.append(l[i])

  if num==x:
    print(len(ans))
    sys.exit()
    
  elif num>x:
    print(len(ans)-1)
    sys.exit()
    
print(len(ans))

Measured memory_bytes: 3064
data = input().rstrip().split(" ")
tele = input().rstrip().split(" ")
telepo = [int(i) for i in tele]

max = int(data[1])
limit = max
times = 0
pos = 1
experience = [1]
check = {1}
before = 0
while max > 0:
    pos = telepo[pos - 1]
    max -= 1
    times += 1
    before = len(check)
    check.add(pos)
    if before == len(check):
        length = len(experience) - experience.index(pos)
        max = max % length
        if max == 0:
            break
        while max > 0:
            pos = telepo[pos - 1]
            max -= 1
            times += 1
            #print(pos)
        break
    experience.append(pos)
print(pos)

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	string s;

	cin >> s;

	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

int main() {
  int n;
  cin >> n;
  unordered_set<string> set;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    set.insert(s);
  }
  cout << set.size() << endl;
  return 0;
}


Measured memory_bytes: 13788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int f(ll n, int k){
    string s;
    Rep(k){
        s += ('a' + n % 26);
        n /= 26;
    }
    Reverse(s);
    Cout(s);
    return 0;
}

int main(void){
    Cin(ll, n); n--;
    for(ll k = 1, r = 26; true; k ++, r *= 26){
        if(n < r) return f(n, k);
        n -= r;
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	string s;
	cin >> s;
	s[3]++;
	cout << s << endl;
	return 0;
}



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

int main() {
  int N,X,C;
  cin >> N;
  C = N;

  while (C > 0){
    X += C % 10;
    C = C /10;
  }
  if (N % X == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main(){
	int n;
	int a[200000];
	cin>>n;
	int ans=0;
	int now=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==now){
			now++;
			ans++;
		}
	}
	if(ans==0){
		cout<<-1<<endl;
	}else{
		cout<<n-ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
int a,b,c;
  int an=0;
  
  scanf("%d %d %d",&a,&b,&c);
if(a==b&&b==c){printf("1\n");}
  else if((a==b&&b!=c)||(a!=c&&b==c)||(a==c&&b!=c)){printf("2\n");}
  else{printf("3\n");}
  //printf("%d\n",an);
}

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

vector<pair<char, int>> rle(string s)
{
    vector<pair<char, int>> res;
    char c; int l;
    for (int i = 0; i < (int)s.length(); i++) {
        if (i == 0) {
            c = s[i]; l = 1;
        } else if (s[i] == c) {
            l++;
        } else {
            res.push_back({c, l});
            c = s[i]; l = 1;
        }
    }
    res.push_back({c, l});
    return res;
}

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    auto r = rle(s);
    cout << r.size() << endl;
    return 0;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int n,flag=0,flag2=0;
	cin>>n;
	ll a;
	ll ans=1,ans1=1;
	ll che=1e18;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==0){
			flag=1;
		}
		ans=ans*a;
		//cout<<ans<<" "<<ans1<<endl;
		if(ans<ans1){
			//cout<<"in of\n";
			
			flag2=1;
		}
		ans1=ans;
	}
	//cout<<ans<<" ";
	if(flag==1){
		cout<<"0\n";
		return 0;
	}
	if(flag2==1){
		cout<<"-1\n";
		return 0;
	}
	if(ans>che ){
		cout<<"-1\n";
		return 0;
	}
	else
		cout<<ans<<endl;

	return 0;
}

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

ll divby2(ll x) {
  ll ret = 0;
  while(x%2==0) {
    x /= 2;
    ret++;
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  ll a, ans = 0;
  rep(i, 0, n) {
    cin >> a;
    ans += divby2(a);
  }    
    
  cout << ans << "\n";

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

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

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ull A, B, C;
    in >> A >>  B >>  C;
    if (C < A + B) {
        out << "No" << endl;
        return 0;
    }
    ull X = (C-A-B)*(C-A-B);
    out << (4*A*B < X ? "Yes" : "No" ) << endl;
    return 0;
}


int main() {
    return run(cin, cout);
}


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

#define pb push_back

using namespace std;

int N;
vector<int> a;
char s[200010];

int main(){
	scanf("%s",s);
	N = strlen(s);
	for(int i=0; i<N; i++){
		if(s[i] == 'S') a.pb(0);
		else{
			if(a.size() != 0 && a.back() == 0){
				a.pop_back();
			}else a.pb(1);
		}
	}
	printf("%d\n",a.size());

	return 0;
}

Measured memory_bytes: 1528
#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a) for (auto &i: a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

// 最大値のquery
template<class T>
struct SegmentTree {
private:
  int n    = 1;
  int init = -INF;
  vector<T> data;

public:
  SegmentTree(vector<T> &v) {
    while (n < v.size()) n *= 2;
    data.assign(2 * n - 1, init);
    for (int i = 0; i < v.size(); i++) data[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--) data[i] = max(data[2 * i + 1], data[2 * i + 2]);
  }
  void update(int ind, T val) {
    ind += n - 1;
    data[ind] = val;
    while (ind > 0) {
      ind       = (ind - 1) / 2;
      data[ind] = max(data[2 * ind + 1], data[2 * ind + 2]);
    }
  }
  T at(int ind) { return data[n - 1 + ind]; }
  T operator[](int ind) { return data[n - 1 + ind]; }
  T query(int L, int R, int k = 0, int l = 0, int r = -1) { // [L, R
    if (r < 0) r = n;
    if (r <= L || R <= l) return init;
    if (L <= l and r <= R) return data[k];
    return max(query(L, R, 2 * k + 1, l, (l + r) / 2), query(L, R, 2 * k + 2, (l + r) / 2, r));
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  vector<int> temp(n, 0);
  SegmentTree<int> seg(temp);
  rep(i, n) seg.update(x[i] - 1, seg.query(0, x[i]) + x[i]);
  cout << SUM(x) - seg.query(0, n) << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll N; cin >> N;
  ll result = 0;
  if (N%2==0) {
    N /= 2;
    while(N) { result += N/5; N /= 5; }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int a,b,c,result;
    long sum=0;
    cin>>a;
    for(int i=1;i<=a;i++)
    {
    	for(int j=1;j<=a;j++)
    	{
    		for(int k=1;k<=a;k++)
    		{
    			sum+=gcd(gcd(i,j),k);

    		}
    	}
    }
    cout<<sum;

}

Measured memory_bytes: 3648
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "Yes" : "No")<<endl;
using namespace std;


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int n=0;
	while(a>0 && c>0){
		if((n&1)){
			a-=d;
		}
		else{
			c-=b;
		}
		n++;
		// cout << a << " " << c << endl;
	}
	if(a>0){
		output(1);
	}
	else{
		output(0);
	}

	return 0;
}  


Measured memory_bytes: 3596
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
int H, n;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> H >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    int maxA = *max_element(all(a));
    vector<int> dp(H + maxA + 1,INF);

    dp[0] = 0;
    for (int i = 0; i < n; i++)
        for (int j = a[i]; j <= H + maxA; j++)
            dp[j] = min(dp[j],dp[j - a[i]] + b[i]);
    
    int ans = INF;
    for (int i = H; i <= H + maxA; i++)
        ans = min(ans,dp[i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop0(i,n) for(int i=0; i<(n); i++)
#define loop1(i,n) for(int i=1; i<=(n); i++)
#define fori(a,b,i) for(int i=(a); i<=(b); i++)
#define ford(a,b,i) for(int i=(a); i>=(b); i--)
#define fast_io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ign cin.ignore(numeric_limits<streamsize>::max(),'\n')
 
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef map<int,int> MCI;
typedef unordered_map<int,int> UMII;
typedef unordered_map<char,int> UMCI;
typedef set<int> SI;
typedef long long int llint;
 
// Display Map
//~for (auto const& pair: m) {
//~std::cout << "{" << pair.first << ": " << pair.second << "}\n";
//~}
 
// Extract word(w) from sentence(s)
//~stringstream str(s);
//~string w;
//~while(str >> w){
//~// w is your word
//~}
 
//Memset Syntax
// memset(array, value,sizeof(array)) val is 0,-1 or bool only
 
// To get accurate precision
//~cout.precision(20);
 
int main() {
    fast_io;
	llint n;
	cin >> n;
	vector<llint> v(n);
	unordered_map<llint, llint> m; 
	for(auto &i : v) cin >> i;
	for (llint i = 0; i < n; i++) m[v[i]]++;  
	llint q;
	cin >> q;
	llint sum = accumulate(v.begin(),v.end(),1LL*0);;
	
	for(llint i = 0; i < q; i++){
		llint a,b;
		cin >> a >> b ;
		
		sum = sum - (1LL*a*m[a]) +(1LL*b*m[a]);
		
		m[b] += m[a];
		
		m[a] = 0;
 
		cout << sum << endl;		
	}
	
}

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

int main()
{
    int i,flag=0;
    char digit[4];
    scanf("%s",digit);
    for(i=0;i<3;i++)
    {
        if(digit[i]=='7')flag++;
    }
    if(flag==0)printf("No");
    else printf("Yes");
    return 0;
}

Measured memory_bytes: 1724
import collections
N, X, Y = map(int, input().split())
ans = collections.defaultdict(int)
for i in range(1,N):
    for j in range(i+1,N+1):
        minnum = min(abs(j-i),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[minnum]+=1

for i in range(1,N):
    print(ans[i])

Measured memory_bytes: 3956
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int gankin = 100000, week = sc.nextInt();
    double risoku = 0.05;
    for(int i = 0;i < week;i++){
      gankin *= (1 + risoku);
      if(gankin % 1000 != 0){
        gankin = gankin - (gankin % 1000) + 1000;
      }
    }
    System.out.println(gankin);
  }
}

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

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

    int alf['Z' + 1] = {};
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        alf[s[0]]++;
    }

    string ss = "MARCH";
    long long ans = 0;
    for (int i = 0; i < 1 << 5; i++) {
        int cnt = 0;
        long long t = 1;
        for (int j = 0; j < 5; j++) {
            if ((i >> j) & 1) t *= 1LL * alf[ss[j]], cnt++;
        }
        if (cnt == 3) ans += t;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
s = gets.chomp!
t = gets.chomp!
al = "abcdefghijklmnopqrstuvwxyz"
ss = Hash.new(0)
tt = Hash.new(0)
for i in 0...al.size
  ss[al[i]] = 0
  tt[al[i]] = 0
end
for i in 0...s.size
  ss[s[i]] += 1
  tt[t[i]] += 1
end
sss = ss.values
ttt = tt.values
sss.sort!
ttt.sort!
mat = true
for i in 0...ss.size
  if sss[i] != ttt[i]
    print 'No'
    exit
  end
end
print 'Yes'


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  string res = "";
  for (int i = 0; i < n; i++) sort(s[i].begin(), s[i].end());
  for (char c = 'a'; c <= 'z'; c++) {
    int m = 100;
    for (int i = 0; i < n; i++) {
      int t = upper_bound(s[i].begin(), s[i].end(), c) - lower_bound(s[i].begin(), s[i].end(), c);
      m = min(m, t);
    }
    for (int i = 0; i < m; i++) res += c;
  }
  cout << res << "\n";
  return 0;
}

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

int main(){
  double A, B, H, M; cin>>A>>B>>H>>M;
  double pi=3.1415926535;
  double Xa, Xb, Ya, Yb;
  Xa=A*cos((2*pi*H/12)+(pi*M/360));
  Ya=A*sin((2*pi*H/12)+(pi*M/360));
  Xb=B*cos(2*pi*M/60);
  Yb=B*sin(2*pi*M/60);
  double dist=(Xa-Xb)*(Xa-Xb)+(Ya-Yb)*(Ya-Yb);
  double ans=pow(dist, 0.5);
  cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 4292
function main(arg) {
    var a1 = arg.split(/\s+/g)[0];
    var a2 = arg.split(/\s+/g)[1];
    var a3 = arg.split(/\s+/g)[2];
    var sum = parseInt(a1)+parseInt(a2)+parseInt(a3);
    if(sum>=22){
    	console.log("bust");
    }else{
    	console.log("win");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int r,c;
    int a[100][100];
    int x[100]={0};
    int y[100]={0};
    int i,j,z;
    
    scanf("%d %d",&r,&c);
    
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d",&a[i][j]);
        }
    }
    
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            z+=a[i][j];
        }
    }
    
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            x[i]+=a[i][j];
        }
    }
    for(j=0;j<c;j++){
        for(i=0;i<r;i++){
            y[j]+=a[i][j];
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            printf("%d ",a[i][j]);
        }printf("%d\n",x[i]);
    }
    for(j=0;j<c;j++){
        printf("%d ",y[j]);
    }printf("%d\n",z);
    
    return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
#define int long long
#define INT INT_MAX
#define LONG LLONG_MAX
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
typedef long long ll;
using namespace std;

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

ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}

ll mypow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}

signed main() {
	int a, b, c[100];
	cin >> a >> b;
	f(i, a)cin >> c[i];
	sort(c, c + a);
	f(i, a) {
		if (b >= c[i]) b -= c[i];
		else {
			cout << i << endl;
			return 0;
		}
	}
	if (b) cout << a - 1 << endl;
	else cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
flag = []
for i in range(0, len(s)-len(t)+1):
    num = 0
    while True:
        if num == len(t):
            flag.append(i)
            break
        elif s[i + num] not in [t[num], '?']:
            break
        else:
            num += 1
if not flag:
    print ('UNRESTORABLE')
else:
    answers = []
    for ind in flag:
        ans = s[:ind] + t + s[ind+len(t):]
        if '?' in ans:
            ans = ans.replace('?', 'a')
        answers.append(ans)
    answers.sort()
    print (answers[0])
            


Measured memory_bytes: 3064
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 300001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);


using namespace std;

int n , W;

intt dp[SIZE] , we[SIZE] , val[SIZE] , res;

int main()
{
    FAST_READ;
    cin>>n>>W;
    for (int i = 1;i<=100000;i++)dp[i] = INF;
    for (int i = 1;i<=n;i++) cin>>we[i]>>val[i];
    for (int i = 1;i<=n;i++) {
        for (int j = 100000;j>=0;j--) {
            if (j - val[i] < 0)break;
            if (dp[j - val[i]] == INF)continue;
            dp[j] = min(dp[j] , dp[j - val[i]] + we[i]);
            if (dp[j] <= W)res = max(res,j * 1LL);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb push_back

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll a;
    double b;
    cin >> a >> b;

    ll ans = (ll) round(b*100);
    ans *= a;
    cout << (ans / 100);

}

Measured memory_bytes: 3796
import sys
import math
def input(): return sys.stdin.readline().rstrip()


def solve(x, y):
    if x == y:
        return 2*x-2
    elif abs(x-y)==1:
        return min(x,y)*2-2
    else:
        k = x*y
        sqr = math.ceil(math.sqrt(k))-1
        return 2*sqr-2+(sqr*(sqr+1) < k)


def main():
    q=int(input())
    for _ in range(q):
        a,b=map(int, input().split())
        print(solve(a,b))


if __name__ == '__main__':
    main()

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

int main(void) {
    long long int one_hundread = 100;
    double rate = 1.01;

    double x;
    cin >> x;

    int year = 0;
    for (long long int yokin = one_hundread; yokin < x; yokin = yokin * rate) {
        year++;
    }

    cout << year << endl;

    return 0;
}


Measured memory_bytes: 3720
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

const int MaxN = 1e5;
int a[MaxN + 5], b[MaxN + 5], c[MaxN + 5];
int n;

int main()
{
	while(~scanf("%d", &n)){
		for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
		for(int i = 1; i <= n; i++) scanf("%d", &c[i]);
		sort(a + 1, a + 1 + n);
		sort(b + 1, b + 1 + n);
		sort(c + 1, c + 1 + n);
		LL ans = 0;
		int pa = 0, pc = 0;
		for(int i = 1; i <= n; i++){
			while(a[pa + 1] < b[i] && pa < n) pa++;
			while(c[pc + 1] <= b[i] && pc < n) pc++;
			ans += 1LL * pa * (n - pc);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
pair<long long, long long> ext_gcd(long long a, long long b) {
  if (b == 0) return {1, 0};
  pair<long long, long long> pr = ext_gcd(b, a % b);
  return {pr.second, pr.first - a / b * pr.second};
}

long long mod_inv(long long a, long long mod = MOD) {
  if (__gcd(a, mod) != 1) return 0;
  pair<long long, long long> pr = ext_gcd(a, mod);
  return (pr.first + mod) % mod;
}

const int MAX = 10000000;
long long fact[MAX + 1], fact_inv[MAX + 1];
void nCk_init(int num = MAX, long long mod = MOD) {
  fact[0] = 1;
  FOR(i, 1, num + 1) fact[i] = fact[i - 1] * i % mod;
  fact_inv[num] = mod_inv(fact[num], mod);
  for (int i = num; i > 0; --i) fact_inv[i - 1] = fact_inv[i] * i % mod;
}

inline long long nCk(int n, int k, long long mod = MOD) {
  if (n < 0 || n < k || k < 0) return 0;
  return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  nCk_init();
  int h, w, a, b; cin >> h >> w >> a >> b;
  long long ans = 0;
  FOR(j, b+1, w+1) {
    (ans += nCk(j-1 + h-a-1, j-1) * nCk(a-1 + w-j, a-1) % MOD) %= MOD;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 156544
X = gets.chomp.to_i

def func(x)
  if x == 0 then
    puts "1"
    exit
  end
end

(0..X/100).each do |a|
  xa = a == 0 ? X : X - (100 * a)
  func(xa)
  (0..xa/101).each do |b|
    xb = b == 0 ? xa : xa - (101 * b)
    func(xb)
    (0..xb/102).each do |c|
      xc = c == 0 ? xb : xb - (102 * c)
      func(xc)
      (0..xc/103).each do |d|
        xd = d == 0 ? xc : xc - (103 * d)
        func(xd)
        (0..xd/104).each do |e|
          xe = e == 0 ? xd : xd - (104 * e)
          func(xe)
          (0..xe/105).each do |f|
            xf = f == 0 ? xe : xe - (105 * f)
            func(xf)
          end
        end
      end
    end
  end
end

puts "0"

Measured memory_bytes: 3836
#include<stdio.h>

char farm[102][102];//売約済みはo
int vector[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int ans=0;
int bfs(int h,int w){
        int i,j;
        char now = farm[h][w];
        farm[h][w]='o';
        for(i=0;i<4;i++){
                if(now==farm[h+vector[i][0]][w+vector[i][1]]){
                        bfs(h+vector[i][0],w+vector[i][1]);
                }
        }
        return 1;
}
int main(){
        int i,j,k;
        int H,W;
        while(scanf("%d %d\n",&H,&W)){
                if(H==0&&W==0){
                        break;
                }
                for(i=0;i<H+2;i++){
                        if(i==0||i==H+1){               
                                for(j=0;j<W+2;j++){
                                        farm[i][j]='o';
                                }
                        }
                        else{
                                farm[i][0]='o';
                                scanf("%s",&farm[i][1]);
                                farm[i][W+1]='o';
                        }
                }
                ans=0;
                for(i=1;i<H+1;i++){
                        for(j=1;j<W+1;j++){
                                if(farm[i][j]!='o'){
                                        ans+=bfs(i,j);
                                }
                        }
                }
//              printf("%d %d \n",H,W);
//              for(i=0;i<H+2;i++){
//                      for(j=0;j<W+2;j++){
//                              printf("%c",farm[i][j]);
//                      }
//                      puts("");
//              }
                printf("%d\n",ans);
        }
        return 0;
}

Measured memory_bytes: 1080
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  long long int n,k;
  cin>>n>>k;
  vector<long long int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(k>=n){
    cout<<0<<endl;
  }
  else {
    long long int temp=0;
    for(int i=0;i<n-k;i++){
      temp+=vec.at(i);
    }
    cout<<temp<<endl;
  }
  return 0;
}

Measured memory_bytes: 1792
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
for i in range(8):
	if bin(i)[-1]=="1":
		x="+"
		p=a+b
	else: 
		x="-"
		p=a-b
	if bin(i)[-2]=="1":
		y="+"
		p+=c
	else:
		y="-"
		p-=c
	if bin(i)[-3]=="1":
		z="+"
		p+=d
	else:
		z="-"
		p-=d
	if p==7:
		print(str(a)+x+str(b)+y+\
			str(c)+z+str(d)+"="+str(7))
		break

Measured memory_bytes: 3064
n = list(map(int,input()))

if n[-1] == 2 or n[-1] == 4 or n[-1] == 5 or n[-1] == 7 or n[-1] == 9:
    print("hon")
elif n[-1] == 0 or n[-1] == 1 or n[-1] == 6 or n[-1] == 8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 61640
// ~maqsat~
/*    
**	  “Anyone who has never made a mistake has never tried anything new.”
**    © Albert Einstein
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 998244353;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;

    int x, y;
    cin >> x >> y;

    if(x == 1 && y == 1) return !(cout << 1000000);

    int ans = 0;
    if(x == 1) ans += 300000;
    if(y == 1) ans += 300000;
    if(x == 2) ans += 200000;
    if(y == 2) ans += 200000;
    if(x == 3) ans += 100000;
    if(y == 3) ans += 100000;

    cout << ans;
    return 0;
}
/*
 
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define fi first
#define se second
const int maxn=3*100005;
const int maxm=2<<16;
const int maxe=maxn*2;
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
ll n,a,b;
vector<ll> vec;
map<ll,int> ma;
ll p[maxn];

int main(){
    scanf("%lld%lld%lld",&n,&a,&b);
    if(!(a*b>=n&&a+b-1<=n)){printf("-1\n");return 0;}
    //vec.push_back(b);
    ll cnt=0;
    ll need=a*b-n;
    for(ll j=1;j<=a;j++)vec.push_back((b-1)*a+j);
    for(int i=b-2;i>=0;i--){
        ll wei=i*a;
        vec.push_back(wei+1);
        ll lef=a-2+1;
        if(cnt+lef<=need){
            cnt+=lef;
            continue;
        }
        else{
            ll rig=need-cnt;
            cnt=need;
            for(ll j=2+rig;j<=a;j++){
                vec.push_back(wei+j);
            }
        }
    }
    int tot=1;
    for(int i=0;i<vec.size();i++){
        p[i]=vec[i];
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<vec.size();i++){
        ma[vec[i]]=tot++;
    }
    for(int i=0;i<n;i++){
        printf("%d ",ma[p[i]]);
    }
    return 0;
}


Measured memory_bytes: 27244
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  ll x;
  cin >> n >> x;
  ll a[n], sum = 0;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n - 1; i++){
    if(a[i] + a[i+1] > x){
      sum += a[i+1] + a[i] - x;
      a[i+1] -= a[i+1] + a[i] - x;
      if(a[i+1] < 0) a[i+1] = 0;
    }
  }
  cout << sum << endl;
  return 0;
}

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

int main(){
    int n, x;
    while(1){
        int count = 0;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        for(int i = 1; i <= n - 2; i++){
            for(int j = i + 1; j <= n - 1; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x) count = count + 1;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}


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

int main(){

  int mai_500,mai_100,mai_50,goukei;
  cin >> mai_500;
  cin >> mai_100;
  cin >> mai_50;
  cin >> goukei;

  int count = 0;
  for (int i=0;i<=mai_500;++i){
    for(int j=0;j<=mai_100;++j){
      for(int l=0;l<=mai_50;++l){
        if(500*i + 100*j + 50*l == goukei){
          count++;
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main(){
    int n, a, cnt;
    cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        if(i % 2 != 0 && a % 2 != 0){
            cnt++;
        }
    }

    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 3592
import re
from itertools import product
import itertools

q1 = int(input())
q2 = input()
q3 = int(input())
q4 = input()

S = re.split(r' ',q2)
S=list(map(int, S))

T = re.split(r' ',q4)
T=list(map(int, T))

S_len = len(S)
T_len = len(T)

array = []
for j in range(q1+1):
    x = list(itertools.combinations(S, j))
    for k in range(len(x)):
        y = sum(x[k])
        array.append(y)

for i in range(T_len):
    if(T[i] in array):
        print("yes")
    else:
        print("no")


Measured memory_bytes: 78076
#include <stdio.h>
#include <string.h>
#define  maxn 1000
int main ()
{
	char O[maxn],E[maxn],D[maxn];
	int j; 
	while(scanf("%s",O)!=EOF&&scanf("%s",E)!=EOF){
		int i,num1,num2;
		num1=strlen(O);
		num2=strlen(E);
		
		for(i=0,j=0;i<=num1;i++){
			
			D[j]=O[i];
			                   
			j++;
		    if(i>num2)
			  break;
		    D[j]=E[i];
		     j++;
		                        
		}
	printf("%s",D);	
	}
	
 } 

Measured memory_bytes: 128
// #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define S second
#define F first
using namespace std;

const ll N = 2e5 + 5, M = 1e6 + 5;

int arr[100];

int main()
{
    int n, k, mx = 0;
    scanf("%d%d", &n, &k);
    for(int i = 1 ; i <= n ; i++) scanf("%d", arr + i);
    for(int i = 0 ; i <= min(k, n) ; i++)
    {
        for(int j = 0 ; i + j <= min(n, k) ; j++)
        {
            int sum = 0;
            vector<int> v;
            for(int w = 1 ; w <= i ; w++)
            {
                sum += arr[w];
                v.emplace_back(arr[w]);
            }
            for(int w = 1 ; w <= j ; w++)
            {
                sum += arr[n - w + 1];
                v.emplace_back(arr[n - w + 1]);
            }
            sort(v.begin(), v.end());
            for(int w = 0 ; w < k - (i + j) and w < v.size() ; w++)
            {
                if(v[w] >= 0) break;
                sum -= v[w];
            }
            // printf("%d %d %d\n", i, j, sum);
            mx = max(mx, sum);
        }
    }
    printf("%d\n", mx);
    return 0;
}


Measured memory_bytes: 3756
N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    s = list(map(int, input().split()))
    C.append(s[0])
    A.append(s[1:])
ans = float('INF')
for i in range(0, 1 << N):
    scores = [0] * M
    count = 0
    for j in range(N):
        if (i >> j) & 1:
            for s in range(M):
                scores[s] += A[j][s]
            count += C[j]
    if min(scores) < X:
        continue
    else:
        ans = min(ans, count)
 
if ans == float("INF"):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9212
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(1,n+1):
        ans += i * (n//i)*((n//i)+1) / 2
    print(int(ans))



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9052
N,M,Q=map(int,input().split())
L,R=0,0
A=[[0]*(N+1) for i in range(N+1)]
for i in range(M):
  L,R=map(int,input().split())
  A[L][R]+=1
C=[[0]*(N+1) for i in range(N+1)]
for i in range(1,N+1):
  for j in range(1,N+1):
    C[i][j]=C[i][j-1]+C[i-1][j]-C[i-1][j-1]+A[i][j]
for i in range(Q):
  L,R=map(int,input().split())
  print(C[N][R]-C[L-1][R])

Measured memory_bytes: 80424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

int main()
{
    int H,W;
    cin >> H >> W;
    VS A(H);
    
    rep(i,H){
        cin >> A.at(i);
    }
    VI B;
    rep(i,H){
        rep(j,A.at(i).size()){
            if(A.at(i).at(j)=='#'){
                B.push_back(i*5+j);
            }
        }
    }
    rep(i,B.size()-1){
        if(B.at(i+1)-B.at(i)!=1 && B.at(i+1)-B.at(i)!=5){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
}

Measured memory_bytes: 256