akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

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

    int h, w, n;
    cin >> h >> w >> n;
    int a[h][w];
    int arrayn[n];

    int* pointer = a[0];
    for(int i=1; i<=n; i++)
    {
        int num;
        cin >> num;

        for(int j=0; j<num; j++, pointer++)
        {
            *pointer = i;
        }
    }

    for(int i=0; i<h; i++)
    {
        if(i%2 == 0)
        {
            for(int j=0; j<w; j++) cout << a[i][j] <<' ';
        }
        else for(int j=w-1; j>=0; j--) cout << a[i][j] << ' ';

        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
# python 3.4.3
import sys
input = sys.stdin.readline
import numpy as np

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
H = list(map(int,input().split()))

ans = 0
highest = 0

for h in H:
    if h >= highest:
        ans += 1
        highest = h

print(ans)

Measured memory_bytes: 12488
N,M = map(int,input().split())
score = [[False,0] for _ in [0]*N]
for _ in range(M):
    p,S = input().split()
    p = int(p)-1
    S = S=="AC"
    if S:
        score[p][0] = True
    else:
        if not score[p][0]:
            score[p][1] += 1
AC = sum(s[0] for s in score)
WA = sum(s[1] for s in score if s[0])
print(AC,WA)

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

int main(){
    int n;
    cin >> n;
    int i;
    int a[n];
    rep(i,n) a[i] = 0;
    for(i = 1; i<n;i++) cin >> a[i];
    int num[n];
    rep(i,n) num[i] = 0;
    rep(i,n){
        if(i>0){
            num[a[i]-1]++;
        }
    
 
    }
    rep(i,n) cout << num[i] << endl;

    return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;

  	--a[0];
    for (int i = 1; i < n; i++) {
        if (a[i - 1] == a[i]) continue;
        if (a[i - 1] > a[i]) {
            std::cout << "No" << std::endl;
            return 0;
        }
        --a[i];
    }
    std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>

int main(){
	while(1){
		int n, i;
		double r=1, t=0;
		
		scanf(" %d", &n);
		if(n==-1) break;
		
		for(i=1; i<n; i++){
			t += atan(1/r);
			r = sqrt(r*r + 1);
		}
		
		printf("%.2lf\n%.2lf\n", r*cos(t), r*sin(t) );
	}

	return 0;
}

Measured memory_bytes: 1128
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
// set<int>st{ 3,1,4,1,5,9,2,6,5,3,5 };
//     for (auto itr = st.begin(); itr != st.end(); ++itr) {
//         cout << *itr;
//     }
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
    int n;
    cin>>n;
    rep(i,n/4+1){
        rep(j,(n-i*4)/7+1){
            if(i*4+j*7==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

}

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

int main(){
	//freopen("in.txt","r",stdin);
	int a,b;
	int cnt = 0;
	scanf("%d%d",&a,&b);
	cnt = max((a+a-1),max((b+b-1),(a+b)));
	printf("%d",cnt);
	//fclose(stdin);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int r;
    cin>>r;
    
    if(r<1200){
        cout<<"ABC"<<endl;
    }else if(r<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }
        
        
    
   
    return 0;
}








Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

struct Edge{
	int src;
	int dst;
	int cost;
	Edge(int src = -1, int dst = -1, int cost = 1)
	: src(src), dst(dst),cost(cost){};
	bool operator<(const Edge &e) const {
		return this -> cost < e.cost;
	}
	bool operator>(const Edge &e) const{
		return this -> cost > e.cost;
	}
};
using Graph = vector<vector<Edge>>;

int N,K;
Graph tree;
int ans = 1;
const int MOD = 1000000007;

void dfs(int cur,int pre,int num){
	ans = ans * num % MOD;
	num = K-1;
	if(pre != -1){
		num--;
	}
	for(auto e : tree[cur]){
		if(e.dst != pre){
			dfs(e.dst,cur,num);
			num--;
		}
	}
};

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> K;
  tree.resize(N);
  for(int i = 0; i < N-1 ; i++){
  	int a,b;
  	cin >> a >> b;
  	a--;
  	b--;
  	tree[a].emplace_back(a,b);
  	tree[b].emplace_back(b,a);
  }

  dfs(0,-1,K);
  cout << ans << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 12672
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, K);
    OUT((K / 2) * ((K + 1) / 2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

long long calc(long long A) {

	if (A <= 0) return 0;
	//4の時に、0,1,2,3,4までになるので、これは5つの整数まで
	//なので帳尻合わせで１足してあげる。
	A++;
	long long ans = 0;
	//i桁目の偶奇を調べる
	for (int i = 0; i < 50; i++)
	{
		//0桁目 → 周期2
		//1				4
		//2				8
		long long loop = (1LL << (i + 1));
		long long cnt = (A / loop) * (loop / 2);
		//00000.....0011111.....11
		cnt += max(0LL, (A % loop) - (loop / 2));

		//その桁の1の数が奇数だったら足し算
		if (cnt % 2 == 1) {
			ans += 1LL << i;
		}
	}

	return ans;
}

int main() {
	long long A, B;
	cin >> A >> B;
	long long ans = calc(B) ^ calc(A - 1);
	cout << ans << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC008
{
    public class D
    {
        private const string Yes = "Yes";
        private const string No = "No";
        private void Run()
        {
            var N = int.Parse(Console.ReadLine().Trim());
            var X = Console.ReadLine().Trim().Split().Select(int.Parse)
                .Select(x => x - 1) // to 0-indexed
                .ToArray();

            if (X.Distinct().Count() != X.Length) { goto No; }

            var array = Enumerable.Range(0, N)
                .Select(i => Tuple.Create(X[i], i + 1)) // [index, value]
                .OrderBy(t => t.Item1)
                .ToArray();

            var head = new Queue<int>();
            var rest = new Queue<int>();
            var resArray = new int[N * N];

            foreach (var t in array)
            {
                for (int i = 0; i < t.Item2 - 1; i++)
                {
                    head.Enqueue(t.Item2);
                }
            }

            var used = new bool[N];
            int index = 0;
            for (int i = 0; i < resArray.Length; i++)
            {
                int currentValue;
                if (index < array.Length && i == array[index].Item1)
                {
                    int arrayValue = array[index].Item2;
                    currentValue = arrayValue;
                    for (int j = arrayValue + 1; j <= N; j++)
                    {
                        rest.Enqueue(arrayValue);
                    }
                    used[arrayValue - 1] = true;
                    index++;
                }
                else
                {
                    if (head.Count > 0)
                    {
                        currentValue = head.Dequeue();
                        if (used[currentValue - 1]) { goto No; }
                    }
                    else
                    {
                        if (rest.Count == 0) { goto No; }
                        currentValue = rest.Dequeue();
                    }
                }
                resArray[i] = currentValue;
            }

            Console.WriteLine(Yes);
            Console.WriteLine(string.Join(" ", resArray));
            return;

            No:
            Console.WriteLine(No);
            return;
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new D().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 17112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };
#define all(u) begin(u),end(u)
#define mp make_pair
#define pb push_back

int main()
{
   i64 x, y;
    cin >> x >> y;
    cout << (abs(x - y) >= 2 ? "Alice" : "Brown") << endl;
    return 0;
    
    
    
    
    if(x >=3 || y >= 3)
    {
        cout << "Alice" << endl;
        return 0;
    }
    bool b = false;
    while(x  > 1 || y > 1)
    {
        if(x > 1)
        {
            x -= 2;
            y += 1;
        }
        else
        {
            y -= 2;
            x += 1;
        }
        b = !b;
    }
    cout << (b ? "Alice" : "Brown") << endl;
  return 0;
}


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

int A, B, ans=-1000001;

int main () {
    cin >> A >> B;
    if (A+B > ans) {
        ans = A+B;
    }
    if (A-B > ans) {
        ans = A-B;
    }
    if (A*B > ans) {
        ans = A*B;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const int SIZE = 100005;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ll MOD = 1E9 + 7;
#define rep(i,n) for (long long i=0;i<(n);++i)
#define repp(i,a,b) for (long long i=(a);i<(b);++i)
#define per(i,x) for(long long i = (x) ; i >= 0 ; --i)
#define perr(i,x,y) for(long long i = (x) ; i >= (y) ; --i)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define lla(a) (a).rbegin(),(a).rend()
#define p(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define p2(x,y) cout<<x<<" "<<y<<"\n"
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define p4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define p5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<"\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


//template<class T>
//bool isPrime(T n){
//    if(n==1)return false;
//    T i = 2;
//    while(i*i<=n){
//       if(n%i==0)return false;
//       i+=1;
//    }
//    return true;
//}

// bool prime[100005];
// void seive()
// {
//     memset(prime,true,sizeof(prime));
//     prime[0]=0;
//     prime[1]=0;
//     for(ll p=2;p*p<=100000;p++)
//     {
//         if(prime[p]==true)
//         {
//             for(ll i=p*2;i<=100000;i+=p)
//             prime[i]=false;
//         }
//     }    
// }

// ll power(ll n,ll k, ll mod){
//     if(k==0)
//         return 1;
//     if(k==1)
//         return n%mod;

//     ll get=power(n,k/2,mod);
//     ll ret = ((get%mod)*(get%mod))%mod;

//     if(k%2)
//         ret = ((ret%mod)*(n%mod))%mod;

//     return ret%mod;
// }

int main(){
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    FAST;
    
    int n,m; cin>>n>>m;
    vector<string> a(n);

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

    int dp[n][m];
    dp[0][0] = 1;

    rep(i,n){
        rep(j,m){
            if(i==0 && j==0)continue;
            if(a[i][j] == '#')dp[i][j] = 0;
            else if(i==0 || j==0){
                if(i==0)dp[i][j] = dp[i][j-1]%MOD;
                else dp[i][j] = dp[i-1][j]%MOD;
            }
            else dp[i][j] = (dp[i][j-1]%MOD + dp[i-1][j]%MOD)%MOD;
        }
    }
    // rep(i,n){
    //     rep(j,m){
    //         p(dp[i][j]);
    //     }
    //     pn("");
    // }
    pn(dp[n-1][m-1]);
}

Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

int n; vector<ll> a;

vec memo[18][18];
bool used[18][18];


vec dfs(int l, int r) {
	if (used[l][r])return memo[l][r];
	used[l][r] = true;
	if (l+1 == r) {
		return memo[l][r] = vec{ LP{0,0} };
	}
	vec ret;
	Rep1(i, l + 1, r - 1) {
		vec le = dfs(l, i);
		vec ri = dfs(i, r);
		rep(j, le.size()) {
			rep(k, ri.size()) {
				ret.push_back({ le[j].first + le[j].second + ri[k].first+a[i],le[j].second + ri[k].first + ri[k].second+a[i] });
			}
		}
	}
	sort(ret.begin(), ret.end());
	vec cc; cc.push_back(ret[0]);
	ll mem = ret[0].second;
	for (int i = 1; i < ret.size(); i++) {
		if (ret[i].second >= mem)continue;
		mem = ret[i].second;
		cc.push_back(ret[i]);
	}
	return memo[l][r] = cc;
}

void solve() {
	cin >> n; a.resize(n);
	rep(i, n) {
		cin >> a[i];
	}
	vec ans = dfs(0, n - 1);
	ll out = INF;
	rep(i, ans.size()) {
		out = min(out, ans[i].first + ans[i].second);
	}
	out += a[0] + a[n - 1];
	cout << out << endl;
}

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

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



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '[';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "");
    return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

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

    ll N, W;
    cin >> N >> W;
    vector<pair<ll, ll>> items(N);
    F0R (i, N)
        cin >> items[i].fi >> items[i].se;
    ll V = 0;
    for (auto p : items) V += p.se;

    // val x items -> minCost
    vector<vector<ll>> dp(V + 1, vector<ll>(N, -1));
    fill(ALL(dp[0]), 0);
    FOR (v, 1, V + 1) {
        if (v == items[0].se) dp[v][0] = items[0].fi;
        FOR (n, 1, N) {
            dp[v][n] = dp[v][n - 1];
            if (v >= items[n].se && ~dp[v - items[n].se][n - 1]) {
                if (~dp[v][n])
                    ckmin(dp[v][n], dp[v - items[n].se][n - 1] + items[n].fi);
                else
                    dp[v][n] = dp[v - items[n].se][n - 1] + items[n].fi;
            }
        }
    }

    R0F (v, V) {
        if (any_of(ALL(dp[v]), [&](ll a) { return ~a && a <= W; })) {
            cout << v << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 82304
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    string s;
    unsigned long long k;
    cin >> s >> k;

    for(int i = 0; i < s.length(); i++){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
        if(i+1 >= k){
            cout << '1' << endl;
            return 0;
        }
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

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

    int a,b;
    cin>>a>>b;
    if(a+b==15) cout<<"+"<<endl;
    else if(a*b==15) cout<<"*"<<endl;
    else cout<<"x"<<endl;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

const int MAX = 5001;
bool exist[MAX][MAX];

inline bool inside(int x, int y) {
    return 0 <= x && x < MAX && 0 <= y && y < MAX;
}

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

    int n;
    while (cin >> n, n) {
        rep(i, 5001) rep(j, 5001) exist[i][j] = false;

        V x(n), y(n);
        rep(i, n) {
            cin >> x[i] >> y[i];
            exist[x[i]][y[i]] = true;
        }

        int ans = 0;
        rep(i, n) {
            rep2(j, i + 1, n) {
                int dx = x[j] - x[i];
                int dy = y[j] - y[i];
                int x1 = x[i] + dy, y1 = y[i] - dx;
                int x2 = x[j] + dy, y2 = y[j] - dx;
                if (!inside(x1, y1) || !inside(x2, y2)) continue;
                if (exist[x[i] + dy][y[i] - dx] && exist[x[j] + dy][y[j] - dx]) {
                    ans = max(ans, dx * dx + dy * dy);
                }
            }
        }

        cout << ans << endl;

    }
}

Measured memory_bytes: 27580
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int limit = 50;
bool visit[limit];
bool graph[limit][limit];

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
void dfs(int v, int n) {
	visit[v] = true;
	for (int v2 = 0; v2 < n; ++v2) {
		if (graph[v][v2] == false) continue;
		if (visit[v2] == true) continue;
		dfs(v2, n);
	}
}

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(limit), b(limit);
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		graph[a[i]][b[i]] = false;
		graph[b[i]][a[i]] = false;
		for (int j = 0; j < n; ++j) visit[j] = false;
		dfs(0, n);
		bool bridge = false;
		for (int j = 0; j < n; ++j) {
			if (visit[j] == false) {
				bridge = true;
			}
		}
		if (bridge) ans++;
		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;
    return;
}

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



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

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

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

    sort(A, A+N);
    int ans = 0;
    long long int temp = A[0];
    int cnt = 1;
    for (int i=1; i<N; ++i) {
        if (A[i] != temp) {
            if (cnt % 2 == 1) ++ans;
            cnt = 1;
            temp = A[i];
        } else ++cnt;
    }
    if (cnt % 2 == 1) ++ans;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll m,n,ts,a,b,f=0;
    string s;
    cin>>s;
    if(s[s.size()-1]=='2' || s[s.size()-1]=='4' || s[s.size()-1]=='5' || s[s.size()-1]=='7' || s[s.size()-1]=='9' )
    {
       cout<<"hon\n";
    }
    else if(s[s.size()-1]=='0' || s[s.size()-1]=='1' || s[s.size()-1]=='6' || s[s.size()-1]=='8')
    {
        cout<<"pon\n";
    }
    else if(s[s.size()-1]=='3')
    {
       cout<<"bon\n";
    }




}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int A,B,C,D,E,F,x=1,y=1;
int main(){
    scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
    for(int i = 0;i <= F/(100*A);i++){
        int a = i*100*A;
        if(a > F) break;
        for(int j = 0;j <= F/(100*B);j++){
            int b = j*100*B;
            if(a+b > F) break;
            for(int k = 0;k < F/C;k++){
                int c = k*C;
                if(a+b+c > F) break;
                for(int l = 0;l < F/D;l++){
                    int d = l*D;
                    if((a+b+c+d) > F || (c+d) > (a+b)/100*E) break;
                    int tz = (c+d);
                    int tm = (a+b);
                    if(x*(tm+tz) <= tz*(y+x)){
                        x = tz;
                        y = tm;
                    }
                }
            }
        }
    }
    printf("%d %d",x+y,x);
    return 0;
}

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

using namespace std;

void solve()
{
	string str;
	cin >> str;
	int size = str.size();
	int count = 0;
	if(size % 2 == 0)
	{
		if(str[size / 2 - 1] == 'i' && str[size / 2] == 'i' || 
		   str[size / 2 - 1] == 'w' && str[size / 2] == 'w' ||
		   str[size / 2 - 1] == '(' && str[size / 2] == ')' ||
		   str[size / 2 - 1] == ')' && str[size / 2] == '(')
		{
			;
		}
		else
		{
			++count;
		}
		for(int i = 0; i < size / 2 - 1; ++i)
		{
			if(str[i] == 'i' && str[size - i - 1] == 'i' ||
			   str[i] == 'w' && str[size - i - 1] == 'w' ||
			   str[i] == '(' && str[size - i - 1] == ')' ||
			   str[i] == ')' && str[size - i - 1] == '(')
			{
				;
			}
			else
			{
				++count;
			}
		}
	}
	else
	{
		if(str[size / 2] == 'i' || str[size / 2] == 'w')
		{
			;
		}
		else
		{
			++count;
		}
		for(int i = 0; i < size / 2; ++i)
		{
			if(str[i] == 'i' && str[size - i - 1] == 'i' ||
			   str[i] == 'w' && str[size - i - 1] == 'w' ||
			   str[i] == '(' && str[size - i - 1] == ')' ||
			   str[i] == ')' && str[size - i - 1] == '(')
			{
				;
			}
			else
			{
				++count;
			}
		}
	}
	
	cout << count << endl;
}

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

Measured memory_bytes: 1188
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n; int gcd;
	cin >> n;
	vector<int>num(n);
	for (int i = 0; i < n; i++) {
		cin >> num[i];
	}

	sort(num.begin(), num.end());

	for (int i = num[1]; i > 0; i--) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			if (num[j] % i == 0) {
				sum++;
			}
		}
		if (sum >= n - 1) {
			gcd = i;
			break;
		}
	}
	cout << gcd;

}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
	int c=0,i,count[26]={0},num=0;
	char a,b='a';
	while(scanf("%c",&a)!=EOF){
		if(a>='a'&&a<='z'){
			num=a-'a';
			count[num]++;
		}else if(a>='A'&&a<='Z'){
			num=a+32-'a';
			count[num]++;
		}
	}
	for(i=0;i<26;i++){
			printf("%c : %d\n",b++,count[i]);
	}
	return 0;
}

Measured memory_bytes: 1848
#include <math.h>
#include <stdio.h>
 
int main()
{
    double x1,x2,x3,y1,y2,y3,r,xp,yp;
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
        xp=((y1-y2)*(x3*x3+y3*y3)+(y2-y3)*(x1*x1+y1*y1)+(y3-y1)*(x2*x2+y2*y2))/(2*(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)));
        yp=((x1-x2)*(x3*x3+y3*y3)+(x2-x3)*(x1*x1+y1*y1)+(x3-x1)*(x2*x2+y2*y2))/(2*(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2)));
        r=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
        printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
    }
    return 0;
}

Measured memory_bytes: 1084
from subprocess import run

with open("./tmp215378912379.cpp", mode='w') as f:
  f.write("""
#include <bits/stdc++.h>
template <class T>
concept Integral = std::is_integral_v<T>;

int main() {
  auto f = []<Integral T>(T a, T b) { return a * b; };
  int a, b;
  std::cin >> a >> b;
  std::cout << f(a, b) << std::endl;
}
""")

run("g++ -o ./tmp215378912379 -std=gnu++2a -fconcepts ./tmp215378912379.cpp && ./tmp215378912379", shell=True)

Measured memory_bytes: 196040
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> Pint;
typedef pair<double,double> Pdouble;
 
#define all(x) x.begin(),x.end()
 
const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;
 
double dot(Pint p1,Pint p2){
    return p1.first*p2.first + p1.second*p2.second;
}
double vector_length(Pint p){
    return pow(p.first*p.first+p.second*p.second,0.5);
}
 
double cos_(Pint p1,Pint p2){
    return dot(p1,p2)/(vector_length(p1)*vector_length(p2));
}
 
Pdouble proj(Pint p1,Pint p2,Pint a,Pint b){
    Pint pp = Pint(p2.first-p1.first,p2.second-p1.second);
    double ans_x = (double)p1.first + vector_length(a)*cos_(a,b)*pp.first/vector_length(pp);
    double ans_y = (double)p1.second + vector_length(a)*cos_(a,b)*pp.second/vector_length(pp);

    return Pdouble(ans_x,ans_y);
}
 
bool vector_equal(Pint p,Pint q){
    return (p.first == q.first) && (p.second == q.second);
}
 
int main()
{
    Pint p1,p2;
    cin >> p1.first >> p1.second >> p2.first >> p2.second;
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int x,y;
        cin >> x >> y;
 
        Pint pp = Pint(x,y);
        if(vector_equal(pp,p1)||vector_equal(pp,p2)){
            cout << x << " " << y << endl;
            continue;
        }
 
        Pint a = Pint(x-p1.first,y-p1.second);
        Pint b = Pint(p2.first-p1.first,p2.second-p1.second);

        Pdouble t =  proj(p1,p2,a,b);

        printf("%.12f %.12f\n", x + 2*(t.first-x),y + 2*(t.second-y));
        //cout << x + 2*(t.first-x) << " " << y + 2*(t.second-y) << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), l(n);
    vector<P> p(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
        l[i] = b[i] - a[i];
        p[i] = P(b[i], a[i]);
        if (l[i] < 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    sort(all(p));

    int tmp = 0;
    rep(i, n-1) {
        tmp += p[i].second;
        if (tmp > p[i+1].first - p[i+1].second) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

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

#define MAX 100002

int n;
int m;

vector<int> v[MAX];

int deg[MAX];
int main(){
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
		deg[a]++;
		deg[b]++;
	}
	for (int i = 0; i < n; i++){
		if (deg[i] & 1){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

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

struct Node {
  int key;
  Node *parent;
  Node *left;
  Node *right;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z = new Node[1];

  z->key = k;
  z->right = NIL;
  z->left = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent = y;

  if (y == NIL) {
    root = z;
  }
  else if (z->key < y->key) {
    y->left = z;
  }
  else {
    y->right = z;
  }
}

int preParse(Node *start) {
  if (start == NIL) {
    return 0;
  }
  cout << " " << start->key;
  preParse(start->left);
  preParse(start->right);
}

int inParse(Node *start) {
  if (start == NIL) {
    return 0;
  }
  inParse(start->left);
  cout << " " << start->key;
  inParse(start->right);
}

int main()
{
  int n;

  cin >> n;
  for (int i = 0; i < n; i++) {
    string command;
    cin >> command;
    if (command == "insert") {
      int k;
      cin >> k;
      insert(k);
    }
    else if (command == "print") {
      inParse(root);
      cout << endl;
      preParse(root);
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 26500
#include<iostream>
#include<string>
#include<set>
#include<vector>
using namespace std;

int main(){
  string str;
  int K;
  cin >> str;
  cin >> K;
  set<string>st;

  for(int i = 0 ; i < str.size() ; i++){
    string s;
    for(int j = 0 ; j < 5 && j + i < str.size() ; j++){
      s += str[i+j];
      st.insert(s);
    }
  }
  vector<string>vec = vector<string>(st.begin(),st.end());
  cout << vec[K-1] << endl;
  return 0;
}


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

int main () {
  int N;
  cin >> N;
  vector <int> B(N);
  for (int i = 0; i < N-1; i++) cin >> B.at(i);
  int ans = 0;
  for (int i = 1; i < N-1; i++){
    int a = 0;
    a = min (B.at(i-1), B.at(i));
    ans += a;
  }
  ans += B.at(N-2) + B.at(0);
  cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i=0;i<N;i++){
    cin >> num[i];
  }
  int flag=0;
  int s=1;
  int a=0;
  for(int i=0;i<N;i++){
    if(num[i]==s){
      s++;
      a++;
      flag=1;
    }
  }
  if(flag==0){
    cout << -1 << endl;
  }else{
    cout << N-a << endl;
  }
}  

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
 
int main(){
int n,b[100000],f[100000],r[100000],v[100000];
int A[5][4][11];
 
for(int i=1;i<5;i++){
for(int j=1;j<4;j++){
for(int k=1;k<11;k++){
A[i][j][k]=0;
}
}
}
 
cin>>n;
for(int i=1;i<=n;i++){
cin>>b[i]>>f[i]>>r[i]>>v[i];
A[b[i]][f[i]][r[i]] += v[i];
}
 
for(int i=1;i<=4;i++){
for(int j=1;j<=3;j++){
for(int k=1;k<=10;k++){
cout<<" "<<A[i][j][k];
}
cout<<endl;
}
if(i!=4){
cout<<"####################"<<endl;
}
}
 
return 0;

}


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

int main() {
  string S;
  cin >> S;
  bool B=true;
  for(int i=0;i<S.size();i++){
    for(int j=i+1;j<S.size();j++){
      if(S[i]==S[j]){
        B=false;
        break;
      }
    }
  }
  if(B){
    cout << "yes" << endl;
  }
  else{
    cout << "no" << endl;
  }
}


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

int main(){
  int a,b,c,p=0,sum=0;
  bool visited[60]={};
  cin>>a>>b>>c;
  while(1){
    if(visited[p]){
      cout<<-1<<endl;
      break;
    }
    visited[p]=true;
    if(p<=c&&c<=p+a){
      cout<<sum+c-p<<endl;
      break;
    }
    p=(p+a+b)%60;
    sum=sum+a+b; 
  }
  return 0;
}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,K,C;
	cin>>N>>K>>C;

    string S;
    cin>>S;
    vector<ll> L(K),R(K);
    ll ind = 0;
    rep(i,K){
        while(S[ind]=='x'){
            ++ind;
        }
        L[i] = ind;
        ind += C+1;
    }
    ind = 0;
    rep(i,K){
        while(S[N-1-ind]=='x'){
            ++ind;
        }
        R[i] = N-1-ind;
        ind += C+1;
    }
    // rep(i,K){
    //     cout<<L[i]<<" "<<R[K-1-i]<<"\n";
    // }
    // rep(i,K){
    //     cout<<R[i]<<"\n";
    // }
    rep(i,K){

        if(L[i]==R[K-1-i]){
            cout<<L[i]+1<<"\n";
        }
    }
	return 0;
}

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

int ctoi(char c){
  if('0' <= c && c<= '9')return(c-'0');
  return -1;
}
int  main(){
  string s; cin>>s;
  vector<int> a(4);
  rep(i,4){
    a[i]=ctoi(s.at(i));
    
  }
  char op1='+',op2='+',op3='+';
  if(a[0]+a[1]+a[2]+a[3]==7){}
  else if(a[0]+a[1]+a[2]-a[3]==7){op3='-';}
  else if(a[0]+a[1]-a[2]-a[3]==7){op2='-';op3='-';}
  else if(a[0]+a[1]-a[2]+a[3]==7){op2='-';}
  else if(a[0]-a[1]+a[2]-a[3]==7){op1='-';op3='-';}
  else if(a[0]-a[1]+a[2]+a[3]==7){op1='-';}
  else if(a[0]-a[1]-a[2]+a[3]==7){op1='-';op2='-';}
  else{op1='-';op2='-';op3='-';}
  
  cout<<a[0];cout<<op1;cout<<a[1];cout<<op2;
  cout<<a[2];cout<<op3;cout<<a[3];cout<<"=7";
}

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

int M[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[10010];

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++)
        cin >> a[i];
    sort(a.begin(), a.end(), greater<int>()); // 降順
    for (int i = 0; i < m; i++)
        b[i] = M[a[i]];
    dp[0] = 0;
    for (int i = 1; i <= n; i++)
        dp[i] = -1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (i < b[j])
                continue;
            dp[i] = max(dp[i], dp[i - b[j]] + 1);
        }
    }
    int size = dp[n];
    while (n)
    {
        for (int i = 0; i < m; i++)
        {
            if (n < b[i])
                continue;
            if (dp[n - b[i]] == size - 1)
            {
                cout << a[i];
                n = n - b[i];
                size--;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int a,b,s=0;
cin>>a>>b;
int arr[b];
for(int i=0; i<b; i++)
{
cin>>arr[i];

}

for(int j=0; j<b; j++)
{
 s=s+arr[j];

}


 if(a>=s)
 {cout<<a-s;
 }
 else{
  cout<<-1;

 }
 }


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
ll N,p[111];

ll i,sum,sub;
int main(){
    scanf("%lld",&N);
    fornum(i,0,N){
        scanf("%lld", &p[i]);
    }
    
    fornum(i,0,N){
        sum += p[i];
        if(sub<p[i]/2){
            sub = p[i] / 2;
        }
    }

    printf("%lld", sum-sub);

    return 0;
}

Measured memory_bytes: 256
import sys,heapq
#これを加える！！！！
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

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

res = [0]*(n+1)
head = a[:n:]
heapq.heapify(head)
p = sum(head)
for i in range(n+1):
    res[i] = p
    p += a[n+i]
    heapq.heappush(head,a[n+i])
    p -= heapq.heappop(head)
end = a[2*n::]
heapq._heapify_max(end)
q = sum(end)
for i in range(n+1):
    res[n-i] -= q
    q += a[2*n-1-i]
    _heappush_max(end,a[2*n-1-i])
    q -= _heappop_max(end)
print(max(res))

Measured memory_bytes: 37212
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b){
     if (a < b) { a = b; return true; } return false;
}

template<class T> inline bool chmin(T& a, T b){
    if (a > b) { a = b; return true; } return false;
}
const long long INF = 1LL<<60;

int main(){
    int N;
    long long W;
    long long K;
    
    cin >> N >> W;
    int maxValue = (int)pow(10, 3);
    long long dp[N+1][maxValue*N + 1];
    for(int i=0;i<N+1;i++){
        for(int j=0;j<=maxValue*N;j++){
            dp[i][j] = INF;
        }
    }
    long long weight[N], value[N];
    for(int i=0;i<N;i++){cin >> weight[i] >> value[i];}

    // dp
    dp[0][0] = 0;
    for(int i=0;i<N;i++){
        for(int sum_v=0;sum_v<=maxValue*N;sum_v++){
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
            if(sum_v - value[i] >= 0){
                chmin(dp[i+1][sum_v], dp[i][sum_v-value[i]]+weight[i]);
            }
            // cout << dp[i+1][sum_v] << " " << sum_v << " " << sum_v-value[i] << endl;
            
        }
    }

    long long ans=-1;
    for(int sum_v=0;sum_v<=maxValue*N;sum_v++){
        if(dp[N][sum_v] <= W){
            // cout << dp[N][sum_v] << endl;
            ans = sum_v;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79104
import sys
input = sys.stdin.readline


def main():
    n, a, b = map(int, input().split())
    div, mod = n // (a+b), n % (a+b)
    ans = a * div
    if mod >= a:
        ans += a
    else:
        ans += mod
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll n, q, tot = 0;

vector<pii> rowBound, colBound;//x, value sorted descending

void processRows(vi rows) {
	sort(rows.begin(), rows.end());
	if (colBound.empty()) {
		rowBound.pb(mp(rows[0], n - 2));
		tot += (ll)rows.size() * (n - 2);
	}
	else {
		if (rowBound.empty()) {
			rowBound.pb(mp(rows[0], colBound.back().first - 2));
			tot += (ll)rows.size() * (colBound.back().first - 2);
		}
		else {
			if (rows[0] < rowBound.back().first) {
				rowBound.pb(mp(rows[0], colBound.back().first - 2));
			}
			int mySz = rows.size(), i = 0, boundInd = rowBound.size() - 1;
			while (i < mySz) {
				while (boundInd >= 0 && rowBound[boundInd].first <= rows[i]) {
					boundInd--;
				}
				tot += rowBound[boundInd + 1].second;
				i++;
			}
		}
	}
}

void processCols(vi cols) {
	sort(cols.begin(), cols.end());
	if (rowBound.empty()) {
		colBound.pb(mp(cols[0], n - 2));
		tot += (ll)cols.size() * (n - 2);
	}
	else {
		if (colBound.empty()) {
			colBound.pb(mp(cols[0], rowBound.back().first - 2));
			tot += (ll)cols.size() * (rowBound.back().first - 2);
		}
		else {
			if (cols[0] < colBound.back().first) {
				colBound.pb(mp(cols[0], rowBound.back().first - 2));
			}
			int mySz = cols.size(), i = 0, boundInd = colBound.size() - 1;
			while (i < mySz) {
				while (boundInd >= 0 && colBound[boundInd].first <= cols[i]) {
					boundInd--;
				}
				tot += colBound[boundInd + 1].second;
				i++;
			}
		}
	}
}

int main() {
	fast;
	cin >> n >> q;
	int type, x, prv = -1;
	vi cur;
	foru(i, 0, q) {
		cin >> type >> x;
		if (i&&prv != type) {
			if (prv == 1)processRows(cur);
			else processCols(cur);
			cur.clear();
		}
		cur.pb(x);
		prv = type;
	}
	if (!cur.empty()) {
		if (prv == 1)processRows(cur);
		else processCols(cur);
	}
	cout << (n - 2) * (n - 2) - tot << endl;
	return 0;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it.fi<<" "<<it.se<<endl;}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
//#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int32_t main()
{
 io
int n;
cin>>n;

cout<<(powe(10,n)+powe(8,n)+mod-(2*powe(9,n))%mod)%mod<<endl;



}


Measured memory_bytes: 3604