akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

typedef tuple<int, int, ll> tup;
vector<tup> edges;

int n, m;
ll p;
Vl d;
Vb loop, accessible;

void init()
{
	cin >> n >> m >> p;

	d.resize(n, -linf);
	d[0] = 0;
	accessible.resize(n, false);	
	accessible[0] = true;
	loop.resize(n, false);

	edges.reserve(m);
	REP(i, m)
	{
		int a, b; ll c; cin >> a >> b >> c;
		--a; --b;
		c -= p;
		edges.emplace_back(tup(a, b, c));
	}
}

void pseudo_BellmanFord()
{
	REP(_i, n - 1)
		for (tup edge : edges)
		{
			int a = get<0>(edge);
			int b = get<1>(edge);
			ll c = get<2>(edge);
			chmax(d[b], d[a] + c);

			if (!a || accessible[a])
				accessible[b] = true;
		}

	REP(_i, n)
		for (tup edge : edges)
		{
			int a = get<0>(edge);
			int b = get<1>(edge);
			ll c = get<2>(edge);

			if (chmax(d[b], d[a] + c))
			{
				if (accessible[b])
					loop[b] = true;
			}

			if (accessible[a] && loop[a])
				loop[b] = true;
		}
}


int main()
{
	init();

	pseudo_BellmanFord();

	if (loop[n - 1])
	{
		cout << -1 << endl;
		return 0;
	}

	if (d[n - 1] < 0)
		cout << 0 << endl;
	else
		cout << d[n - 1] << endl;	
}


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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

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

	int N; cin >> N;
	vector<pair<int,int> > ver(N);
	
	rep(i, N) { 
		cin >> ver[i].first; 
		ver[i].second = i;
	}

	vector<pair<int, int> > S = ver;
	sort(S.rbegin(), S.rend());

	rep(x,N) {
		rep(y,N) {
			if (ver[x]!=S[y]) {
				cout << S[y].first << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 4736
#include<iostream>
using namespace std;
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h != 0 && w != 0) {
			for (int j = 0; j < h; j++) {
				for (int i = 0; i < w; i++) {
					if (j == 0||j==h-1) {
						cout << '#';
					}
					else {
						if (i == 0 || i == w - 1) {
							cout << '#';
						}
						else {
							cout << '.';
						}
						
					}
				}
				cout << endl;
			}
			cout << endl;
		}
		if (h == 0 && w == 0) { break; }
	}
	return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  int plan1, plan2;
  plan1 = a * n;
  plan2 = b;
  
  if (plan1 < plan2) {
    cout << plan1 << endl;
  }
  else {
    cout << plan2 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

const long long mod = 1000000007;

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

  string S;
  cin >> S;

  vector<int> left(N), right(N);

  for (int i = 0; i < N; i++) {
    if (i > 0) {
      left[i] = left[i - 1];
    }
    if (S[i] == '#') {
      left[i]++;
    }
  }

  for (int i = N - 1; i >= 0; i--) {
    if (i < N - 1) {
      right[i] = right[i + 1];
    }
    if (S[i] == '.') {
      right[i]++;
    }
  }

  int best = min(left[N - 1], right[0]);
  for (int i = 0; i < N - 1; i++) {
    best = min(best, left[i] + right[i + 1]);
  }

  cout << best << endl;

  return 0;
}


Measured memory_bytes: 2180
import sys

sys.setrecursionlimit(1000000)

n = int(input())

ulist = []

for _ in range(n+1):
    ulist.append([])

vlist = [False]*(n+1)

for _ in range(1,n):
    u, v, w = map(int, input().split())
    ulist[u].append([v,w])
    ulist[v].append([u,w])

def check(checkV, fromV):
    for data in ulist[checkV]:
        if data[0] != fromV:
            vlist[data[0]] = vlist[checkV] if data[1] % 2 == 0 else not vlist[checkV]
            check(data[0], checkV)

check(1, 0)

for i in range(1,n+1):
    print(1 if vlist[i] else 0)


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int cnt0 = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) cnt0 += (s[i] == '1');
        else cnt0 += (s[i] == '0');
    }

    int cnt1 = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) cnt1 += (s[i] == '1');
        else cnt1 += (s[i] == '0');
    }
    cout << min(cnt0, cnt1) << endl;
    return 0;
}

Measured memory_bytes: 512
x,n=map(int,input('').split(' '))
p=input('')
if n==0:
    print(x)
