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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> vec(N);
    vector<long long> ruiseki(N);
    vector<long long> araiguma(N-1);
    vector<long long> balance(N-1);




    for(int i=0;i<N;i++){
        cin>>vec[i];
        if(i==0){
            ruiseki[i]=vec[i];
        }else{
            ruiseki[i]=ruiseki[i-1]+vec[i];
        }
    }

    long long max=ruiseki[N-1];

    ruiseki.pop_back();

    for(int i=0;i<ruiseki.size();i++){
        araiguma[i]=max-ruiseki[i];
    }

    for(int i=0;i<N-1;i++){
        balance[i]=abs(araiguma[i]-ruiseki[i]);
    }

    cout<<*min_element(balance.begin(),balance.end())<<endl;

}

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


int main()
{
    int a,b,x;
    cin >> a >> b >> x;
    int m=a*((x-1)/1000+1);
    for(int i=0;i<(x-1)/1000+1;i++){
        int j=0;
        while(1000*i+500*j<x)
            j++;
        m=min(m,a*i+b*j);
    }
    cout << m << endl;
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<set>
using namespace std;
const int inf=1e8;
typedef pair<int, int> pii;

int main(){

   int N, M;
   cin>> N>> M;
   int a[M], b[M], c[M];
   for(int i=0; i<M; i++) cin>> a[i]>> b[i]>> c[i];

   int g[N][N];
   for(int i=0; i<N; i++) g[i][i]=0;
   for(int i=0; i<N; i++)
      for(int j=0; j<N; j++)
         if(i!=j) g[i][j]=inf;

   for(int i=0; i<M; i++){
      g[a[i]-1][b[i]-1]=c[i];
      g[b[i]-1][a[i]-1]=c[i];
   }

   int next[N][N];
   for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
         next[i][j]=j;
      }
   }
   for(int k=0; k<N; k++){
      for(int i=0; i<N; i++){
         for(int j=0; j<N; j++){
            if(g[i][j]>g[i][k]+g[k][j]){
               g[i][j]=g[i][k]+g[k][j];
               next[i][j]=next[i][k];
            }
         }
      }
   }

   int used[N][N];
   for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
         used[i][j]=0;
      }
   }
   for(int start=0; start<N; start++){
      for(int goal=start+1; goal<N; goal++){
         for(int i=start; i!=goal; i=next[i][goal]){
            used[i][next[i][goal]]=1;
            used[next[i][goal]][i]=1;
         }
      }
   }

   int s=0;
   for(int i=0; i<M; i++){
      if(used[a[i]-1][b[i]-1]) s++;
   }

   cout<< M-s<< endl;

   return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N; cin >> N;
  vi32 v(N + 1);
  reps(i, N) {
    int a; cin >> a;
    v[i] = a;
  }
  int ans = 0;
  reps(i, N) {
    if (i == v[v[i]]) ans++;
  }
  cout << ans / 2 << '\n';
}


Measured memory_bytes: 640
solve = do
    s <- getLine
    let [a, b] = map read . words $ s :: [Int]
    if a == 0 && b == 0 then
        return ()
    else do
        if a <= b then 
            putStrLn $ (show a) ++ " " ++ (show b)
        else
            putStrLn $ (show b) ++ " " ++ (show a)
        solve

main = solve



Measured memory_bytes: 4084
class Dice
  def initialize(t, s, e, w, n, b)
    $north = n
    $south = s
    $east = e
    $west = w
    $top = t
    $bottom = b
  end

  def execute_orders(orders)
    length = orders.length
    for i in 0...length
      if orders[i] == "N"
        move_north
      elsif orders[i] == "S"
        move_south
      elsif orders[i] == "E"
        move_east
      elsif orders[i] == "W"
        move_west
      else
        puts "error!"
      end
    end
  end

  def check_dices_same(order_t, order_s, order_e, order_w, order_n, order_b)
      60.times do
        execute_orders(["N", "W"].sample)
        return true if $top == order_t && $south == order_s && $east == order_e && $west == order_w && $north == order_n && $bottom == order_b
      end
    return false
  end


  private
  def move_north
    north = $north
    south = $south
    top = $top
    bottom = $bottom
    $north = top
    $top = south
    $bottom = north
    $south = bottom
  end

  def move_south
    north = $north
    south = $south
    top = $top
    bottom = $bottom
    $south = top
    $bottom = south
    $north = bottom
    $top = north
  end

  def move_east
    top = $top
    bottom = $bottom
    east = $east
    west = $west
    $east = top
    $bottom = east
    $west = bottom
    $top = west
  end

  def move_west
    top = $top
    bottom = $bottom
    east = $east
    west = $west
    $west = top
    $bottom = west
    $east = bottom
    $top = east
  end
