akhauriyash/Code-Regression huggingface dataset:
((input: string): void => {
    const hoge: string[] = input.split(/\n/);
    const l: number[] = hoge[1].split(" ").map(Number);
    l.sort((a, b) => { return a-b });
    const fuga: number = l.slice(0, -1).reduce((a, b) => a+b, 0);
    const piyo: boolean = l.slice(-1)[0] < fuga;
    console.log(piyo ? 'Yes' : 'No');
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

void fnInput(vector<int>& rvnBinHeap)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnBinHeap.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; ++i)
    cin >> rvnBinHeap[i];
}

void fnBinaryHeaps(const vector<int>& cnrvnBinHeap)
{
  for (int i = 1; i < cnrvnBinHeap.size(); ++i)
  {
    cout << "node " << i << ": key = " << cnrvnBinHeap[i] << ", ";
    int nParnt = i / 2;
    int nLeft = i * 2;
    int nRigt = nLeft + 1;
    if (nParnt >= 1)
      cout << "parent key = " << cnrvnBinHeap[nParnt] << ", ";
    if (nLeft < cnrvnBinHeap.size())
      cout << "left key = " << cnrvnBinHeap[nLeft] << ", ";
    if (nRigt < cnrvnBinHeap.size())
      cout << "right key = " << cnrvnBinHeap[nRigt] << ", ";
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnBinHeap; 

  fnInput(vnBinHeap);
  fnBinaryHeaps(vnBinHeap);
  return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

bool dp[10010];

int main(){
    int n;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; i++) cin >> s[i];

    dp[0] = true;
    for (int i = 0; i < n; i++){
        for (int j = 10000; j >= 0; j--){
            if (j >= s[i]) dp[j] = dp[j] || dp[j - s[i]];
        }
    }

    for (int j = 10000; j >= 0; j--){
        if (dp[j] && j % 10 != 0 || j == 0){
            cout << j << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static final int[] MCXI_NUM = {1000, 100, 10, 1};
    private static final char[] MCXI_CHAR = {'m', 'c', 'x', 'i'};

    public static void main(String[] args) {
        for(int n = scn.nextInt(); n > 0; n--) {
            System.out.println(encode(decode(scn.next()) + decode(scn.next())));
        }
    }

    private static int decode(String mcxi) {
        int ans = 0;
        int buf = 1;
        for(char elm : mcxi.toCharArray()) {
            if(Character.isDigit(elm)) {
                buf = elm - '0';
            } else {
                ans += buf * convert(elm);
                buf = 1;
            }
        }
        return ans;
    }

    private static int convert(char mcxi) {
        for(int i = 0; i < MCXI_CHAR.length; i++) {
            if(MCXI_CHAR[i] == mcxi) {
                return MCXI_NUM[i];
            }
        }
        return 0;
    }

    private static String encode(int num) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < MCXI_NUM.length; i++) {
            sb.append(num / MCXI_NUM[i] > 1 ? num / MCXI_NUM[i] : "");
            sb.append(num / MCXI_NUM[i] > 0 ? MCXI_CHAR[i] : "");
            num = num % MCXI_NUM[i];
        }
        return sb.toString();
    }
}

Measured memory_bytes: 37888
// Generated by CoffeeScript 1.6.2
(function() {
  var each;

  each = function(obj, iterator, context) {
    return Object.keys(obj).forEach(function(key) {
      if (iterator.call(context, obj[key], key, obj)) {
        return true;
      }
    });
  };

  (function(input) {
    var i, j, _i, _results;

    _results = [];
    for (i = _i = 1; _i <= 9; i = ++_i) {
      _results.push((function() {
        var _j, _results1;

        _results1 = [];
        for (j = _j = 1; _j <= 9; j = ++_j) {
          _results1.push(console.log("" + i + "x" + j + "=" + (i * j)));
        }
        return _results1;
      })());
    }
    return _results;
  })(require('fs').readFileSync('/dev/stdin', 'utf8'));

}).call(this);

Measured memory_bytes: 7648
#include<iostream>

bool isP(int x){
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;
    }
    return true;
}


