akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    string st;
    cin>>st;
    vector<pair<char,int>> vec;
    REP(i,n){
        if(vec.size()&&vec.back().fi==st[i]){
            vec.back().se++;
        }else{
            vec.pb({st[i],1});
        }
    }
    int ans=0;
    REP(i,vec.size()){
        ans+=vec[i].se-1;
    }
    if(m*2<vec.size()-1){
        ans+=m*2;
    }else{
        ans+=vec.size()-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

    vector<bool> dp(k+1,false);
    for(int i = 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i-a[j]>=0 && !dp[i-a[j]]){
                dp[i] = !dp[i];
                break;
            }
        }
    }

    cout << (dp[k]?"First":"Second") << endl;

    return 0;
}

Measured memory_bytes: 256
import heapq
import sys
X, Y, A, B, C = map(int, input().split())
Av = list(map(int, input().split()))
Bv = list(map(int, input().split()))
Cv = list(map(int, input().split()))
heapq.heapify(Av)
heapq.heapify(Bv)
heapq.heapify(Cv)
for i in range(A-X):
    heapq.heappop(Av)
for i in range(B-Y):
    heapq.heappop(Bv)
if C > X+Y:
    for i in range(C-(X+Y)):
        heapq.heappop(Cv)
    NotTake = X+Y
else:
    NotTake = C
total = X+Y
C = NotTake
for _ in range(NotTake):
    Amin = heapq.heappop(Av)
    Bmin = heapq.heappop(Bv)
    Cmin = heapq.heappop(Cv)
    if X > 0 and Amin == min(Amin, Bmin, Cmin):
        heapq.heappush(Bv, Bmin)
        heapq.heappush(Cv, Cmin)
        X -= 1
    elif Y > 0 and Bmin == min(Bmin, Cmin):
        heapq.heappush(Av, Amin)
        heapq.heappush(Cv, Cmin)
        Y -= 1
    elif C > 0:
        heapq.heappush(Av, Amin)
        heapq.heappush(Bv, Bmin)
        C -= 1
    if X == 0 or Y == 0 or C == 0:
        break
NotTake = X+Y+C-total
if X == 0:
    Iv = Bv
    Jv = Cv
    I = Y
    J = C
elif Y == 0:
    Iv = Av
    Jv = Cv
    I = X
    J = C
else:
    print(sum(Av)+sum(Bv)+sum(Cv))
    sys.exit()

for _ in range(NotTake):
    Imin = heapq.heappop(Iv)
    Jmin = heapq.heappop(Jv)
    if I > 0 and Imin == min(Imin, Jmin):
        heapq.heappush(Jv, Jmin)
        I -= 1
    elif J > 0:
        heapq.heappush(Iv, Imin)
        J -= 1
    if J == 0 or I == 0:
        break

print(sum(Av)+sum(Bv)+sum(Cv))


Measured memory_bytes: 29820
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if(A>B || N==1){
        cout << (A==B) << el;return;
    }
    ll L = (N-1)*A+B;
    ll R = A+(N-1)*B;
    cout << R-L+1 << el;
}



Measured memory_bytes: 3580
#include <vector> 
#include <iostream>

using namespace std;

int N, W;
long long v[105], w[105];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }
    vector<long long> dp(W + 1, 0);
    for (int i = 0; i < N; ++i) {
        for (int j = W; j >= w[i]; --j) {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    cout << dp[W];
}

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

#define int long long

struct BiMatch{
  int n;
  vector<vector<int> > G;
  vector<int> match,used;
  
  BiMatch(){}
  BiMatch(int sz):n(sz),G(sz),match(sz),used(sz){}
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  bool dfs(int v){
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      int u=G[v][i],w=match[u];
      if(w<0||(!used[w]&&dfs(w))){
        match[v]=u;
        match[u]=v;
        return true;
      }
    }
    return false;
  }

  int build(){
    int res=0;
    fill(match.begin(),match.end(),-1);
    for(int v=0;v<n;v++){
      if(match[v]<0){
        fill(used.begin(),used.end(),0);
        if(dfs(v)){
          res++;
        }
      }
    }
    return res;
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  using P = pair<int, int>;
  vector<P> A(N), B(N);
  BiMatch bm(2*N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i].first >> A[i].second;
  }
  for ( int i = 0; i < N; i++ ) {
    cin >> B[i].first >> B[i].second;
  }

  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ ) {
      auto a = A[i], b = B[j];
      if ( a.first < b.first && a.second < b.second ) {
	bm.add_edge(i, N+j);	
      }
    }
  }

  cout << bm.build() << endl;  
  
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE


int main() {
    auto start = chrono::high_resolution_clock::now();
    fio;
    ll t=1; 
   // cin>>t;
    while(t--)
    {
       ll a,b,c; cin>>a>>b>>c;
       swap(a,b);
       swap(a,c);
       cout<<a<<" "<<b<<" "<<c<<"\n";
        
    }

    auto finish = chrono::high_resolution_clock::now();
    cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
        
}


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

using namespace std;

const int md = 1e9 + 7;

int main(){
  long long n, m;
  scanf("%lld %lld", &n, &m);
  if (n * 2 <= m){
    long long cur = m - n * 2;
    printf("%lld\n", n + cur / 4);
  }
  else {
    printf("%lld\n", m / 2);
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define MAX 1010

int main(){
  double x1,x2,y1,y2,xq,yq;
  while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)){
    P p1(x1, y1), p2(x2, y2);
    P q(xq, yq);
    p2 -= p1; q -= p1;
    q /= p2;
    q = conj(q);
    q *= p2;
    q += p1;
    printf("%.6f %.6f\n", q.real(), q.imag());
  }
  return 0;
}

Measured memory_bytes: 0
#n<=10**5まで
def cmb(n, k, mod, fac, ifac):    
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac



n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mod = 1000000007
fac, ifac = make_tables(mod, n)


ans = 0
for i in range(n-k+1):
    c = cmb(n-1-i, k-1, mod, fac, ifac)
    ans += ((a[n-1-i] - a[i]) * c) % mod
print(ans%mod)

Measured memory_bytes: 20436
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

vector<string> V;
int H,W;

struct Point {
    int x;
    int y;

    Point(){};
    Point( int a, int b ) {
        x = a; y = b;
    }
};

int dir[4][2] = { {1,0}, {0,1}, {-1,0}, {0,-1} };
bool isOK( int x, int y ) {
    return x >= 0 && y >= 0 && x < W && y < H;
}
bool canGo( int x, int y ) {
    return V[y][x] == '.';
}

int dist[51][51];

void init() {
    for ( int x = 0; x < W; x++ ) {
    for ( int y = 0; y < H; y++ ) {
        dist[x][y] = -1;
    }
    }
}

void bfs( int x, int y ) {

    dist[x][y] = 0;
    queue<Point> Q;

    for ( int i = 0; i < 4; i++ ) {
        int nx,ny;
        nx = x+dir[i][0];
        ny = y+dir[i][1];        
        if ( isOK(nx,ny) && canGo(nx,ny) && dist[nx][ny] == -1 ) {
            Point p(nx,ny);
            Q.push(p);
            dist[nx][ny] = 1;
        }
    }

    while ( !Q.empty() ) {
        Point p;
        p = Q.front();
        Q.pop();

        for ( int i = 0; i < 4; i++ ) {
            int nx,ny;
            nx = p.x+dir[i][0];
            ny = p.y+dir[i][1];
            if ( isOK(nx,ny) && canGo(nx,ny) && dist[nx][ny] == -1 ) {
                dist[nx][ny] = dist[p.x][p.y]+1;
                Point np(nx,ny);
                Q.push(np);
            }
        }
    }

}