end

dice_numbers_1 = gets.chomp.split.map(&:to_i)
dice_numbers_2 = gets.chomp.split.map(&:to_i)
dice1 = Dice.new(dice_numbers_1[0], dice_numbers_1[1], dice_numbers_1[2], dice_numbers_1[3], dice_numbers_1[4], dice_numbers_1[5])
if dice1.check_dices_same(dice_numbers_2[0], dice_numbers_2[1], dice_numbers_2[2], dice_numbers_2[3], dice_numbers_2[4], dice_numbers_2[5])
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8728
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}

void no() {
    cout << "No" << endl;
    exit(0);
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N;
    cin >> N;
    vector<int> a(N);
    cin >> a;
    map<int, int> mp;
    REP(i, N) mp[a[i]]++;
    if (mp[0] == N) yes();
    vector<int> b;
    for (auto p : mp) b.push_back(p.first);
    SORT(b);
    if (mp[0] * 3 == N) {
        if (b.size() == 2) {
            if (mp[b[1]] * 3 == 2 * N) yes();
            else no();
        } else {
            no();
        }
    } else if (mp[0] == 0) {
        if (b.size() == 4 && mp[b[1]] * 3 == N && mp[b[2]] * 3 == N && mp[b[3]] * 3 == N && (b[1] ^ b[2] ^ b[3]) == 0) yes();
        else no();
    } else {
        no();
    }
    return 0;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
ll dp[100005];
int main()
{
	dhoom;
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	int cnt1[26],cnt2[26];
	for(int i = 1 ; i < n ; i++){
		memset(cnt1 , 0 , sizeof(cnt1));
		memset(cnt2 , 0 , sizeof(cnt2));	
		for(int j = 0 ; j < i ; j++)
			cnt1[s[j] - 'a']++;
		for(int j = i ; j < n ; j++)
			cnt2[s[j] - 'a']++;
		int temp = 0;
		for(int j = 0 ; j < 26 ; j++)
			if(cnt1[j] && cnt2[j])	
				temp++;
		ans = max(temp , ans);
		
	}	
	cout << ans << endl;
	return 0;
} 



Measured memory_bytes: 256
mod = 10 ** 9 + 7
INF = 10 ** 10

N = int(input())
A = [int(input()) for _ in range(N)] + [INF]
B = [int(input()) for _ in range(N)] + [INF]

A.sort()
B.sort()

ans = 1
a = b = 0
i = j = 0
while i < N or j < N:
    if A[i] < B[j]:
        if b > 0:
            ans *= b
            b -= 1
        else:
            a += 1
        i += 1
    else:
        if a > 0:
            ans *= a
            a -= 1
        else:
            b += 1
        j += 1

    ans %= mod

print(ans)

Measured memory_bytes: 11664
n = int(input())
a = list(map(int, input().split()))
s = 0

for i in range(0, n - 1):
    h = a[i] - a[i+1]
    if h > 0:
        s += h
        a[i+1] += h
        # a[i+1] = a[i]

print(str(s))


Measured memory_bytes: 32172
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int n,r;
	
	scanf("%d %d",&n,&r);
	if(n>9){
		printf("%d",r);
	}else{
		printf("%d",r+(100*(10-n)));
	}
	return 0;
}


Measured memory_bytes: 128
A, B = map(int, input().split())