int main(void){
    int n,cnt=0;
    int a;
    std::cin>>n;
    for(int i=0;i<n;i++){
        std::cin>>a;
        cnt+=isP(a);
    }
    std::cout<<cnt<<std::endl;
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif
vector<int> tsort(vector<vector<int>> &G) {
  int N=G.size();
  vector<int> D(N,0);
  for(int u=0; u<N; ++u) for(auto v : G[u]) D[v]++;
  vector<int> res;
  queue<int> Q;
  for(int u=0; u<N; ++u) if(D[u]==0) Q.emplace(u);
  while(Q.size()) {
    int u=Q.front(); Q.pop();
    res.push_back(u);
    for(auto v : G[u]) {
      D[v]--;
      if(D[v]==0) Q.emplace(v);
    }
  }
  return res;
}
// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 5/24/2020

 16:40-

 */

const int MAX_N=1e5+1;
int N,M;

vector<pair<LL,int>> G[MAX_N];
bool solve() {
  VV<int> gg(N);
  REP(u,N)FORR(p,G[u]) gg[u].push_back(p.second);
  VI us=tsort(gg);
  if(SZ(us)!=N) return false;
  vector<LL> ds(N,-1);
  FORR(u,us) {
    if(ds[u]==-1) ds[u]=0;
    FORR(p,G[u]) {
      LL w=p.first; int v=p.second;
      if(ds[v]!=-1&&ds[v]!=ds[u]+w) return false;
      ds[v]=ds[u]+w;
    }
  }
  return true;
}

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

  cin>>N>>M;
  REP(i,M) {
    LL w; int u,v; cin>>u>>v>>w;
    --u,--v;
    G[u].emplace_back(w,v);
  }
  cout<<(solve()?"Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 13808
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

res = 0
past = -100
for i in range(n):
    ind = a[i]-1
    res+=b[ind]
    if(ind-past ==1):
        res += c[past]
    past = ind

print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<LL,LL>
int N, K;
bool G[200010];
LL ans;
int main(){
	std::cin >> N >> K;
	for(int i = 1; i <= N; i++){
		if((i * 2) % K == 0){
			G[i] = true;
		}
	}
	for(int i = 1; i <= K; i++){
		int tmp = i;
		LL sum = 0;
		while(tmp <= N){
			if(G[tmp])sum++;
			tmp += K;
		}
		ans += sum * sum * sum;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const ll INFTY = 1001001001;

int main()
{
    int N;
    cin >> N;
    int count = 0;
    ll min_v = INFTY, ans=0, a;
    for(int i=0;i<N;++i){
        cin >> a;
        if(a < 0) ++count;
        min_v = min(min_v, abs(a));
        ans += abs(a);
    }
    
    if(count % 2){
        ans -= 2 * min_v;
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#define QUEUE_LEN  2000
#define INIT_QUEUE (queue){.head_ind = 0,.len = 0}
#define INF 32700

typedef struct{
    int data[QUEUE_LEN];
    int head_ind,len;
}queue;

static inline void enqueue(queue *dest,int num){
    dest->data[(dest->head_ind + dest->len) % QUEUE_LEN] = num;
    dest->len++;
}

static inline int dequeue(queue *q){
    int res = q->data[q->head_ind];
    q->len--;
    q->head_ind++;
    q->head_ind %= QUEUE_LEN;
    return res;
}

int main(void){
    int n,x,y;
    scanf("%d %d %d",&n,&x,&y);
    x--;
    y--;
    int anscnt[n];
    for(int i = 0;i < n;i++)anscnt[i] = 0;
    for(int ns = 0;ns < n;ns++){
        int dist[n];
        for(int i = 0;i < n;i++)dist[i] = INF;
        dist[ns] = 0;
        queue quu = INIT_QUEUE;
        enqueue(&quu,ns);
        while(quu.len){
            int node = dequeue(&quu);
            if(node + 1 < n && dist[node + 1] == INF){
                dist[node + 1] = dist[node] + 1;
                enqueue(&quu,node+1);
            }
            if(node - 1 >= 0 && dist[node - 1] == INF){
                dist[node - 1] = dist[node] + 1;
                enqueue(&quu,node-1);
            }
            if(node == x && dist[y] == INF){
                dist[y] = dist[node] + 1;
                enqueue(&quu,y);
            }
            if(node == y && dist[x] == INF){
                dist[x] = dist[node] + 1;
                enqueue(&quu,x);
            }
        }
        for(int i = 0;i < n;i++)anscnt[dist[i]]++;
    }
    for(int i = 1;i < n;i++)printf("%d\n",anscnt[i] / 2);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  ll sa = a1 * t1 + a2 * t2;
  ll sb = b1 * t1 + b2 * t2;
  if(sa == sb) {
    cout << "infinity" << endl;
    return 0;
  }
  if(sa < sb) {
    swap(sa, sb);
    swap(a1, b1);
    swap(a2, b2);
  }
  ll ans;
  if(a1 > b1)
    ans = 0;
  else {
    ll y = (b1 - a1) * t1;
    ll x = sa - sb;
    ans = y / x * 2 + 1;
    if(y % x == 0) ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> T;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	int ans = 0;
	int m = A[0], C = 0;
	for (int i = 1; i < N; i++) {
		if (A[i] - m > C) {
			ans = 1;
			C = A[i] - m;
		} else if (A[i] - m == C) {
			++ans;
		}
		chmin(m, A[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
int main()
{
	int m[10][331]={0};
	int n,s,i,a[10],f[11]={1};
	for(i=0;i<10;++i)a[i]=i;
	for(i=1;i<10;++i)f[i]=f[i-1]*i;
	do
	{
		for(s=i=0;i<10;++i)
		{
			s+=(i+1)*a[i];
			++m[i][s];
		}
	}while(std::next_permutation(a,a+10));
	while(scanf("%d%d",&n,&s)>0)
		if(s>330)puts("0");
		else printf("%d\n",m[n-1][s]/f[10-n]);
	return 0;
}

Measured memory_bytes: 648
#define MOD_TYPE 2

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
#pragma endregion

int main()
{
  init_main();

  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.length() <= k)
    cout << s << endl;
  else
  {
    cout << s.substr(0, k) << "...\n";
  }
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


char a[51][51], b[51][51];
void solve(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			cin >> a[i][j];
		}
	}
	rep(i, m) rep(j, m) cin >> b[i][j];
	rep(i, n) {
		if(i + m > n) break;
		rep(j, n){
			if(j + m > n) break;
			//if(i == 1 && j == 1) cout << 'x';
			bool ok = 1;
			rep(x, m) rep(y, m) if(a[x + i][y + j] != b[x][y]) ok = 0;
			if(ok){
				cout << "Yes";
				return;
			}
		}
	}
	cout << "No";
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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 int MAX = 100010;
ll dp[110][MAX];

int main()
{
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    // initiarize
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j < MAX; j++)
        {
            dp[i][j] = LINF;
        }
    }
    dp[0][0] = 0;
    //do dp
    for (int i = 0; i < n; i++)
    {
        for (int sum_v = 0; sum_v < MAX; sum_v++)
        {
            if (sum_v >= v[i])
            {
                dp[i + 1][sum_v] = min(dp[i][sum_v - v[i]] + w[i], dp[i][sum_v]);
            }
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }
    int maxi = 0;
    for (int sum_v = 0; sum_v < MAX; sum_v++)
    {
        if (dp[n][sum_v] <= W)
        {
            maxi = max(maxi, sum_v);
        }
    }
    cout << maxi << endl;
    return 0;
}

Measured memory_bytes: 82480
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
for i in range(n):
    if a[i] <= b[i]:
        cnt += (b[i]-a[i])//2
    else:
        cnt -= a[i]-b[i]
if cnt >= 0: print("Yes")
else: print("No")

Measured memory_bytes: 10564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int T;
    cin >> T;
    string s = T >= 30 ? "Yes" : "No";
    cout << s;
}









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


void solve(std::string S){

}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  std::string S, ans;
  std::cin >> S;

  if(S == "Sunny") ans = "Cloudy";
  if(S == "Cloudy") ans = "Rainy";
  if(S == "Rainy") ans = "Sunny";

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if ((a != b || b != c || a != c) && (a == b || b == c || c == a)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main()
{
  int64_t n, m; cin >> n >> m;
  
  int count=0;
  vector<int>a(m);
  for (int i=1; i<=m; i++) {
    cin >> a[i];
    count += a[i];
  }
  if (n<count)	cout << -1 << endl;
  else	cout << n-count << endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int A; int B; int H; int M;
  cin>>A>>B>>H>>M;
  double L=0.000000000000000000;
  double Z(12);
    Z=abs(H*30+0.5*M-M*6);
  int X=A*A; int Y=B*B;
  L=X+Y-2*A*B*cos(3.14159265358979*Z/180);
  cout<<setprecision(12)<<sqrt(L)<<endl;
}


Measured memory_bytes: 4224
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>

int main(void)
{
    uint32_t n, d, x;

    std::cin >> n >> d >> x;

    std::vector<uint32_t> a_list(n);

    for (uint32_t i=0; i < n; ++i) {
        std::cin >> a_list.at(i);
    }

    uint32_t num = n;

    for (uint32_t a : a_list) {
        for (uint32_t i=1; i*a < d; ++i) {
            num++;
        }
    }

    std::cout << num + x << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char s[15];
	while(scanf("%s",s)!=EOF)
	{
		int sum=0,sum1=0,g=0;
		if(s[0]!='A')
		{
	    	printf("WA\n");
	    	continue;
		}
	   	else
	    	sum++;
	    int i;
	    for(i=2;i<strlen(s)-1;i++)
	    {
	    	if(s[i]=='C')
	        	sum1++;
		}
		if(sum1>=2||sum1<1||s[1]=='C'||s[strlen(s)-1]=='C')
		{
	    	printf("WA\n");
	    	continue;
		}
		else
	    	sum++;
	    for(i=0;i<strlen(s);i++)
	    {
	    	if(s[i]!='A'&&s[i]!='C'&&s[i]>=65&&s[i]<=90)
	    	{
	    		printf("WA\n");
	    		g=1;
	    		break;
			}
		}
		sum++;
		if(sum==3&&g==0)
	    	printf("AC\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < N; i++) {
			set.add(sc.nextInt());
		}
		System.out.println(set.size()); 
	}
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

bool bigger( string a,string b ){
    if(a.size()>b.size())return true;
    if(a.size()<b.size())return false;
    if(a>b)return true;
    return false;
}


void sort(vector<pair<string,int>> &x){
    rep(i,x.size()){
        for(int j=i+1;j<x.size();j++){
            if(bigger(x[i].first,x[j].first)){
                swap(x[i],x[j]);
            }
        }
    }
}



int main(){
    map<string,int> mp;
    int n;
    cin>>n;
    rep(i,n){
        string s;
        int a;
        cin>>s>>a;
        mp[s] +=a;
    }
    
    vector<pair<string,int>> x;
    
    
    for(auto &data:mp){
        x.pb(make_pair(data.first,data.second));
    }
    
    sort(x);
    
    rep(i,x.size()){
        cout<<x[i].first<<" "<<x[i].second<<endl;
    }
}

Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int r,D,x;

int main(){
  cin >> r >> D >> x;
  rep(i,10){
    x = r*x-D;
    cout << x << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> V, C;
  tools::read(V, N);
  tools::read(C, N);

  i64 answer = 0;
  for (i64 i = 0; i < N; ++i) {
    answer += std::max<i64>(V[i] - C[i], 0);
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

const int ms = 200005;
int main()
{
    int n, k;
    cin >> n >> k;
    priority_queue<int>q;
    int x;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &x);
        q.push(x);
    }
    for (int i = 0; i < k; ++i)
    {
        x = q.top(), q.pop();
        x /= 2;
        q.push(x);
    }
    ll res = 0;
    for (int i = 0; i < n; ++i)
    {
        x = q.top(), q.pop();
        res += x;
    }
    printf("%lld", res);
        return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
  int D = 1000000007;
  int N, M;
  cin >> N >> M;
  bool* safe = new bool[N+1];
  for(int i=0; i<=N; i++) safe[i]=true;
  for(int i=0; i<M; i++){
    int ai;
    cin >> ai;
    safe[ai] = false;
  }
  int* dp = new int[N+1];
  dp[0] = 1;
  dp[1] = safe[1] ? 1 : 0;
  for(int i=2; i<=N; i++){
    dp[i] = safe[i] ? (dp[i-2]+dp[i-1])%D : 0;
  }
  cout << dp[N] <<endl;
  return 0;
}

Measured memory_bytes: 768
#! /usr/bin/env python
# -*- coding: utf-8 -*-

N = int(raw_input())
while N!=0:
    act = raw_input().split()
    cur = 0
    cnt = 0
    lr = [0, 0]

    for i in range(N):
        if act[i] == "ld":
            lr[0] = 0
        elif act[i] == "lu":
            lr[0] = 1
        elif act[i] == "ru":
            lr[1] = 1
        elif act[i] == "rd":
            lr[1] = 0 

        if lr == [1, 1] and cur == 0:
            cur = 1
            cnt += 1
        elif lr == [0, 0] and cur == 1:
            cur = 0
            cnt += 1

    print cnt
    N = int(raw_input())

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

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

    int A, B, C;
    cin >> A >> B >> C;

    int x = max(A, max(B, C));

    if((3 * x - A - B - C) % 2 == 0) {
        cout << (3 * x - A - B - C) / 2 << endl;
        return 0; 
    }

    x++;

    cout << (3 * x - A - B - C) / 2 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    # See:
    # https://www.youtube.com/watch?v=VSeggcnxwrc

    # KeyInsight
    # L, Rでまとめる
    # 1回の操作で幸福度が最大で2増える
    # 操作したときの内部のスコアが変化しない
    # 例外的に，すべて同じ文字の場合は変化せず，ランレングス圧縮したときに2グループのときは1増える
    # min(理論値n - 1, 初期スコア + 2 * k回)

    # つまづきポイント
    # 反転操作で，スコアが変化する/変化しない部分を明らかにする
    # 操作が1回の場合を考えて，多数回に展開
    # スコアを増やす=異なるグループを減らす

    # どうしたら気がつけそうか?
    # 同じ要素をまとめる
    # 操作を言い換える，同じことを違う言葉で表現する/異なる視点で見る
    # 理論値VS初期値 + 操作による変化を比べる

    n, k = map(int, input().split())
    s = input()
    score = 0

    for i in range(n - 1):
        if s[i] == s[i + 1]:
            score += 1

    print(min(n - 1, score + 2 * k))


if __name__ == '__main__':
    main()


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

int n, k;
std::vector<int> vec;

int main() {
    std::cin >> n >> k;
    vec.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> vec[i];
    }
    std::sort(vec.begin(), vec.end());
    std::reverse(vec.begin(), vec.end());
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += vec[i];
    }
    
    std::cout << sum << std::endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define VMAX 1000000

int main(){
  unsigned short *A,*B;
  int n,C[VMAX],i,j,k=0;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    if(A[i+1]>k)k=A[i+1];
  }

  /*counting sort*/
  
  for(i=0;i<=k;i++){
    C[i]=0;
  }
  
  for(j=0;j<n;j++){
    C[A[j+1]]++;
  }

  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
     
  return 0;
}



Measured memory_bytes: 9640
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        // 出力
        int o = c-a+b;
        System.out.println(o > 0 ? o : 0);
    }
}

Measured memory_bytes: 23252
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int n,x;
int l[1000001];
int s;
int k;
int main()
{
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>l[i];
		s=s+l[i];
		if(s>x)
		{
			cout<<i;
			k++;
			break;
		}
		else k=0;
	}
	if(k==0) cout<<n+1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
typedef pair<ll,P> lP;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
  int a[5],k,t=0;
  bool f=0;
  fr(i,5) cin>>a[i];
  cin>>k;
  fr(i,5){
    fr(j,i) if(a[i]-a[j]>k) f=1;
  }
  cout<<(f?":(":"Yay!")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int maxL = max(a, max(b, c));
  if(maxL == a)
    cout << b * c / 2 << endl;
  else if(maxL == b)
    cout << a * c / 2 << endl;
  else
    cout << a * b / 2 << endl;
  return 0;
}


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

typedef struct {
    int     no;     /* student No. */
    int     order;  /* order */
} Student;

static int
cmp_student ( const void *a, const void *b ) {
    Student *a_, *b_;
    a_ = (Student*)a;
    b_ = (Student*)b;

    return a_->order - b_->order;
}

int main (void) {
    int n_students;
    scanf("%d", &n_students);

    int i;
    Student st[n_students];
    for ( i=0; i<n_students; i++ ) {
        st[i].no = i+1;
        scanf("%d", &st[i].order);
    }
    qsort(st, n_students, sizeof(Student), cmp_student);

    for ( i=0; i<n_students; i++ ) {
        printf("%d ", st[i].no);
    }
    printf("\n");
    return EXIT_SUCCESS;
}


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

int main() {
  
  int N;
  int hasu,oturi;
  cin >> N;
  hasu=N%1000;
  if(hasu>0){
  oturi=1000-hasu;
  }else{
    oturi=0;
  }
  
  cout << oturi  <<endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s == "RRR") cout << "3\n";
    else if (s.find('R') != string::npos) {
        if (s == "RRS" || s == "SRR") cout << "2\n";
        else cout << "1\n";
    } else cout << "0\n";
    return 0;
}


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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

bool p[9] = { false };

int main()
{
	string S;
	ll ans = 0;
	int digits;

	cin >> S;
	digits = S.length();
	
	if (digits == 1) {
		cout << S << endl;
		return 0;
	}

	while (true) {
		int s = 0;
		int len = 1;
		bool end = true;

		rep(i, digits - 1) {
			if (!p[i]) len++;
			else {
				string sub = S.substr(s, len);
				ll add = atoll(sub.c_str());
				ans += add;

				s = i + 1;
				len = 1;
			}
			if (i == digits - 2) {
				string sub = S.substr(s, len);
				ll add = atoll(sub.c_str());
				ans += add;
			}
		}

		rep(i, digits - 1) if (!p[i]) end = false;
		if (end) break;

		rep(i, digits - 1) {
			if (p[i]) {
				p[i] = false;
				continue;
			}
			p[i] = true;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve(System.in, System.out);
    }

    /*
    F V F M V
    F V F M F M V
    F V F M F V M
    F V F M F M F M V
    F V F M F V M F M
    F V F M F V M F M F M
     */
    public static void solve(InputStream is, PrintStream os) {
        try (Scanner sc = new Scanner(is)) {
            int n = sc.nextInt();
            String[] seat = new String[n];
            seat[0] = read(0, sc, os);
            seat[n - 1] = read(n - 1, sc, os);
            if ("Vacant".equals(seat[0]))
                return;
            int left = 0;
            int right = n - 1;
            while (right - left > 1) {
                int mid = left + (right - left) / 2;
                seat[mid] = read(mid, sc, os);
                if ("Vacant".equals(seat[mid]))
                    return;
                if (isOk(seat, left, mid, right))
                    right = mid;
                else
                    left = mid;
            }

        }
    }

    private static boolean isOk(String[] seat, int left, int mid, int right) {
        if (seat[left].equals(seat[mid]) && (mid - left) % 2 == 0)
            return false;
        if (seat[right].equals(seat[mid]) && (right - mid) % 2 == 0)
            return true;
        if (!seat[left].equals(seat[mid]) && (mid - left) % 2 == 1)
            return false;
        if (!seat[right].equals(seat[mid]) && (right - mid) % 2 == 1)
            return true;
        return true;
    }

    private static String read(int n, Scanner sc, PrintStream os) {
        os.println(n);
        os.flush();
        String line = sc.next();
        return line;
    }
}


Measured memory_bytes: 25792
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		if(k==1) {
			System.out.println("0");
		}
		else {
			System.out.println(n-(k-1)-1);
			
		}

	}

}


Measured memory_bytes: 22604
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] p = nextIntArray(sc, N);

		sc.close();

		double[] sum = new double[N + 1];
		sum[0] = 0;

		for (int i = 0; i < N; i++) {
			sum[i + 1] = sum[i] + (1 + p[i]) / 2.0;
		}

		double ans = 0;

		for (int i = 1; i <= N - K + 1; i++) {
			double x = sum[i - 1 + K] - sum[i - 1];
			ans = Math.max(ans, x);
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 84224
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> Xs(N);
  
  int ans = 0;
  for(int i = 0; i < N;i++){
    int x; cin >> x;
    if(abs(K-x) > x){
      ans += x;
    }
    else{ans += abs(K-x);}
  }
  
  cout <<ans * 2 <<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    multiset<int> s;
    s.insert(a[n - 1]);
    for(int i = n - 2; i >= 0; i--) {
        auto p = s.upper_bound(a[i]);
        if(p == s.end())
            s.insert(a[i]);
        else {
            s.erase(p);
            s.insert(a[i]);
        }
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

var n, m, q, ans int
var a, b, c, d []int

func calc(arr []int) int {
	tot := 0
	// fmt.Println(a)
	for i := range a {
		// fmt.Println(arr[b[i]], arr[a[i]], c[i])
		if (arr[b[i]] - arr[a[i]]) == c[i] {
			tot += d[i]
		}
	}
	return tot
}

func rec(i, pre int, a []int) {
	if i == n {
		// fmt.Println(a)
		ans = max(ans, calc(a))
		return
	}

	for j := pre; j < m+1; j++ {
		rec(i+1, j, append(a, j))
	}
}

func main() {
	n, m, q = readInt(), readInt(), readInt()

	a, b, c, d = make([]int, q), make([]int, q), make([]int, q), make([]int, q)
	for i := range a {
		a[i] = readInt() - 1
		b[i] = readInt() - 1
		c[i] = readInt()
		d[i] = readInt()
	}

	rec(0, 1, []int{})

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 5888
a,b,c,d = map(int,input().split())
ans1 = b*d
ans2 = a*c
ans3 = a*d
ans4 = b*c
ans = max(ans1,ans2,ans3,ans4,)
if 0 in range(a,b+1) or 0 in range(c,d+1):
  if 0 > ans:
    ans =0
print(ans)

Measured memory_bytes: 9180
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut count = 0usize;
    for i in 0..s.len() {
        if s[i] != t[i] {
            count += 1;
        }
    }
    println!("{}", count);
}


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

int main() {
  int N,M;
  cin >> N >> M;
  M = 2 * M;
  vector<int> road(M); 
  for (int i = 0; i < M; i++) {
    cin >> road.at(i);
  }
  vector<int>ans(N + 1);
  for (int i = 0; i < M; i++) {
    for ( int j = 1; j <= N ; j++) {
      if(road.at(i) == j){
        ans.at(j) ++;
      }
    }
  }
  for(int i = 1; i <= N; i++){
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define LL long long 
using namespace std;
int main(){
    map<LL,LL>ma;
    ma.clear();
    LL n,b;
	int i;
    cin>>n;
    for(i=0;i<n;i++){
    	cin>>b;
		ma[b]++;
    }
	LL a[3],ans=0;
    map<LL,LL>::iterator it = ma.end();
    int flag = 1;
	for(it=(--ma.end());;it--){
		if((it->second)>=4&&flag==1)
	 	{
	 		a[ans++]=(it->first);
	 		a[ans++]=(it->first);
	 		break;
	 	}
	 	if((it->second)>=2)
	 	{
	 		a[ans++]=(it->first);
	 		flag = 2;
	 	}
	 	if(ans==2)break;
	 	if(it==ma.begin()) break;
	}
	if(ans==2)
	cout<<a[0]*a[1]<<endl;
	else 
	puts("0");
    return 0;
}
/*
4
100000000 100000000 100000000 100000000
*/

Measured memory_bytes: 6528
import java.util.*;
 
class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int q=sc.nextInt();
		
		int l[]=new int[q];
		int r[]=new int[q];
		int num[]=new int[n];
		
		String s =sc.next();
		char c[]=s.toCharArray();
		
		int count=0;
		int max=0;
		
		for(int i=0;i<q;++i) {
			l[i]=sc.nextInt();
			r[i]=sc.nextInt();
		}
		
		for( int i=s.length()-1;i>=0;--i) {
			if (c[i]=='C') {
				if(i-1>=0 && c[i-1]=='A') {
					++count;				
				}
			}
			if (i-1>=0)num[i-1]=count;	
		}
		
		for (int i=0;i<q;++i) {
			System.out.println(num[l[i]-1]-num[r[i]-1]);
		}

	}
	
}

Measured memory_bytes: 80408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int A=0;
  for (int i=0; i<N; i++){
    int X;
    cin >> X;
    if ( X < K-X ){
      A += 2*X;
    }else {
      A += 2*( K-X );
      
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 3628
package main

import (
	"container/heap"
	"fmt"
)

type Scanner struct{}

func (sc Scanner) Next() (s string) {
	fmt.Scan(&s)
	return
}

func (sc Scanner) NextInt() (i int) {
	fmt.Scan(&i)
	return
}

type MinCostStatus struct {
	Visited   int
	PrevPoint int
}

type Status struct {
	MinCostStatus
	Cost int
}

type PriorityQueueStatus []*Status

func (pq PriorityQueueStatus) Len() int {
	return len(pq)
}

func (pq PriorityQueueStatus) Less(i, j int) bool {
	return pq[i].Cost < pq[j].Cost
}

func (pq PriorityQueueStatus) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueueStatus) Push(data interface{}) {
	*pq = append(*pq, data.(*Status))
}

func (pq *PriorityQueueStatus) Pop() interface{} {
	l := len(*pq)
	item := (*pq)[l-1]
	*pq = (*pq)[0 : l-1]
	return item
}

func main() {
	var sc Scanner
	v, e := sc.NextInt(), sc.NextInt()
	m := make([]map[int]int, v)
	for i := 0; i < v; i++ {
		m[i] = make(map[int]int)
	}
	for i := 0; i < e; i++ {
		s, t, d := sc.NextInt(), sc.NextInt(), sc.NextInt()
		m[s][t] = d
	}
	pq := make(PriorityQueueStatus, 0)
	start := &Status{
		MinCostStatus: MinCostStatus{
			Visited:   0,
			PrevPoint: 0,
		},
		Cost: 0,
	}
	memo := make(map[MinCostStatus]int)
	heap.Push(&pq, start)
	for pq.Len() > 0 {
		now := heap.Pop(&pq).(*Status)
		if now.Visited == (1<<uint(v))-1 && now.PrevPoint == 0 {
			fmt.Println(now.Cost)
			return
		}
		for k, v := range m[now.PrevPoint] {
			if now.Visited&(1<<uint(k)) == 0 {
				minCostStatus := MinCostStatus{
					Visited:   now.Visited | (1 << uint(k)),
					PrevPoint: k,
				}
				cost := now.Cost + v
				if v, ok := memo[minCostStatus]; !ok || (ok && cost < v) {
					next := &Status{
						MinCostStatus: minCostStatus,
						Cost:          cost,
					}
					memo[minCostStatus] = cost
					heap.Push(&pq, next)
				}
			}
		}
	}
	fmt.Println(-1)
}



Measured memory_bytes: 43264
import sys

N, M = map(int, sys.stdin.readline().split())
ab = sorted([list(map(int, sys.stdin.readline().split()))
             for _ in range(M)])

left, right = None, None
cnt = 0

for a, b in ab:
    a, b = min(a, b), max(a, b)
    if left is None:
        left, right = a, b
        continue
    if a < right and b > left:
        left = max(left, a)
        right = min(right, b)
    else:
        cnt += 1
        left, right = a, b

print(cnt + 1)

Measured memory_bytes: 30252
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int a[N];
	for(int i=0;i<N;i++)
		cin >> a[i];
	int max=10000;
	int result = 0;
	int cp=0;
	while(cp<N-1)
	{
		if(a[cp]!=a[cp+1])
		{
			cp++;
			continue;
		}
		result++;
		a[cp+1]=max--;
		if(cp==N-2)
			break;
		if(a[cp+1]==a[cp+2])
			cp+=2;
		if(a[cp+1]!=a[cp+2])
			cp+=1;
	}
	cout << result << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a[4];
   for(int i=0;i<4;i++) cin >> a[i];
   sort(a,a+4);
   if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) cout << "YES" << endl;
   else cout << "NO" << endl;
}


Measured memory_bytes: 256
"""
234 23
134 14
124 14
123 23
"""
import copy
N = int(input())
initial = [list(range(1, N + 1)) for i in range(N)]

for i in range(N):
    initial[i].pop(i)
# print(initial)
neighbors = copy.deepcopy(initial)

S = sum(neighbors[-1])  # S候補の最大値

while True:
    # print(S)
    # print(neighbors)
    for i, tyouten in enumerate(neighbors):
        delta = sum(tyouten) - S
        # print(delta)
        if delta in tyouten:
            tyouten.remove(delta)
            neighbors[delta - 1].remove(i + 1)
        elif delta == 0:
            continue
        else:
            S -= 1
            neighbors = copy.deepcopy(initial)
            break
    else:
        break

# print(neighbors)

ans = []
for i, tyouten in enumerate(neighbors):
    for j in tyouten:
        if j > i+1:
            ans.append(str(i+1)+" "+str(j))

print(len(ans))
for s in ans:
    print(s)


Measured memory_bytes: 4356