else:
    p=p.split(' ')
    for a in range(n):
        p[a]=int(p[a])

    l=400
    sok=0
    for a in range(102):
        ok=1
        for b in range(n):
            if p[b]==a:
                ok=ok*0
            else:
                ok=ok*1
                sok=1

        if ok==1:
            if abs(a-x)<abs(l-x):
                l=a
            elif abs(a-x)==abs(l-x):
                if a<l:
                    l=a
                elif a>l:
                    l=l


    print(l)   

Measured memory_bytes: 9196
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e18 + 7;
const double pi = acos(-1);

vector<pii> arr[2000000 + 10];

void solve() {
	//soln
	int n;
	cin >> n;
	int dif = 0, dif2 = 0;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		deque<char> d;
		for(int j = 0; j < s.size(); j++) {
			if(!d.empty() && s[j] == ')' && d.back() == '(') {
				d.pop_back();
			} else {
				d.pb(s[j]);
			}
		}
		if(!d.empty() && d[0] == '(') {
			dif += d.size();	
		} else {
			int cl = 0, op = 0;
			for(int j = 0; j < d.size(); j++) {
				if(d[j] == ')') {
					cl++;
				} else {
					op++;
				}
			}
			if(!op) {
				dif2 += cl;
			} else {
				arr[1000000 + op - cl].pb({cl, op});		
			}
		}
	}

	multiset<pii> prd;

	for(int i = 1000000; i <= 2000000; i++) {
		for(auto it: arr[i]) {
			prd.insert(it);						
		}
	}
	while(!prd.empty()) {
		pii xx = *prd.begin();
		if(dif >= xx.fr) {
			dif = dif - xx.fr + xx.sc; prd.erase(prd.lower_bound(xx));		        		
		} else {
			cout << "No";
			return;
		}
	}
	for(int i = 1000000; i >= 0; i--) {
		for(auto it: arr[i]) {
			if(dif >= it.fr) {
				dif = dif - it.fr + it.sc;				
			} else {
				cout << "No" << endl;
				return;
			}
		}
	}
	dif -= dif2;
	if(dif == 0) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}



Measured memory_bytes: 66000
#include <bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef int64_t in;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