def g(x):
  if x == 0:
    return 0
  elif x == 1:
    return 1
  elif x == 2:
    return 3
  elif x == 3:
    return 0
  k = len(bin(x))-3
  cnt = x - 2 ** k + 1
  bit = cnt % 2
  return (2 ** k * bit) ^ g(x - 2 ** k)

print(g(B) ^ g(max(0, A-1)))

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main(){
  int N,M;
  int A[101];   //インデックスに対応する商品が何票集めてるか
  int sum = 0;  //商品の総得票数
  int cnt = 0;  //得票数が総得票数かける1/4M以上の商品数
  cin >> N >> M;
  
  
  for(int i=1;i<=N;i++){
    cin >> A[i];
    sum += A[i]; //総得票数求める
  }

//得票数が総得票数かける1/4M以上の商品数を数える
  for(int i=1;i<=N;i++){
    if(A[i]*4*M >= sum){
      cnt++;
    }
  }
  
  //cout << cnt;
  
  if(cnt >= M){
    cout << "Yes";
  }else{
    cout << "No";
  }                          
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+ 5;
const int M = 1e7 + 5;
const int INF=1e9+7;
const int mod=1e9+7;
const double eps=1e-9;
typedef long long ll;
typedef pair<int,int>pi;
int T,n,m;
int a[N],b[N],c[N];
vector<int>G;
int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w;
    cin >> t;
    ll dist = abs(a-b);
    if(v <= w){
        cout << "NO";
        return 0;
    }

    ll diff = v-w;
    if(diff*t >= dist){
        cout << "YES";
    } else{
        cout << "NO";
    }

}

Measured memory_bytes: 3636
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
        if(k%2==0)cout<<a-b<<"\n";
        else cout<<b-a<<"\n";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15)
		cout<<"+"<<endl;
	else if(a*b==15)
		cout<<"*"<<endl;
	else
		cout<<"x"<<endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
vector<int> arr[mxn];
int used[mxn];
int n, m, k, q;
string s, t;

void bfs(int node) {
    queue<int> q;
    used[node] = true;
    q.push(node);
    while (q.size()) {
        int curr = q.front();
        q.pop();
        for (int next : arr[curr]) {
            if (!used[next]) {
                used[next] = curr;
                q.push(next);
            }
        }
    }
}

void dfs(int node) {
    used[node] = true;
    for (int next : arr[node])
        if (!used[next])
            dfs(next);
}


void solve() {
    cin >> n >> m;
    for (int i = 0, u, v; i < m; i++) {
        cin >> u >> v;
        arr[u].pb(v);
        arr[v].pb(u);
    }
    int comp = 0;
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            comp++;
            dfs(i);
        }
    }
    if (comp > 1) {
        cout << "No" << endl;
        return;
    }
    for (int i = 0; i <= n; i++) used[i] = 0;
    used[1] = -1;
    bfs(1);
    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++) cout << used[i] << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int A1B1 = A + B;
  int A1A2 = A + (A - 1);
  int B1B2 = B + (B - 1);
  
  if(A1B1 > A1A2){
    if(A1B1 > B1B2){
      cout << A1B1 << endl;
    }
    else{
      cout << B1B2 << endl;
    }
  }
  else{
    if(A1A2 > B1B2){
      cout << A1A2 << endl;
    }
    else{
      cout << B1B2 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

#define INF 1000000009LL

int dp[3005][3005];//dp[i][j]:sがi文字目，tがj文字目まで見たときの最大部分列長

void print_lcs(int a, int b, string s) {
    if (dp[a][b] == 0) return ;
    else {
        if (dp[a][b-1] == dp[a][b]) {
            print_lcs(a, b - 1, s);
        } else if (dp[a-1][b] == dp[a][b]){
            print_lcs(a - 1, b, s);
        } else if (dp[a-1][b-1] == dp[a][b] - 1) {
            print_lcs(a-1, b-1, s);
            cout << s[a-1];
        }
    }
}

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

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }

    print_lcs(int(s.size()), int(t.size()), s);
    return 0;
}



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