int main() {
    
    cin >> H >> W;
    V.resize(H);
    int a = 0;
    for ( int i = 0; i < H; i++ ) {
        cin >> V[i];
        for ( int j = 0; j < W; j++ ) {
            if ( V[i][j] == '.' ) { a++; }
        }
    }
    init();
    bfs(0,0);

    if ( dist[W-1][H-1] == -1 ) { cout << -1 << endl; }
    else {
        cout << a-(dist[W-1][H-1]+1) << endl;
    }

    return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

template <class T>
T inv_num(T num)
{
    return PowMod(num, MOD - 2);
}
template <class T>
T COM(T n, T a)
{
    T X, Y;
    X = 1;
    Y = 1;
    rep(i, a)
    {
        X *= (n - i) % MOD;
        Y *= (a - i) % MOD;
    }
    return X * (inv_num(Y)) % MOD;
}

int main()
{
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    ll mn,mx;
    for (ll i = k; i <=n+1; i++)
    {
        mn = (0+i-1)*i/2;
        mx = (n+n-i+1)*i/2;
        //cout << mn << " " << mx << endl;
        ans += (mx-mn)%MOD+1;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . reverse . drop ( length "FESTIVAL" ) . reverse


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

ll gcd(ll n, ll m) {
  if (n > m)
    swap(n, m);
  if (m % n == 0)
    return n;
  else {
    return gcd(n, m % n);
  }
}

int main() {
  ll N;
  cin >> N;
  vec A(N, -1);
  vec ans(N, 0);
  // A[0]=
  REP(i, N - 1) {
    cin >> A[i + 1];
    ans[A[i + 1] - 1] += 1;
  }

  REP(i, N) { cout << ans[i] << endl; }

  return 0;
}

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

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	int l = 0, r = 0, in;
	for (int i = 0; i < m; ++i)
	{
		cin >> in;
		l += (in < x);
		r += (in > x);
	}
	cout << min(l, r) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define pii pair<int, int>
#define forr(i,a,n) for (int i = (a); i < (n); ++i)
#define rforr(i,a,n) for (int i = (a); i > (n); --i)
#define ALL(x) x.begin(),x.end()
#define LEN(X) ((int)(X).size())
#define CASET int _T; cin >> _T; forr(caset,0,_T)
//#define int ll

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    //freopen("input.txt","w",stdout);
    double r; cin >> r;
    cout << 6.28318530717958623200*r << '\n';


    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string s;
    cin >> s;
    string ans={};
    rep(i,s.size()){
        if(s.at(i)=='B'){
            if(ans.size()>0) ans.pop_back();
        }else{
            ans.push_back(s.at(i));
        }
    }
    cout << ans << endl;



}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll N, A, B, C, D;
map<ll, ll> num;
ll dfs(ll n){
  if(num[n]==0){
    if(n==0){
      return 0;
    }else if(n==1){
      num[n]=D;
      return num[n];
    }else{
      ll tmp = 1e18;
      if(log10(n)+log10(D)<=18)tmp = n*D;
      tmp = min(tmp, dfs(n/5)+C+(n%5)*D);
      tmp = min(tmp, dfs((n+4)/5) + C + (5 - n%5) * D);
      tmp = min(tmp, dfs(n/3) + B + (n%3) * D);
      tmp = min(tmp, dfs((n+2)/3)+B+(3 - n%3) * D);
      tmp = min(tmp, dfs(n/2)+A + (n%2) * D);
      tmp = min(tmp, dfs((n+1)/2) + A + (2 - n%2) * D);
      //cout << n << " " << tmp << endl;
      num[n]=tmp;
      return tmp;
    }
  }else{
    return num[n];
  }
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll T;
  cin >> T;
  rep(cases, T){
    cin >> N >> A >> B >> C >> D;
    num.clear();
    cout << dfs(N)<<endl;
  }
  return 0;
}


Measured memory_bytes: 4744
def Main(N, S):
    d = {}
    for s in S:
        if s not in d:
            d[s] = 0
        else:
            d[s] += 1
    return len(d)
    
def main():
    N = int(input())
    S = []
    for i in range(N):
        S.append(str(input()))
    print(Main(N, S))

if __name__ == '__main__':
    main()

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

using namespace std;

inline int read() {
	int x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {
		if (c == '-') f = -1;
		c = getchar();
	}
	while (isdigit(c)) {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}

signed main() {
//	freopen("input.txt", "r", stdin);
int a=read(),b=read();
printf("%d\n",a*b);
	return 0;
}


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

int main() {
	vector<int> d{0,1,2,3,4,5,6,7,8,9};
	int i,j,dl,n,k,h,m;
	dl=10;
	cin >> n >> k;
	int s[k];
	for(i=0;i<k;i++){
		cin >> s[i];
		for(j=0;j<dl;j++){
			if(s[i]==d[j]){
				d.erase(d.begin() + j);
				dl--;
			}
		}
	}

	int min=100000;
	for(m=0;m<dl;m++){
	for(h=0;h<dl;h++){
		for(i=0;i<dl;i++){
			for(j=0;j<dl;j++){
				for(k=0;k<dl;k++){
					if(10000*d[m]+1000*d[h]+100*d[i]+10*d[j]+1*d[k]>=n&&10000*d[m]+1000*d[h]+100*d[i]+10*d[j]+1*d[k]<min){
						min=10000*d[m]+1000*d[h]+100*d[i]+10*d[j]+1*d[k];
					}
				}
			}
		}
	}
	}
		for(h=0;h<dl;h++){
		for(i=0;i<dl;i++){
			for(j=0;j<dl;j++){
				for(k=0;k<dl;k++){
					if(1000*d[h]+100*d[i]+10*d[j]+1*d[k]>=n&&1000*d[h]+100*d[i]+10*d[j]+1*d[k]<min){
						min=1000*d[h]+100*d[i]+10*d[j]+1*d[k];
					}
				}
			}
		}
	}
	for(i=0;i<dl;i++){
				for(j=0;j<dl;j++){
					for(k=0;k<dl;k++){
						if(100*d[i]+10*d[j]+1*d[k]>=n&&100*d[i]+10*d[j]+1*d[k]<min){
							min=100*d[i]+10*d[j]+1*d[k];
						}
					}
				}
			}

	for(j=0;j<dl;j++){
						for(k=0;k<dl;k++){
							if(10*d[j]+1*d[k]>=n&&10*d[j]+1*d[k]<min){
								min=10*d[j]+1*d[k];
							}
						}
					}
	for(k=0;k<dl;k++){
								if(1*d[k]>=n&&1*d[k]<min){
									min=1*d[k];
								}
							}
	cout << min << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double A, B;
int main() 
{
	cin >> A >> B;
	double c = max(ceil(A / 0.08), ceil(B / 0.1));
	if ((c < ((A + 1) / 0.08)) && (c < ((B + 1) / 0.1)))cout << static_cast<int>(c) << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  if (b >= a) cout << a << endl;
  else cout << a - 1 << endl;

  return 0;
}


Measured memory_bytes: 3580
<?php
$input = explode(' ', trim(fgets(STDIN)));
$n = $input[0];
$a = $input[1];
$b = $input[2];

if (($n % 2 !== 0 && ($a + $b) % 2 === 0) || ($n % 2 === 0 && ($a + $b) % 2 === 0)) {
  echo "Alice\n";
} else {
  echo "Borys\n";
}


Measured memory_bytes: 3828
n,m=map(int,input().split())
a=[0]*(n)
if n==1:
  print(1)
  exit()
if m>0:
  for _ in range(m):
    a[int(input())]+=1
dp=[0]*(n+1)
dp[0]=1
if a[1]!=1:
  dp[1]=1
for i in range(2,n+1):
  if a[i-2]==0 and a[i-1]==0:
    dp[i]=dp[i-2]+dp[i-1]
  elif a[i-1]!=0 and a[i-2]==0:
    dp[i]=dp[i-2]
  elif a[i-2]!=0 and a[i-1]==0:
    dp[i]=dp[i-1]
  else:
    dp[i]=0
print(dp[n]%(10**9+7))    


Measured memory_bytes: 504824
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
string s;
int main(){
  cin >> s;
  stack<int> s1;
  stack<pair<int,int> > s2;
  int sum=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='\\')s1.push(i);
    else if(s[i]=='/' && s1.size()>0){
      int j=s1.top();
      s1.pop();
      sum+=(i-j);
      int a=i-j;
      while(s2.size()>0 && s2.top().first>j){
	a+=s2.top().second;s2.pop();
      }
      s2.push(make_pair(j,a));
    }
  }
  vector<int> ans;
  int t=0;
  while(s2.size()>0){ans.push_back(s2.top().second);s2.pop();}
  reverse(ans.begin(),ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i=0;i<ans.size();i++){
    cout << " ";
    t+=ans[i];
    cout << ans[i];
  }
  cout << endl;
  
  return 0;
}

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

int main() {
  int N,X,T;
  cin >> N >>X >>T;
  if (N%X==0) {
    cout << (N/X)*T<< endl;
  } else {
    cout << (N/X+1)*T<< endl;
  }
}

Measured memory_bytes: 3592
# coding: utf-8
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        # xの根を探索
        if self.parents[x] < 0:
            return x
        else:
            # 再帰的に根を探索
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        # 2つの木をマージする。
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def are_same(self, x, y):
        # 2つの要素の根が同じかどうかを調べる
        return self.find(x) == self.find(y)

    def members(self, x):
        # xと同じ根の要素をリストで出力
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == self.n]

    def roots(self):
        # 根である要素をリストで出力
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{} {}".format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
ans = 0
for v in uf.parents:
    if v < 0:
        ans = max(ans, abs(v))
print(ans)


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

const int MAXN = 100;

char s[MAXN];
long long ans, ca, cb, cc;

int main (void) {
    int n;
    scanf("%d", &n);
    for (int i = 1, m; i <= n; i++) {
        scanf("%s", s + 1);
        m = strlen(s + 1);
        for (int j = 1; s[j + 1]; j++) {
            if (s[j] == 'A' && s[j + 1] == 'B') ans++;
        }
        if (s[1] == 'B') {
            if (s[m] == 'A') cc++;
            else cb++;
        } else {
            if (s[m] == 'A') ca++;
        }
    }
    if (cc) {
        ans += cc - 1;
        cc = 1;
        ans += min(ca, cb) + (max(ca, cb) != 0);
    } else {
        ans += min(ca, cb);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  string b;
  cin >> b;

  if(b.compare("A") == 0){
    cout << "T" << endl;
  }
  if(b.compare("T") == 0){
    cout << "A" << endl;
  }
  if(b.compare("C") == 0){
    cout << "G" << endl;
  }
  if(b.compare("G") == 0){
    cout << "C" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
struct query {
  int l, r, idx;
} queries[500005];
bool cmp(query x, query y) { return x.r < y.r; }
int a[500005];
ll bit[1000005];
int vis[1000005];
ll ans[500005];
int n, q;
void update(int idx, int val) {
  for (; idx <= n; idx += (idx & -idx))
    bit[idx] += val;
}
int query(int idx) {
  int sum = 0;
  for (; idx > 0; idx -= (idx & -idx))
    sum += bit[idx];
  return sum;
}
int main() {
  IOS;
  cin >> n >> q;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < q; i++) {
    int ll, rr;
    cin >> ll >> rr;
    queries[i].l = ll - 1, queries[i].r = rr - 1;
    queries[i].idx = i;
  }
  sort(queries, queries + q, cmp);
  int qcnt = 0;
  fill(vis, vis + 1000005, -1);
  for (int i = 0; i < n; i++) {
    if (vis[a[i]] != -1)
      update(vis[a[i]] + 1, -1);
    vis[a[i]] = i;
    update(i + 1, 1);
    while (qcnt < q && queries[qcnt].r == i) {
      ans[queries[qcnt].idx] =
          query(queries[qcnt].r + 1) - query(queries[qcnt].l);
      qcnt++;
    }
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

bool exp(int n) {
	int m = 1;
	if (n == 1)return 1;
	for (int i = 2; i < n; i++) {
		while (m <= n) {
			m *= i;
			if (m == n)return 1;
		}
		m = 1;
	}
	return 0;
}

int main() {
	int x;
	cin >> x;
	vector<bool> f(1001);
	for (int i = x; i > 0; i--) {
		if (exp(i) == 1) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3568
#include<vector>

class SlidingSum {
    int size;
    std::vector<int> node;
public:
    SlidingSum(int s) :size(s), node(std::vector<int>(s + 1, 0)) {}
    int sum(int index) const {
        int result = 0;
        for(int i = index + 1; i > 0; i -= i & -i) result += node[i];
        return result;
    }
    int sum(int left, int right) const {
        return sum(right) - sum(left - 1);
    }
    void update(int index, int value) {
        for(int i = index + 1; i <= size; i += i & -i) node[i] += value;
    }
};

#include<iostream>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    SlidingSum ss(n);
    while(--q >= 0) {
        int com, x, y;
        cin >> com >> x >> y;
        if(com == 0) {
            ss.update(x - 1, y);
        } else {
            cout << ss.sum(x - 1, y - 1) << endl;
        }
    }
}

Measured memory_bytes: 1524
#!python3

def resolve():
    N = int(input())

    if N < 2 or (N % 2) == 1:
        print(0)
        return


    n = N // 10
    a = 50
    while a <= N:
        n += N // a
        a *= 5

    print(n)

if __name__ == "__main__":
    resolve()


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

int main(){
  double a,b,h,m,angle,pi=3.14159265358979;
  cin>>a>>b>>h>>m;
  angle = 2*pi*abs(h/12+m/12/60-m/60);
  cout<<setprecision(14)<<sqrt(a*a+b*b-2*a*b*cos(min(2*pi-angle,angle)));
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=5e3+7;
ll d[L],a[L][L], p[L], c[L];
ll get(ll x, ll r, ll n)
{
	ll mx = LLONG_MIN;
	FOR(i,1,r+1)
	{
		mx = max(mx, a[x][i]);
	}
	return mx;
}
void fff()
{
	ll n, k;
	cin >> n >> k;
	FOR(i,1,n+1)
	{
		cin >> p[i];
	}
	ll x, cur = 0;
	ll ans = LLONG_MIN, tmp, co = 0;
	FOR(i,1,n+1)cin >> c[i];
	FOR(i,1,n+1)
	{
		x = p[i], co = 1,cur = 0;
		while(x!=i)
		{
			cur += c[x];
			if(k>=co)
			ans = max(ans, cur);
			a[i][co] = cur;
			co++;
			x = p[x];
		}
		co--;
		if(k>co)
		{
			cur += c[i];
			co++;
			a[i][co] = cur;
			ans = max(ans, cur);
		}
		if(k>co)
		{
			tmp = (k%co);
			// FOR(i,1,tmp+1)
			if(tmp)
			ans = max(ans, cur*(k/(co)) + get(i,tmp, co));
			else 
			{
				ans = max(ans, cur*(k/(co)));
				ans = max(ans, cur*((k/co)-1) + get(i,co,co));
			}
		}

	}
	cout << ans << ln;

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 199276
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back

int main() 
{ 
    int n;
    cin>>n;
    int ans = 0,i,x,y,z;
    for(i=1;i<=n;i++){
        ans = 0;
    for(x=1;x<=100;x++)
    {
        for(y=1;y<=100;y++)
        {
            for(z=1;z<=100;z++)
            {
                if(x*x+y*y+z*z+x*y+y*z+z*x==i)
                    ans++;
                if(x*x+y*y+z*z+x*y+y*z+z*x>i)
                    break;
            }
        }
    }
    cout<<ans<<"\n";
    }
    return 0; 
} 

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <iomanip>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    long N;
    cin >> N;
    cout << ((N-1)*N)/2 << endl;
    return 0;
}

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << 

int n, x;
VI v(101);

signed main()
{
    cin >> n >> x;

    REP(i, n){
        cin >> v[i];
    }

    int d = 0;
    REP(i, n){
        d += v[i];
        if (d <= x) continue;
        cout << i+1 << endl;
        return 0;
    }
    cout << n+1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,m,w[105],v[105];
long long dp[105][N];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=m;j++)
			if(w[i]>j)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
	cout<<dp[n][m];
	return 0;
}

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

long long as[20000], bs[20000];

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

    long long n;
    cin >> n;

    long long suma = 0, sumb = 0, diff = 0, num_things_below = 0;
    for (int i = 0; i < n; ++i) {
        cin >> as[i];
        suma += as[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> bs[i];
        sumb += bs[i];
        if (as[i] > bs[i])
            diff += as[i] - bs[i];
        else
            num_things_below += (bs[i] - as[i]) / 2;
    }

    if (sumb < suma || sumb - suma < diff || diff > num_things_below)
        cout << "No\n";
    else
        cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1 ;
void solve()
{
    ll n ;
    cin >> n ;
    vector<ll> a(n+5) , b(n+5) ;
    rep( i , 1 , n )
        cin >> b[i] ;
    b[0] = hell ;
    b[n] = hell ;
    rep( i , 1 , n + 1 ){
        a[i] = min(b[i],b[i-1]) ;
    }
    ll ans = 0 ;
    rep( i , 1 , n + 1 )
        ans += a[i] ;
    cout << ans ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


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

typedef unsigned long long LL;

using namespace std;

int main() {
	LL n, m, d;
	cin >> n >> m >> d;
	double tmp = double((n - d) * 2)/n;
	double ans = tmp*(m - 1)/n;
	if (d == 0) {
		ans = ans / 2;
	}
	printf("%.10f\n", ans);
}

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

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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int sl = s.size();
  vector<ll> cnt(2019);
  int ten = 1, tot = 0, ans = 0;
  rep(i, sl) {
    cnt[tot]++;
    int x = (s[i] - '0') * ten % 2019;
    tot += x;
    tot %= 2019;
    ans += cnt[tot];
    ten = ten * 10 % 2019;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>

using namespace std;

struct Data
{
	int hour;
	int minute;
	int mm;
};

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int lunch_count = 0;
		int dinner_count = 0;
		int midnight_count = 0;
		int lunch_ok = 0;
		int dinner_ok = 0;
		int midnight_ok = 0;
		vector<Data> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			scanf("%d%*c%d%d",&Vec[i].hour, &Vec[i].minute, &Vec[i].mm);
			if(11 <= Vec[i].hour && Vec[i].hour <= 14)
			{
				lunch_count++;
				for(int j = -8; j <= 8; ++j)
				{
					int time = Vec[i].minute;
					if(time + j < 0)
					{
						time += 60;
					}
					if((time + j) % 60 == Vec[i].mm)
					{
						lunch_ok++;
					}
				}
			}
			else if(18 <= Vec[i].hour && Vec[i].hour <= 20)
			{
				dinner_count++;
				for(int j = -8; j <= 8; ++j)
				{
					int time = Vec[i].minute;
					if(time + j < 0)
					{
						time += 60;
					}
					if((time + j) % 60 == Vec[i].mm)
					{
						dinner_ok++;
					}
				}
			}
			else if(21 <= Vec[i].hour && Vec[i].hour <= 23 || Vec[i].hour == 0 || Vec[i].hour == 1)
			{
				midnight_count++;
				for(int j = -8; j <= 8; ++j)
				{
					int time = Vec[i].minute;
					if(time + j < 0)
					{
						time += 60;
					}
					if((time + j) % 60 == Vec[i].mm)
					{
						midnight_ok++;
					}
				}
			}
		}
		if(lunch_count)
		{
			cout << "lunch " << lunch_ok * 100 / lunch_count << endl;
		}
		else
		{
			cout << "lunch no guest" << endl;
		}
		if(dinner_count)
		{
			cout << "dinner " << dinner_ok * 100 / dinner_count << endl;
		}
		else
		{
			cout << "dinner no guest" << endl;
		}
		if(midnight_count)
		{
			cout << "midnight " << midnight_ok * 100 / midnight_count << endl;
		}
		else
		{
			cout << "midnight no guest" << endl;
		}	
	}
}

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

Measured memory_bytes: 0
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
flag = True
syugo = set(sorted(data))
if len(syugo) == 1:
    syugo = list(syugo)
    if syugo[0] != 0:
        flag = False

elif len(syugo) == 2:
    syugo = list(syugo)
    if syugo[0] != 0:
        flag = False
    if data.count(syugo[1]) != data.count(0)*2:
        flag = False
        
elif len(set(data)) == 3:
    syugo = list(syugo)
    if syugo[0]^syugo[1] != syugo[2]:
        flag = False
    if len(set([data.count(i) for i in syugo])) != 1:
        flag = False
else:
    flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());

		int[] W = new int[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			W[i] = Integer.parseInt(tokens[i]);
		}

		int r = calc(W);
		System.out.println(r);

	}

	static int calc(int[] W) {
		int sum = 0;
		for (int i = 0; i < W.length; ++i) {
			sum += W[i];
		}

		int s = 0;
		int result = Integer.MAX_VALUE;
		for (int i = 0; i < W.length; ++i) {
			s += W[i];
			int diff = Math.abs((sum - s) - s);
			result = Math.min(diff, result);
		}
		return result;
	}

}


Measured memory_bytes: 21204
input()
A = list( map(int, input().split()))
d = {}
for i in A:
  a,b,c = i-1,i,i+1
  for j in [a,b,c]:
    if j in d:
      d[j] +=1
    else:
      d[j] = 1
print(sorted(d.items(), key = lambda x:x[1])[-1][1])
  

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

int main() {
  int x, a;
  cin >> x >> a;
  //vector<int> ant(5);
  //cin >> ant.at(0) >> ant.at(1) >> ant.at(2) >> ant.at(3) >> ant.at(4) >> k;
  /*
  for(int i = 0; i < 5; i++)
    cin >> ant.at(i);
  
  int k = 0;
  cin >> k;
  
  bool ans = true;
  
  for(int i = 0; i < 5; i++) {
    if(ant.at(i+1) - ant.at(i) > k) 
      ans = false;
  }
  
  if (ans)
    cout << "Yay!" << endl;
  else 
    cout << ":(" << endl;
   */
  
  //cout << n << k << endl;
  if(x < a) {
    cout << 0 << endl;
  }
  else if(x >= a) {
    cout << 10 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

struct unionfind{
	vector<int> data, size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i); size.push_back(1);
		}
	}
	
	int find(int x){
		if (data[x]==x) return x;
		return data[x] = find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if (x==y) return false;
		if (size[x]>size[y]) swap(x,y);
		data[x] = y;
		size[y] += size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};

int main(){
    int n, m, k, a, b, c, d;
	sc(n), sc(m), sc(k);

	unionfind uf(n);
	vector<vector<int>> G(n);

    rep(i, 0, m){
		sc(a), sc(b);
		a--; b--;
		uf.unite(a,b);
		G[a].push_back(b), G[b].push_back(a);
	}

    rep(i, 0, k){
        sc(c), sc(d);
        c--, d--;
		G[c].push_back(d), G[d].push_back(c);
	}

    rep(i, 0, n){
		if (i!=0) cout << ' ';
		int ans = uf.get_size(i);
        for (const auto &x : G[i]) if (uf.check(i, x)) ans--;
		cout << ans-1;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 8308
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define pb push_back
#define mp make_pair
#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 cbuf(buf, init) memset(buf, init, sizeof(buf))

template <class T>
constexpr T modp(T x, T y)
{
    return (y + x % y) % y;
}
template <class T>
constexpr T sq(T x)
{
    return x * x;
}
template <class T>
constexpr double divd(T x, T y)
{
    static_cast<double>(x) / static_cast<double>(y);
}

template <class T>
T nextInput()
{
    T t;
    cin >> t;
    return t;
}

#define netint nextInput<ll>()
#define netstr nextInput<string>()

template <class T>
void print(T&& t)
{
    cout << forward<T&&>(t) << endl;
}

void print(double t) { cout << fixed << setprecision(14) << t << endl; }

//

ll K, A[200000];

int main()
{
    //
    K = netint;
    rep(i, 0, K) { A[i] = netint; }

    ll m = 2, M = 2;
    rrep(i, K - 1, 0)
    {
        if (m % A[i] != 0) m = m + A[i] - m % A[i];
        if (m > M) {
            cout << -1 << endl;
            return 0;
        }
        if (M % A[i] == 0)
            M += A[i] - 1;
        else
            M = M - M % A[i] + A[i] - 1;
        if (m > M) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << m << " " << M << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
string S, T;
signed main(){
  vi a(2,0), b(2,0);
  cin >> a[0]>> a[1] >> b[0] >> b[1];
  int ans = -1e20;
  rep(i,2)rep(j,2) ans = max(ans, a[i]*b[j]);
  cout << ans << endl;
  return 0;
}
  
  

Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int> G[200010];
vector<int> c(10010, 0);
int num[200010];
bool used[200010];
int now_c = 0;

int dfs(int s) {
    if (used[s]) {
        return 0;
    } else {
        used[s] = true;
    }

    num[s] = c[now_c];
    now_c++;

    for (int i = 0; i < G[s].size(); i++) {
        dfs(G[s][i]);
    }
    return 0;
}


vector<int>path[200010];
lli value[200010];
void solve(int s, lli sum){
    if(used[s])
        return;

    used[s]=true;
    value[s]+=sum;
    for(auto to : path[s]){
        solve(to, value[s]);
    }
}
int main() {
    int N, Q;
    cin >> N >> Q;

    rep(i,N){
        value[i]=0;
    }

    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--, b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    rep(i,Q){
        int p, x; cin >> p >> x;
        p--;
        value[p]+=x;
    }

    solve(0,0);

    rep(i,N){
        cout << value[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 26880
import sys
import bisect
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
color = [a[n-1]]
for i in range(n-2,-1,-1):
    if a[i]>=color[-1]:
        color.append(a[i])
    else:
        x = bisect.bisect_right(color,a[i])
        color[x] = a[i]
print(len(color))

Measured memory_bytes: 7832
import numpy as np
import itertools

N, M, X = map(int, input().split())

all_df = np.zeros((1,M+1))
for n in range(N):
  A = [int(i) for i in input().split()]
  all_df = np.vstack([all_df, np.array(A).reshape(1,-1)])

all_df = all_df[1:]

now_cost = 10**9
for bins in itertools.product([0,1], repeat=N):
  prod = all_df[np.array(bins).astype(bool)].sum(axis=0)
  #print(prod)
  if (X > prod[1:]).sum() > 0:
    pass
  else:
    if prod[0] < now_cost:
      now_cost = prod[0]

if now_cost == 10**9:
  print(-1)
else:
  print(int(now_cost))

Measured memory_bytes: 27200