int main(){
    string s; cin >> s;
    int left = 0;
    int right = 0;
    left = (int)(s[0]-'0')*10 + (int)(s[1]-'0');
    right = (int)(s[2]-'0')*10 + (int)(s[3]-'0');
    //cout << left << " " << right << "\n";
    if(left > 12 || left == 0){
        if(right > 12 || right == 0){
            cout << "NA" << "\n";
        }else{
            cout << "YYMM" << "\n";
        }
    }else{
        if(right > 12 || right == 0){
            cout << "MMYY" << "\n";
        }else{
            cout << "AMBIGUOUS" << "\n";
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int is_valid(int i, int j, int h, int w) {
  return 0 <= i and i < h and 0 <= j and j < w;
}

int main() { IO;
  int h, w;
  cin >> h >> w;

  vector<string> grid(h);
  for (auto &x : grid) cin >> x;
  
  int i = 0, j = 0;
  while (true) {
    grid[i][j] = '.';
    bool move = false;

    if (is_valid(i + 1, j, h, w) and grid[i + 1][j] == '#') {
      i = i + 1;
      j = j;
      move = true;
    } else if (is_valid(i, j + 1, h, w) and grid[i][j + 1] == '#') {
      i = i;
      j = j + 1;
      move = true;
    }

    if (!move) break;
    move = true;
  }

  int cnt = 0;
  for (auto &x : grid) {
    cnt += count(x.begin(), x.end(), '#');
  }

  if (cnt == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
     
    int main(void){
     
      int a,b;
      int i;
     
      scanf("%d %d",&a,&b);
     
      if(a <= 5){
        i = 0;
      } else if(a >= 6 && a <= 12){
        i = b/2;
      } else {
        i = b;
      }
     
      printf("%d",i);
    }

Measured memory_bytes: 1680
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,d;
    cin>>n>>d;
    d=2*d+1;
    cout<<(n+d-1)/d<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int input;
	cin >> input;
	int A, B, C, D;
	A = input / 1000;
	B = (input % 1000) / 100;
	C = (input % 100) / 10;
	D = input % 10;
	if ((A + B + C + D) == 7)cout << A << "+" << B << "+" << C << "+" << D << "=" << 7 <<endl;
	else if ((A + B + C - D) == 7)cout << A << "+" << B << "+" << C << "-" << D << "=" << 7 << endl;
	else if ((A + B - C + D) == 7)cout << A << "+" << B << "-" << C << "+" << D << "=" << 7 << endl;
	else if ((A + B - C - D) == 7)cout << A << "+" << B << "-" << C << "-" << D << "=" << 7 << endl;
	else if ((A - B + C + D) == 7)cout << A << "-" << B << "+" << C << "+" << D << "=" << 7 << endl;
	else if ((A - B + C - D) == 7)cout << A << "-" << B << "+" << C << "-" << D << "=" << 7 << endl;
	else if ((A - B - C + D) == 7)cout << A << "-" << B << "-" << C << "+" << D << "=" << 7 << endl;
	else if ((A - B - C - D) == 7)cout << A << "-" << B << "-" << C << "-" << D << "=" << 7 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n; cin>>n;
  vector<ll> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  if(num[0]!=0){
    cout<<-1<<endl;
    return 0;
  }ll ans=0;
  if(n==2){
    if(num[1]==0){
      cout<<0<<endl;
      return 0;
    }else if(num[1]==1){
      cout<<1<<endl;
      return 0;
    }else {
      cout<<-1<<endl;
      return 0;
    }
  }
  for(int i=1;i<n-1;i++){
    if(num[i]>i){
      cout<<-1<<endl;
      return 0;
    }
    if(num[i]<num[i+1]){
      if(num[i+1]-num[i]!=1){
        cout<<-1<<endl;
        return 0;
      }else if(i+1==n-1){
        ans+=num[i+1];
      }
    }else{
      ans+=num[i];
      if(i+1==n-1){
        ans+=num[i+1];
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 107;
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;
    cout << n * n;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("in.in", "r", stdin); freopen("out.out", "w", stdout);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {cout << "Case #" << i << ": "; solve();}
    solve();
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
int main(){
  string S;
  cin>>S;
  int count1=0,count2=0;
  rep(i,0,S.size()){
    if(i%2==0){
      if(S.at(i)=='0') count1++;
      else count2++;
    }
    else{
      if(S.at(i)=='0') count2++;
      else count1++;
    }
  }
  cout<<min(count2,count1)<<endl;
}



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

#define HEAD 10000

int *p, *upstep;

void unite(int, int);
int same(int, int);
void makeSet(int);
void link(int, int);
int findSet(int);

int main(){
  int i, x, y, n, q;
  int *a;
  int com;

  scanf("%d %d", &n, &q);

  p = (int *)malloc(n*sizeof(int));
  upstep = (int *)malloc(n*sizeof(int));

  a = (int *)malloc(q * sizeof(int));

  for(i  = 0;i < q;i ++)
    {
      a[i] = HEAD;
    }

  for(i = 0;i < n;i ++)
    {
      makeSet(i);
    }

  for(i = 0;i < q;i ++)
    {
      scanf("%d %d %d", &com, &x, &y);
      if(com == 0)
	{
	  unite(x, y);
        }else if(com == 1)
	{
	  a[i] = same(x, y);
	}
    }

  for(i = 0;i < q;i ++)
    {
      if(a[i] != HEAD){
	printf("%d\n", a[i]);
      }
    }
  return 0;
}
   
void makeSet(int x)
{
  p[x] = x;
  upstep[x]=0;
}
    
void unite(int x, int y)
{
  link(findSet(x),findSet(y));
}
    
void link(int x, int y)
{
  if(upstep[x] > upstep[y])
    {
      p[y] = x;
    }
  else{
    p[x] = y;

    if(upstep[x] == upstep[y])
      {
	upstep[y] = upstep[x];
      }
  }
}
    
int findSet(int x)
{
  if(x!=p[x]) p[x] = findSet(p[x]);
  return p[x];
}
    
int same(int x, int y)
{
  if(findSet(x) == findSet(y)) return 1;
  else return 0;
}
    



Measured memory_bytes: 2176
import math

N,K=map(int,input().split())

if K==1:
    print(1)
    exit()

if N<K:
    P=0
    for i in range(1,N+1):
        temp=math.log2(K/i)
        x=math.ceil(temp)
        P+=(1/N)*(1/2)**x
else:
    P=(N-(K-1))/N
    for i in range(1,K):
        temp=math.log2(K/i)
        x=math.ceil(temp)
        P+=(1/N)*(1/2)**x
print(P)



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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(false);\
				cin.tie(0);\
				cout.tie(0)
#define REP(_i, _a) for(int _i = 0; _i < (int)_a; ++_i)
#define FOR(_i, _a, _b) for(int _i = (int)_a; _i <= (int)_b; ++_i)
#define FORD(_i, _a, _b) for(int _i = (int)_a; _i >= (int)_b; --_i)
#define RESET(_a, _value) fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define ALL(_a) _a.begin(), _a.end()
#define SIZE(_a) _a.size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define newline '\n';

// DEBUG UTIL
#define DEBUG(args...) { cerr << "> "; \
						 string _s = #args; \
						 replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); istream_iterator<string> _it(_ss); \
						 err(_it, args); }

void err(istream_iterator<string> it) { cerr << endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << ": " << a << " ";
	err(++it, args...);
}

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int INF = 2e9;

int a, b;

void test() {

}

void read() {
	cin >> a >> b;
	b = max(a-1, b);
}

void solve() {
	int ans = 0;
	FOR(i, 1, a) {
		if (i <= b) ++ans;
	}
	cout << ans << endl;
}

int main() {
	FAST_IO;
	
	test();

	int TC = 1;
	// cin >> TC;
	FOR(tc, 1, TC) {
		read();
		solve();
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int X;
    cin >> X;
    cout << 8 - (X - 400) / 200 << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
	int x1, y1, x2, y2;
	
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	
	printf("%d %d %d %d", x2+(y1-y2), y2-(x1-x2), x1+(y1-y2), y1-(x1-x2));
	
	return 0;
}

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

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

  vector<long long> w(N);
  vector<int> v(N);
  for (int i = 0; i < N; i++)
  {
    cin >> w[i] >> v[i];
  }

  const long long INF = 1e12;
  long long dp[N+1][100009];
  for (int j = 0; j <= 100000; j++)
  {
    dp[0][j] = INF;
  }
  dp[0][0] = 0;
  for (int i = 1; i <= N; i++)
  {
    for (int j = 0; j <= 100000; j++)
    {
      if(j-v[i-1]>=0){
        dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
      }
      else{
        dp[i][j] = dp[i-1][j];
      }
    }
  }

  int ans = 0;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; j <= 100000; j++)
    {
      if(dp[i][j]<=W) ans = max(ans,j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 79104
#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>

int main() {
    std::vector<int> v(3);
    int x = 0;
    for (int i = 0; i < 3; ++i) {
        std::cin >> x;
        v[i] = x;
    }

    int ret = std::numeric_limits<int>::max();
    for (int i = 0; i < 2; ++i) {
        for (int j = i + 1; j < 3; ++j) {
            ret = std::min(ret, v[i] + v[j]);
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
long long int gcm(long long int a,long long int b)
{
	if(b == 0)
	{
		return a;
	}
	return gcm(b,a%b);
}
int main(){
	long long int k;
	long long int ans = 0;
	cin >> k;
	for(int i = 0;i < k;i++){
		for(int j = 0;j < k;j++){
			for(int l = 0;l < k;l++){
				ans += gcm(i + 1, gcm(j + 1, l + 1));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
import * as fs from "fs";

let X = fs.readFileSync("/dev/stdin", "utf8").trim();

let answer: string[] = [];

for(let i=0; i<X.length; i++) {
    if (X[i] == 'T') {
        let j = answer.length-1;
        if (j >= 0 && answer[j] == 'S') {
            answer.pop()
        } else {
            answer.push(X[i]);
        }
    } else {
        answer.push(X[i]);
    }
}

console.log(answer.length);


Measured memory_bytes: 37896
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int N = sc.nextInt(), K = sc.nextInt();
        ArrayList<Long> H = new ArrayList<>();
        H.ensureCapacity(N);

        for (int i = 0; i < N; i++) {
            H.add(sc.nextLong());
        }

        Collections.sort(H, Collections.reverseOrder());

        long ans = 0;
        for (long i : H) {
            if (K > 0) {
                K--;
            } else {
                ans += i;
            }
        }

        out.println(ans);

        out.close();
    }


    public static PrintWriter out;

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}


Measured memory_bytes: 58676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a+b>=10){
    cout<<"error"<<endl;
  }else{
    cout<<a+b<<endl;
  }
}


Measured memory_bytes: 768
#include<stdio.h>
int n, m;
char p[610][610], q[610][610], r[610][610];
int main(){
    int i, j, k;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        scanf("%s",p[i]+1);
        for(j=1;j<=m;j++)q[i][j]=r[i][j]='.';
        if(i%2==1){
            for(j=1;j<m;j++)q[i][j] = '#';
            r[i][m] = '#';
        }
        else{
            for(j=2;j<=m;j++)r[i][j] = '#';
            q[i][1] = '#';
        }
        for(j=1;j<=m;j++)if(p[i][j]=='#')q[i][j]=r[i][j]='#';
    }
    for(i=1;i<=n;i++)printf("%s\n",q[i]+1);
    printf("\n");
    for(i=1;i<=n;i++)printf("%s\n",r[i]+1);
}


Measured memory_bytes: 1536
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int r,c,k;
  cin>>r>>c>>k;
  auto dp = vec<ll>(5,r,c);
  auto a = vec<ll>(r,c);
  rep(_,k){
    int i,j,v;
    cin>>i>>j>>v;
    i--;j--;
    chmax<ll>(a[i][j],v);
  }

  ll ans = 0;
  rep(i,r){
    rep(j,c){
      if(j-1>=0){
        chmax(dp[1][i][j],max(dp[0][i][j-1]+a[i][j],dp[1][i][j-1]));
        chmax(dp[2][i][j],max(dp[1][i][j-1]+a[i][j],dp[2][i][j-1]));
        chmax(dp[3][i][j],max(dp[2][i][j-1]+a[i][j],dp[3][i][j-1]));
      }
      if(i-1>=0){
        chmax(dp[0][i][j],dp[0][i-1][j]);
        chmax(dp[0][i][j],dp[1][i-1][j]);
        chmax(dp[0][i][j],dp[2][i-1][j]);
        chmax(dp[0][i][j],dp[3][i-1][j]);
      }
      chmax(dp[1][i][j],dp[0][i][j]+a[i][j]);
      chmax(ans,max({dp[0][i][j],dp[1][i][j],dp[2][i][j],dp[3][i][j]}));
    }
  }
  cout<<(ans)<<endl;

}


Measured memory_bytes: 425756
#include<iostream>
using namespace std;
int main(){
  int x1,x2,x3,x4,y1,y2,y3,y4,cx,cy;
  cin>>x1>>y1>>x2>>y2;
  cx=x1-x2;
  cy=y1-y2;
  x4=x1+cy;
  y4=y1-cx;
  x3=x2+cy;
  y3=y2-cx;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
h = gets.split.map!{|i| i.to_i}

h << 0
c = 0

while h.size > 1 do

    for i in 0..h.size-1
        if h[i] <= 0
            if i == 0
                h[i] = nil
                next
            end

            if h[i-1] == nil || h[i-1] <= 0
                h[i-1] = nil
                next
            end

            c += 1
        end
    end

    h.compact!
    h.map!{|i| i -= 1}

end

puts c

Measured memory_bytes: 1788
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;

fn main() {
    input! {
        n: isize,
        txy: [(isize, isize, isize);n],
    }

    let mut cur = (0, 0);
    let mut now = 0;
    for (t, x, y) in txy {
        let dt = t - now;
        let diff = (cur.0 - x).abs() + (cur.1 - y).abs();
        //println!("{}, ({}, {}) -> {}, ({}, {}) [{} {}]", now, cur.0, cur.1, t, x, y, dt, diff);
        if diff > dt || (dt - diff) % 2 == 1 {
            println!("No");
            //println!("{} {}", diff<dt, (diff-dt)%2==1);
            return;
        }
        cur = (x, y);
        now = t;
    }
    println!("Yes");
}


Measured memory_bytes: 8444
def fib(F, n):
    if n == 0:
        return 1    
    if n == 1:
        return 1
    else:
        F.append(fib(F, n-1) + F[n-2])
        return F[n]

n = int(input())
F = [1, 1]
ans = fib(F, n)
print(str(ans))




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

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

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(var,start,stop,step) for(long long var=start;var<stop;var+=step)
#define vi vector<int>
#define vl vector<long long>
#define fio  cin.tie(nullptr); ios::sync_with_stdio(false); cout.tie(nullptr);
 
int main()
{
    fio;
    ll n;cin>>n;
    vi v(n);
    ll sum=0;
    map<ll,ll> m;
    loop(i,0,n,1)
    {
        cin>>v[i];
        sum+=v[i];
        m[v[i]]++;
    }
    ll q;cin>>q;
    loop(i,0,q,1)
    {
        ll old,ne;
        cin>>old>>ne;
        sum-=m[old]*old;
        sum+=ne*m[old];cout<<sum<<endl;
        m[ne]+=m[old];
        m.erase(old);
    }
    return 0;
}

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

using namespace std;
int n, k;
vector < pair < int, int > > v;
int main(){
    cin >> n >> k;
    if((n - 1) * (n - 2) / 2 < k){
        cout << -1;
        return 0;
    }
    for(int i = 2; i <= n; i++){
        v.push_back({i, 1});
    }
    int kol = (n - 1) * (n - 2) / 2 - k;
    for(int i = 2; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(!kol){
                break;
            }
            v.push_back({i, j});
            kol--;
        }
        if(!kol){
            break;
        }
    }
    cout << v.size() << '\n';
    for(auto to : v){
        cout << to.first << " " << to.second << '\n';
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c;
    cin>>a>>b>>c;
    if(a.back()==b.front() && b.back()==c.front()){
      cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n];
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = in.nextInt();
		}
		for(int i=0;i<n;i++) {
			a[i] = Integer.MAX_VALUE;
		}
		a[0] = 0;
		for(int i=0;i<n;i++) {
			for(int j=1;j<=k&&i+j<n;j++) {
				a[i+j] = Math.min(a[i+j], a[i]+Math.abs(h[i]-h[i+j]));
			}
		}
		System.out.println(a[n-1]);
	}
}

Measured memory_bytes: 60132
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int x, a, b;
    cin >> x >> a >> b;
    if( 0 >= b - a){
        cout << "delicious" << endl;
    }else if(b - a <= x){
        cout << "safe" << endl;
    }else if(b-a > x){
        cout << "dangerous" << endl;
    }
    return 0;
}


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

C = [[] for i in range(10**5+10)]

for i in range(n):
    C[B[i][0]].append(B[i][1])
for i in range(len(C)):
    C[i].sort(reverse=1)

#print(C[:10])
notst=1
st=0
ans = 0

Bl = [0 for i in range(10**4+2)]
for i in range(1, m+1):
    for j in range(len(C[i])):
        Bl[C[i][j]] += 1
    if notst == 1 and len(C[i]) > 0:
        notst = 0
        st = C[i][0]
    if notst == 0 and len(C[i]) > 0:
        if st < C[i][0]:
            st = C[i][0]
    while st > 0 and Bl[st] == 0:
        st -= 1
    ans += st
    # print(ans)
    # print(Bl[:10])
    Bl[st] -= 1

print(ans)

    
    

Measured memory_bytes: 75736
#include"bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> & l, const pair<T1, T2> & r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> & l, const pair<T1, T2> & r) { return make_pair(l.first - r.first, l.second - r.second); }


int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	lint N;
	cin >> N;
	vector<lint> vec(N);
	lint sum = 0, A;
	map<lint, lint> cnt;
	cnt[0] = 1;
	REP(i, N) {
		cin >> A;
		sum += A;
		if (cnt.find(sum) == cnt.end()) cnt[sum] = 1;
		else cnt[sum]++;
	}
	lint ans = 0;
	for (auto item : cnt)
	{
		ans += (item.second - 1) * item.second / 2;
	}
	cout << ans;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define Q int tc; scanf("%d",&tc);cin.ignore(); for(int q=1;q<=tc;q++)
typedef long long int ll;
#define MAX 100000

int main()
{
    ll x;
    cin>>x;
    double ans=(-1+sqrt(1+8*x))/2;
    cout<<ceil(ans);
}



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

int main(){
    int N;
    string S,T="ABC";
    cin>>N>>S;
    int cnt=0;
    for(int i = 0;i<N-2;i++){
        if(S[i]==T[0]){
            if(S[i+1]==T[1]){
                if(S[i+2]==T[2]){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int LCS(string A, string B)
{
    int s1 = A.size();
    int s2 = B.size();
    int X[s1 + 1][s2 + 2];
    for (int i = 0; i < s1+1; i++)
    {
        for (int j = 0; j < s2+1; j++)
        {
            if (i > 0 && j > 0)
            {
                if (A[i-1] == B[j-1])
                {
                    X[i][j] = max(X[i - 1][j - 1] + 1, max(X[i][j - 1], X[i - 1][j]));
                }
                else
                {
                    X[i][j] = max(X[i - 1][j], X[i][j - 1]);
                }
            }
            else
            {
                X[i][j] = 0;
            }
        }
    }
    int N = X[s1][s2];
    return N;
}
int main()
{
    int N;
    cin >> N;
    for(int i = 1; i < N + 1; i++){
        string A;
        string B;
        cin >> A;
        cin >> B;
        cout << LCS(A,B) << endl;
    }
    return 0;
}


Measured memory_bytes: 7084
n, m, l = map(int, input().split())
A = []
B = []
for _ in range(n):
    A.append(list(map(int, input().split())))
for _ in range(m):
    B.append(list(map(int, input().split())))
C = [[0 for _ in range(l)] for _ in range(n)]
for i in range(n):
    for j in range(l):
        s = 0
        for k in range(m):
            s += A[i][k] * B[k][j]
        C[i][j] = s

for row in C:
    print(' '.join(list(map(str, row))))



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

int main(){
  char s;
  cin >> s;
  if(s == toupper(s)) cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
 
long int compare_int(const void *a, const void *b)
{
    return *(long int*)a - *(long int*)b;
}
 
long int binary_search_right(long int list[], long int list_size, long int x){
    long int left, right, mid;
    left = 0;
    right = list_size - 1;
 
    while (left <= right) {
        mid = (left + right)/2;
        if(list[left] < x && x <= list[right] && right - left == 1){
            return left;
        }else if(list[mid] < x){
            left = mid;
        }
        else{
            right = mid;
        }
    }
    while(1){
        printf("error");
    }
}
 
long int binary_search_left(long int list[], long int list_size, long int x){
    long int left, right, mid;
    left = 0;
    right = list_size - 1;
 
    while (left <= right) {
        mid = (left + right)/2;
        if(list[left] <= x && x < list[right]&& right - left == 1){
            return right;
        }else if(list[mid] <= x){
            left = mid;
        }
        else{
            right = mid;
        }
    }
    while(1){
        printf("error");
    }
}
 
int main(void){
    long int n, i;
    scanf("%d", &n);
    long int a[100001], b[100001], c[100001];
    for(i = 0; i < n; i++){scanf("%ld", &a[i]);}
    for(i = 0; i < n; i++){scanf("%ld", &b[i]);}
    for(i = 0; i < n; i++){scanf("%ld", &c[i]);}
 
    qsort(a, n, sizeof(long int), compare_int);
    qsort(c, n, sizeof(long int), compare_int);
 
    long int a_b, b_c, k;
    long int tmp;
    long int ans = 0;
    if(n == 1){
        if(a[0] < b[0] && b[0] < c[0]){
            printf("1\n");
            return 0;
        }else{
            printf("0\n");
            return 0;
        }
    }
 
    for(i = 0; i < n; i++){
        if(b[i] > a[n - 1]){
            a_b = n;
        }else if(b[i] <= a[0]){
            a_b = 0;
        }else{
            a_b = binary_search_right(a, n, b[i]) + 1;//(条件を満たす最大の配置番号＋１)通りがある
        }
 
        if(b[i] >= c[n - 1]){
            b_c = 0;
        }else if(b[i] < c[0]){
            b_c = n;
        }else{
            b_c = n - binary_search_left(c, n, b[i]);
        }
        ans = ans +  a_b * b_c;
    }
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 4844
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

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

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

class C {
	int d, target;
	int mask{ 0 };
	vector<vector<int>> problems;
public:
	C()
	{
		cin >> d >> target;
		problems.resize(d, vector<int>(2));
		
		REP(i, d)
		{
			mask |= (1 << i);
			cin >> problems[i][0] >> problems[i][1];
			problems[i][1] += 100 * (i + 1) * problems[i][0];
		}
	}

	void solve()
	{

		int ans{ 2000 };
		int sum;
		int n_questions;

		for (int bit{ 0 }; bit < (1 << d); bit++)
		{
			sum = n_questions = 0;

			for (int b{ 0 }; b < d; b++)
				if (bit & (1 << b))
				{
					sum += problems[b][1];
					n_questions += problems[b][0];
				}

			if (sum >= target)
			{
				chmin(ans, n_questions);
				continue;
			}
			else
			{
				int notUsed{ mask ^ bit };
					// look for highest bit that is zero
				for (int b{ d - 1 }; b >= 0; b--)
				{
					if (notUsed & (1 << b))
					{
						// find out how many questions we need to the target
						int needMore{ ceil(((double)target - sum) / 100 / (b + 1)) };

						// if the number does not exceed existing qustions update ans
						if (needMore <= problems[b][0])
							chmin(ans, n_questions + needMore);

						break;
					}
				}
			}
		}

		cout << ans << endl;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

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

int main() {
  int A,B,C,X,Y,cost1,cost2,cost3;
  cin >> A >> B >> C >> X >> Y;
  
  cost1=A*X+B*Y;
  cost2=2*C*max(X,Y);
  if(X>=Y){
    cost3=2*C*Y+(X-Y)*A;
  }
  else{
    cost3=2*C*X+(Y-X)*B;
  }
  cout << min({cost1,cost2,cost3}) << endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    int N, K;
    cin >> N >> K;
    ll x[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    ll ans = llmax;
    for (int i = K - 1; i < N; i++) {
        ll d = llmax;
        if (x[i] <= 0) {
            d = abs(x[i - (K - 1)]);
        } else if (x[i - (K - 1)] >= 0) {
            d = x[i];
        } else {
            d = min(abs(x[i]), abs(x[i - (K - 1)])) + x[i] - x[i - (K - 1)];
        }
        if (d < ans) {
            ans = d;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

template<class comp>
class sum_pri_queue : public priority_queue<ll, deque<ll>, comp> {
private:
    ll ss = 0;
public:
    void push2(ll n) {
        this->push(n);
        ss += n;
    }

    ll pop2() {
        auto r = this->top();
        ss -= r;
        this->pop();
        return r;
    }

    ll sum() {
        return ss;
    }
};

int main() {
    ll a, b, c, p = 0, q;
    cin >> q;
    sum_pri_queue<greater<>> bigger;
    sum_pri_queue<less<>> smaller;
    for (ll i = 0; i < q; i++) {
        cin >> c;
        if (c == 1) {
            cin >> a >> b;
            p += b;
            if (bigger.size() == smaller.size()) smaller.push2(a);
            else bigger.push2(a);
            while ((!bigger.empty()) && smaller.top() > bigger.top()) {
                smaller.push2(bigger.pop2());
                bigger.push2(smaller.pop2());
            }
        } else if (c == 2) {
            ll center = smaller.top();
            ll r = center * smaller.size() - smaller.sum() + bigger.sum() - center * bigger.size();
            cout << center << ' ' << r + p << endl;
        } else throw;
    }
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<math.h>

int main(){
	
	int N,A,B,C,D,i,j,k;
	char op1,op2,op3;
	scanf("%d",&N);
	
	D=N%10;
	N/=10;
	C=N%10;
	N/=10;
	B=N%10;
	N/=10;
	A=N;
	
	for(i=0;i<=1;i++){
		for(j=0;j<=1;j++){
			for(k=0;k<=1;k++){
				if(A+pow(-1,i)*B+pow(-1,j)*C+pow(-1,k)*D==7){
					if(i==0){
						op1='+';
					}else {
						op1='-';
					}
					if(j==0){
						op2='+';
					}else {
						op2='-';
					}
					if(k==0){
						op3='+';
					}else {
						op3='-';
					}
					printf("\n%d%c%d%c%d%c%d=7\n",A,op1,B,op2,C,op3,D);
					return 0;
				}
			}
		}
	}
return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
	long long I, O, T, J, L, S, Z;
	while(cin >> I >> O >> T >> J >> L >> S >> Z){
		long long res = O + 2*(I/2) + 2 * (J/2 + L/2);
		if(I > 0 && J > 0 && L > 0){
			res = max(res, O + 3 + 2 * ((I-1)/2 + (J-1)/2 + (L-1)/2));
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll x,ans=0;
  cin >> x;
  ans += x/11 * 2;
  x %= 11;
  if(x == 0)cout << ans << endl;
  else if(x <= 6)cout << ans + 1 << endl;
  else cout << ans + 2 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    if(h2<h1)
    h2+=24;
    m1+=(60*h1);
    m2+=(60*h2);
    int md=m2-m1;
    cout<<md-k<<"\n";
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<iomanip>
using namespace std;

double pi=3.14159265358979;
int main(){
	double R;
	cin >> R;
	cout << fixed << setprecision(20) << 2*R*pi << endl;
	return 0;
}


Measured memory_bytes: 3788