int main(){
    int W, H ,x, y, r;
    cin >>W >>H >>x >> y>> r;
    
    if(x - r < 0 || x + r >W ){
        cout << "No" << endl;
    }else if(y - r < 0 || y + r >H ){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

//const ll INF=(ll)1e19;
const int INF=(1<<30);


int main(){
  int H,W,K;
  cin >> H >> W >> K;

  vector<vector<int>> S(H, vector<int>(W,0));
  REP(i,H)REP(j,W){
    char c;
    cin >> c;
    S[i][j] = (c == '1' ? 1 : 0 );
  }

  int ans = INF;
  REP(i, 1<<(H-1)){
    vector<vector<int> > t(H, vector<int>(W,0));
    int h=0;
    int b=i;
    REP(j,H){
      REP(k,W){
        t[h][k] += S[j][k]; 
      }
      if(b & 1){
        h++;
      }
      b = b >> 1;
    }

    h++;
    // cout << h << endl;
    // REP(j,H){
    //   REP(k,W){
    //     cout << t[j][k] << " ";
    //   }
    //   cout << endl;
    // }
    // cout << endl;

    vector<int> sum(h,0);

    int l=0;
    int tmp=h-1;
    REP(j,W){
      bool ok = true;
      REP(k,h){
        sum[k] += t[k][j];
      }

      REP(k,h){
        if(sum[k] > K)ok = false;
      }

      if(!ok){
        tmp++;
        sum = vector<int>(h,0);
        REP(k,h){
          sum[k] += t[k][j];
        }

        REP(k,h){
          if(sum[k] > K){
            tmp = INF;
            break;
          }
        }
      }

    }
    ans = min(ans,tmp);

  }

  cout << ans << endl;
}



Measured memory_bytes: 384
/*
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){

    return 0;
}
*/

//y11-1
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    while(true){

    int t,n;
    cin >> t;
    if(t == 0) return 0;
    cin >> n;
    int sum = 0;
    for(int i=0; i<n; i++){
        int s,f;
        cin >> s >> f;
        sum += f - s;
    }
    if(sum >= t) cout << "OK" << endl;
    else{
        cout << t - sum << endl;
    }


    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int dp[105][105][305];

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

    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    cin >> w[0] >> v[0];
    int base = w[0];
    w[0] = 0;
    for(int i = 1; i < N; ++i){
        cin >> w[i] >> v[i];
        w[i] -= base;
    }
    for(int i = 0; i <= N; ++i){
        for(int j = 0; j <= N; ++j){
            for(int k = 0; k <= N * 3; ++k){
                dp[i][j][k] = -1;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j <= i; ++j){
            for(int k = 0; k <= i * 3; ++k){
                if(dp[i][j][k] == -1)   continue;
                chmax(dp[i + 1][j][k], dp[i][j][k]);
                chmax(dp[i + 1][j + 1][k + w[i]], dp[i][j][k] + v[i]);
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= i; ++j){
            for(int k = 0; k <= i * 3; ++k){
                if(dp[i][j][k] == -1)   continue;
                if((ll)base * j + k <= W)   chmax(ans, dp[i][j][k]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 16160
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int nenrei = stdIn.nextInt();
		int a;
		int b;
					
		if (nenrei == 1){
			System.out.println("Hello World");
		}
		if(nenrei == 2) {
			a = stdIn.nextInt();
			b = stdIn.nextInt();
			System.out.println((a + b));
		}	
	}
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 2000005;
int R1, C1, R2, C2;

int memo[MAX_N];

int myKai(int n) {
  return memo[n];
}

int myPow(int n, int k) {
  int tmp = n;
  int ret = 1;
  while(k) {
    if(k&1) {
      ret *= tmp;
      ret %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;

    k /= 2;
  }

  return ret;
}

int solve(int wc, int hc)
{
  int ret = 0;

  FOR(n,1,hc+2) {
    int ww = wc, hh = n;
    int tmp = (((myKai(ww+hh) * myPow(myKai(ww), MOD-2)) % MOD) * myPow(myKai(hh), MOD-2)) % MOD;
    ret += tmp;
    ret %= MOD;
  }

  return ret;
}

signed main()
{
  memset(memo, -1, sizeof(memo));
  memo[0] = 1;
  FOR(n,1,MAX_N) {
    memo[n] = (memo[n-1] * n) % MOD;
  }

  cin >> R1 >> C1 >> R2 >> C2;

  int ans = (LL)MOD*4;
  ans += solve(R2, C2) - solve(R2,C1-1) - solve(R1-1,C2) + solve(R1-1,C1-1);

  cout << ans % MOD << endl;

  return 0;
}


Measured memory_bytes: 15872
n, k = map(int, input().split())
x = [int(n) for n in input().split()]
index = 0
current = 0
top = 0
flag = 0
if x[n - 1] <= 0:
	x.append(0)
	index = n
else:
	while x[index] < 0:
		index += 1
		if index >= n:
			break
	x.insert(index, 0)
for i in range(k + 1):
	i1 = index + i
	i2 = index - k + i
	if i1 < n + 1 and i2 > -1:
		if i == 0 or i == k:
			current = max(abs(x[i2]), x[i1])
		else:
			s = abs(x[i2])
			smaller = min(x[i1], s)
			current = x[i1] - x[i2]
			current += smaller

		if flag == 0:
			top = current
			flag += 1
		elif top > current:
			top = current
print(top)

Measured memory_bytes: 14484
#include <iostream>

using namespace std;

int check(int w[], int n, int p) {
    int k = 1;
    int margin = p;
    for(int i = 0; i < n; i++) {
        if(w[i] > p) return n + 1;
        margin -= w[i];
        if(margin < 0) {
            margin = p - w[i];
            k++;
        }
    }
    return k;
}

int solve(int w[], int n, int k) {
    long int mid, left = 0, right = 100000 * 100000;
    while(right - left > 1) {
        mid = (left + right) / 2;
        int x = check(w, n, mid);
        if(k >= x) right = mid;
        else if(k < x) left = mid;
    }
    return int(right);
}

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

    cout << solve(w, n, k) << endl;
}


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

using namespace std;

#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

const int N = 1e6+20;
int st[N],p[N];
int c[N];
signed main(){
	IOS
	int n;cin>>n;
	vi v(n);
	forn(i,n){
		cin>>v[i];
		p[v[i]]++;
	}
	sort(all(v));
	int ans = 0;
	for(int i:v){
		if(!st[i] && p[i]==1) ans++;
		for(int j=i;c[i]==0 && j<N;j+=i)
			st[j]++;
		c[i]++;
	}
	cout<<ans;
}

Measured memory_bytes: 15728
W, H, N = map(int, input().split())

ans = [[1] * H for i in range(W)]

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    for j in range(x):
      for k in range(H):
        ans[j][k] = 0
  elif a == 2:
    for j in range(x, W):
      for k in range(H):
        ans[j][k] = 0
  elif a == 3:
    for j in range(W):
      for k in range(y):
        ans[j][k] = 0
  else:
    for j in range(W):
      for k in range(y, H):
        ans[j][k] = 0
  
#print(ans)  
aa = 0
for i in range(W):
  for j in range(H):
    if ans[i][j] == 1:
      aa += 1
print(aa)




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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


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


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n, a = 0,b = 0,c = 0,d = 0;
    string s;
    cin >> n;
    rep(i,n) {
        cin >> s;
        if(s == "AC") ++a;
        else if(s == "WA") ++b;
        else if(s == "TLE") ++ c;
        else ++d;
    }

    cout << "AC x " << a << '\n';
    cout << "WA x " << b << '\n';
    cout << "TLE x " << c << '\n';
    cout << "RE x " << d << '\n';

//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

using namespace std;

int main()
{
	
	int N;
	int *whoRabbitLikes, *checked;	//array
	int currentRabbitNum, loveInterest;
	int numFriendlyPairs = 0;

	cin >> N;
	whoRabbitLikes = new int[N];
	checked = new int[N] ();
	
	cin.ignore(256, '\n');

	for (int i = 0; i < N; i++) {
		cin >> whoRabbitLikes[i];
	}

	for (int i = 0; i < N; i++) {
		if (!checked[i]) {
			currentRabbitNum = i + 1;
			loveInterest = whoRabbitLikes[i];

			if (currentRabbitNum == whoRabbitLikes[loveInterest-1]) {
				numFriendlyPairs++;
				checked[loveInterest - 1] = 1;	//set to true
			}
		}
	}

	cout << numFriendlyPairs << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	string s;
	ci2(n,s);
	vi R,G;
	unordered_map<int ,bool> B;
	fo(i,n){
		if(s[i]=='R'){
			R.pb(i);
		}
		else if(s[i]=='G'){
			G.pb(i);
		}
		else{
			B[i]=true;
		}
	}
	int m =B.size();
	ll cnt=(R.size())*(G.size())*m;
	for(auto r: R){
		for(auto g: G){
			if((r+g)%2==0 && B[(r+g)/2]){
				cnt--;
			}
			if(B[2*r-g]){
				cnt--;
			}
			if(B[2*g-r]){
				cnt--;
			}
		}
	}
	co(cnt);
}


Measured memory_bytes: 4100
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, ~n){
        string ans;
        while(n){
            ans += to_string(n&3);
            n >>= 2;
        }
        if(ans.empty()) ans = "0";
        reverse(ans.begin(),ans.end());
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
long long n,x;
long long gcd(long long a,long long b)
{
    if (!b) return a;
    return gcd(b,a%b);
}
void solve()
{
    vector < long long > a(n);
    long long i,ans;
    for (i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        a[i]=abs(a[i]-x);
    }
    ans=a[0];
    for (i=1;i<n;i++)
    {
        long long u;
        if (a[i]<ans) {u=a[i];a[i]=ans;ans=u;}
        ans=gcd(a[i],ans);
    }
    printf("%lld\n",ans);
}
int main()
{
    while(~scanf("%lld%lld",&n,&x))
        solve();
}

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

using namespace std;

int n,k;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
	}
	
	int s=k-1;
	
	cout<<(n+s-2)/s;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int A, B, C; cin >> A >> B >> C;
  int K; cin >> K;
  priority_queue<int> que;
  que.push(A), que.push(B), que.push(C);
  for (int i = 0; i < K; ++i){
    int v = que.top() * 2; que.pop();
    que.push(v);
  }
  int ans = 0;
  while(!que.empty()) ans += que.top(), que.pop();
  cout << ans << endl;
}


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

const int mod = 10007;

int n;
int dp[1001][8];
char s[1001];

bool is_present(int x,char c){
  int y;
  if(c=='J') y = 1;
  else if(c=='O') y = 2;
  else if(c=='I') y = 4;
  return x&y;
}


int main(){
  scanf("%d %s",&n,s);
  fill(dp[0],dp[0]+8008,0);
  for(int i=0;i<=n;i++){
    for(int j=0;j<8;j++){
      if(i==0&&j==1) dp[i][j] = 1;
      else if(is_present(j,s[i-1])){
        for(int k=0;k<8;k++){
          if(j&k){
            dp[i][j]+=dp[i-1][k];
            dp[i][j]%=mod;
          }
        }
      }
    }
  }
  int ans = 0;
  for(int i=0;i<8;i++) ans+=dp[n][i];
  printf("%d\n",ans%mod);
  return 0;
}

Measured memory_bytes: 1056
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

vector<int> g[100111];
int n,k,a[100111],mn[100111],root;
bool add[100111];
void dfs(int x,int f=0,int d=0)
{
	mn[x]=inf;
	for(int i=0;i<(int)g[x].size();i++)
		if(g[x][i]!=f)
		{
			dfs(g[x][i],x,d+1);
			mn[x]=min(mn[x],mn[g[x][i]]);
		}
	if(a[x]!=-1&&(a[x]+d<a[root]||a[x]-d>a[root]||(a[root]-a[x]+d)%2==1))
	{
		puts("No");
		exit(0);
	}
	if(a[x]!=-1)mn[x]=min(mn[x],(a[x]-a[root]+d)/2);
}
void dfs2(int x,int f=0,int v=0,int d=0)
{
	int val=a[root]-d+2*v;
	if(a[x]!=-1&&a[x]!=val)
	{
		puts("No");
		exit(0);
	}
	else a[x]=val;
	for(int i=0;i<(int)g[x].size();i++)
		if(g[x][i]!=f)
		{
			if(mn[g[x][i]]-v>0)add[g[x][i]]=1;
			dfs2(g[x][i],x,v+add[g[x][i]],d+1);
		}
}
int main()
{
	memset(a,-1,sizeof(a));
	get1(n);
	for(int i=1,u,v;i<n;i++)
	{
		get2(u,v);
		g[u].pb(v);
		g[v].pb(u);
	}
	get1(k);
	for(int i=1,x,y;i<=k;i++)
	{
		get2(x,y);
		root=x;
		a[x]=y;
	}
	dfs(root);
	dfs2(root);
	puts("Yes");
	for(int i=1;i<=n;i++)printendl(a[i]);
	return 0;
}

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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll res = 1;
    ll x, y; cin >> x >> y;
    ll cur = x;
    while (cur * 2 <= y) {
        cur *= 2;
        res++;
    }
    cout << res << endl;
    return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int t,mx=0,s=0;
	while(n--)
	{
		cin>>t;
		s+=t;
		mx=max(mx,t);
	}
	s-=mx;
	if(mx<s) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ULL H;
    cin >> H;

    ULL tmp = 2;
    ULL ans = 1;

    while((H/tmp) > 0) {
        ans += tmp;
        tmp *= 2;
    }

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


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    ans=n+2
    for d in range(1,n+1):
        if d**2>n:break
        if n%d==0:
            ans=min(ans,d+n//d)
    print(ans-2)

main()

Measured memory_bytes: 3064
///
// File:  0529.cpp
// Author: ymiyamoto
//
// Created on Wed Feb 28 21:12:52 2018
//
#include <bits/stdc++.h>
using namespace std;

#define rep(_n, _init, _N) for (int32_t _n = _init; _n < (int32_t)(_N); _n++)
#define rrep(_n, _N, _end) for (int32_t _n = (int32_t)(_N); _n >= _end; _n--)
#define iceil(_x, _y) (((_x) + (_y)-1) / (_y))
#define ifloor(_x, _y) ((_x) / (_y))

static const double pi = 2 * asin(1);
static const double precision = 10e-9;

int32_t main()
{
  while (true) {
    int64_t N, M;
    cin >> N >> M;
    if (N == 0) break;

    vector<int64_t> arr = vector<int64_t>(N + 1);
    rep(i, 1, N + 1)
    {
      cin >> arr[i];
    }
    sort(arr.begin(), arr.end());

    vector<int64_t> sums = vector<int64_t>((N + 1) * (N + 1));
    uint32_t cnt = 0;
    rep(i, 0, N + 1)
    {
      rep(j, 0, N + 1)
      {
        sums[cnt] = arr[i] + arr[j];
        cnt++;
      }
    }

    sort(sums.begin(), sums.end());
    int64_t m = 0;
    rep(i, 0, sums.size())
    {
      int64_t rem = M - sums[i];
      if (0 <= rem) {
        auto p = lower_bound(sums.begin(), sums.end(), rem);
        if (p != sums.begin() && p != sums.end()) {
          m = max(m, *(p - 1) + sums[i]);
        }
      }
    }
    cout << m << endl;
  }

  return 0;
}



Measured memory_bytes: 11480
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(a,b);
  COUT(a * b - a - b + 1)
;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = 510000;

int main(){
    int x,n;
    cin >> x >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p.at(i);
    }

    
        for(int i=0;i<110;i++){
            bool lc,rc;
            lc = false;
            rc = false;
            int l = x-i;
            int r = x+i;
                
            for(int j=0;j<n;j++){
                
                if(p.at(j) == l) lc = true;
                if(p.at(j) == r) rc = true;
            }
            if(lc == false && rc == false){
                cout << l << endl;
                return 0;}

            if(lc && rc == false){
                cout << r << endl;
                return 0;}

            if(lc == false && rc){
                cout << l << endl;
                return 0;
                }
        }
    
}

Measured memory_bytes: 3600