akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
bool prime[10000001];
int main() {
    for(int i=3;i<3162;i+=2)if(!prime[i])for(int j=i*2;j<10000001;j+=i)prime[j]=1;
    int n;
    while(cin>>n,n){
        if(!(n%2))n--;
        while(prime[n]||prime[n-2]||prime[n-6]||prime[n-8])n-=2;
        cout<<n<<endl;
    }
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    char c;
    cin >> c;

    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
'''
左子右兄弟表現で記載する。
元々の木の形を変形させて保存しておく。
具体的には左の木は自分の子供
右の木は自分の兄弟を連結させる。
深さは親を辿っていって、根につくまで加算することで計算する

'''


class Node:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left
        self.right = right

    def get_depth(self):
        if self.parent == -1:
            return 0
        else:
            depth = 1
            t = Nodes[self.parent]
            while t.parent != -1:
                t=Nodes[t.parent]
                depth += 1
            return depth

    def get_type(self):
        if self.parent == -1:
            return 'root'
        elif self.left == None:
            return 'leaf'
        else:
            return 'internal node'


def decode_node_data(n):
    '''
    n...受け取る文字列、一行ずつ
    一行ずつ、文字列からノードに変化する
    '''
    global Nodes
    num_of_elem = len(n)
    if num_of_elem < 2:
        raise ValueError
    elif num_of_elem == 2:  # leaf
        pass

    else:
        id, num_of_children = int(n[0]), int(n[1])
        # 子供
        children = n[2:]
        # まず、一人目の子供をとりあえず左に格納する
        Nodes[id].left = int(children[0])
        prev_child = None

        for c in children:
            # 子Nodeの親を登録しておく
            Nodes[int(c)].parent = id
            if prev_child != None:
                # 兄弟の右の木にprev_childを登録する
                Nodes[prev_child].right = int(c)

            # かこに同じdepthの子供がいる場合、それを登録する
            prev_child = int(c)


MAX_NODES = 100001
Nodes = [Node(-1, None, None) for _ in range(MAX_NODES)]

if __name__ == "__main__":

    num_of_nodes = int(input())
    node_data = []
    for _ in range(num_of_nodes):
        node_data.append(input().split(' '))

    for n in node_data:
        decode_node_data(n)

    for node_id in range(num_of_nodes):
        type = Nodes[node_id].get_type()
        children = []
        #葉でなければ子ノードを集める
        if type != 'leaf':
            #左がついてない時はleaf
            if Nodes[node_id].left != None:
                c = Nodes[node_id].left
                children.append(c)
                #右は兄弟なので追加する
                while Nodes[c].right != None:
                    c = Nodes[c].right
                    children.append(c)
        print('node {0}: parent = {1}, depth = {2}, {3}, [{4}]'.format(
            node_id, Nodes[node_id].parent, Nodes[node_id].get_depth(), type,
            ', '.join(map(str, children))))



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

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) (container).begin(), (container).end()
#define sortall(container) (sort((container).begin(), (container).end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
T getSum(std::vector<T>& v) {
	T ret = 0;
	for (T& x : v) ret += x;
	return ret;
}

template <typename T>
istream& operator >> (istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;  return is;
}

template <typename S, typename T>
istream& operator >> (istream & is, pair<S, T> & p) {
	is >> p.first >> p.second; return is;
}

istream& operator >> (istream & is, point & p) {
	is >> p.x >> p.y;          return is;
}

template <typename T>
ostream& operator << (ostream & os, const vector<T> & vec) {
	for (const T& x : vec) os << x << " "; return os;
}

template <typename T>
ostream& operator << (ostream & os, const vector<vector<T>> & mat) {
	for (const vector<T>& m : mat)
		os << m << endl; return os;
}
template <typename S, typename T>
ostream& operator << (ostream & os, const pair<S, T> & p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template <typename T>
ostream& operator << (ostream & os, const set<T> & s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream & os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream & os, const point & p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	int X, A;
	cin >> X >> A;

	if (X < A) say(0);
	else say(10);

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main (String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String side[] = line.split(" ");
		int x = Integer.parseInt(side[0]);
		int y = Integer.parseInt(side[1]);	
		int area = x * y;
		int cir  = 2 * (x + y); 
		System.out.println(area + " " +cir);
	}
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    int n; cin>>n;
    int s=196471;
    REP(i,n){
        int y,m,d;
        cin>>y>>m>>d;

        d+=200*((y-1)/3)+195*((y-1)-(y-1)/3);
        if(y%3==0) d+=20*(m-1);
        else d+=19*((m-1)/2)+20*((m-1)-(m-1)/2);
        cout<<s-d<<endl;
    }
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
using namespace std;
int main()
{
    fIO
    int a,b;
    cin>>a>>b;
    int ans=max(2*a-1,max(2*b-1,a+b));
    cout<<ans;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

string GenZero(int len) {
    string res = "";
    for (int i = 0; i < len; ++i) {
        res += '0';
    }
    return res;
}

void solve() {
    string a, b;
    cin >> a >> b;

    int add_zero = a.size() - b.size();
    if (add_zero > 0) {
        b = GenZero(add_zero) + b;
    } else {
        a = GenZero(add_zero * -1) + a;
    }

    string ans;
    if (a > b) {
        ans = "GREATER";
    } else if (a < b) {
        ans = "LESS";
    } else {
        ans = "EQUAL";
    }

    cout << ans << "\n";
}


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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n,m,q;
	cin>>n>>m>>q;
  int d[555][555]={};
	rep(i,m){
		int l,r;
		cin>>l>>r;
		d[l][r]++;
	}
	rep(i,n+1)rep(j,n+1)d[i][j+1]+=d[i][j];
	rep(i,n+1)rep(j,n+1)d[i+1][j]+=d[i][j];

	while(q--){
   int p,q;
	 cin>>p>>q;
	 cout<<d[q][q]-d[p-1][q]-d[q][p-1]+d[p-1][p-1]<<endl;
	}

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int n;
int num[11];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> num[i];
	}
	int pf[10000] = { 0 };
	for (int i = 0; i < n; ++i) {
		for (int j = 2; j <= 1000; ++j) {
			int index = 0;
			for (;;) {
				if (num[i] == 1||num[i]%j!=0) break;
				if (num[i] % j == 0) {
					num[i] /= j;
					index++;
				}
				pf[j] = max(index, pf[j]);
			}
		}
	}
	int ans = 1;
	for (int i = 2; i <= 1000; ++i) {
		for (int j = 0; j < pf[i]; ++j) {
			ans *= i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

using namespace std;

int main(){
  string s; cin >> s;
  replace(s.begin(), s.end(), ',', ' ');
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){
ll a,b,c ,sum=0;
	cin>>a>>b;
	for(int i=0 ; i<b ; i++)
    {  cin>> c ;
      sum +=c ;

    }
if(sum >= a){cout << "Yes" <<endl ;}
else cout << "No" <<endl ;

    return 0 ;
}


Measured memory_bytes: 256
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int M;

int dp[2010 * 3 + 1][2010 + 1];

inline void add(int &x, int y) {
    x += y;
    if (x >= M) {
        x -= M;
    }
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n >> M;
    dp[0][0] = 1;
    rep(i, 1, n * 3 + 1) {
        rep(j, 0, n + 1) {
            add(dp[i][j], dp[i - 1][j]);
            if (j > 0) {
                if (i >= 2) {
                    add(dp[i][j], 1LL * dp[i - 2][j - 1] * (i - 1) % M);
                }
                if (i >= 3) {
                    add(dp[i][j], 1LL * dp[i - 3][j - 1] * (i - 2) % M * (i - 1) % M);
                }
            }
        }
    }
    int ans = 0;
    rep(j, 0, n + 1) {
        add(ans, dp[n * 3][j]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 47360
# pragma GCC optimize("Ofast")
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }


int main(){
    string ans = "UNRESTORABLE";
    string s,t; cin >> s >> t;
    int i;
    for(i=s.length()-t.length();i>=0;i--){
        bool judge = false;
        rep(j,t.length()){
            if(s[i+j] != '?' && s[i+j] != t[j]){ //一致しない時
                break;
            }
            if(s[i+j] == t[j]) judge = true; //一致した時
            if(j==t.length()-1) goto fill;
        }
    }
    cout << ans;
    return 0;
    
    fill:
    rep(j,t.length()){
        s[i+j] = t[j];
    }
    rep(i,s.length()){
        if(s[i]=='?') s[i] = 'a';
    }
    cout << s;
    return 0;  
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    b: [i32; n-1],
  }
  let mut sum = 0;
  for i in 0 .. n {
    if i == 0 {
      sum += b[i];
    } else if i == n - 1 {
      sum += b[i-1];
    } else {
      sum += cmp::min(b[i-1], b[i]);
    }
  }

  puts!("{}\n", sum);
}


Measured memory_bytes: 4352
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    rep(i,0,n) cin>>v[i];
    ll ans=1e13;
    for(int i=0;i+k-1<n;i++){
        ans=min(ans, v[i+k-1]-v[i]+min(abs(v[i]),abs(v[i+k-1])));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n,a[200005],ans=0,mm,k;
    bool ok[200005]={0};
    umap mp;
    vc s,t;
    cin >> n;
    rep(i,0,n-1){
    	cin >> a[i];
    }
    mp.insert({-a[0],1});
    rep(i,1,n-1){
    	if(mp.find(a[i]-i)!=mp.end()){
    		k=mp.at(a[i]-i);
    		ans+=k;
    	}
    	if(mp.find(-a[i]-i)!=mp.end()){
    		mp.at(-a[i]-i) = mp.at(-a[i]-i)+1;
    	} else mp.insert({-a[i]-i,1});
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17600
A, B, C, K = map(int,input().split())

ans = 0
if K >= A:
  ans += A
  K -= A
else:
  ans += K
  K = 0

if K >=B:
  K -= B
else:
  K = 0

if K >= C:
  ans -= C
else:
  ans -= K

print(ans)

Measured memory_bytes: 9188
N = int(input())
x = []
y = []
for i in range(N):
    new_x, new_y = map(int, input().split())
    x.append(new_x)
    y.append(new_y)

dist_list = []
count_list = []
for i in range(N):
    for j in range(i+1, N):
        p = x[i] - x[j]
        q = y[i] - y[j]
        for index, dist in enumerate(dist_list):
            x_dist, y_dist= dist
            if (x_dist == p and y_dist == q) or (x_dist == -p and y_dist == -q):
                count_list[index] += 1
                break
        else:
            dist_list.append([p, q])
            count_list.append(1)

if N == 1:
    print(1)
else:
    print(N - max(count_list))

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> v(m);
  for (int i=0; i<m; i++) {
  	cin >> v[i];
  }
  int result = accumulate(v.begin(), v.end(), 0);
  if (result > n) {
    cout << -1 << endl;  	
  } else {
    cout << n - result << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int a[3], k; cin >> a[0] >> a[1] >> a[2] >> k;
  int mi = 0;
  for(int i = 0; i < 3; i++){
    if(a[i] > a[mi]) mi = i;
  }
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(i == mi) ans += a[i] * pow(2, k);
    else ans += a[i];
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int n;
  cin >> n;
  int a[110];
  rep(i, n) cin >> a[i];

  sort(a, a+n);

  int min = 0;

  rep(i, n-1) {
    min += a[i+1] - a[i];
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
H, W, K = map(int,input().split())
masu = []
subete = 0
yoko = [0]*H
tate = [0]*W
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == '#':
            yoko[i] += 1
            tate[j] += 1
            subete += 1

    masu.append(s)

kotae = 0

for i in range(2**(H+W)):
    nuri = bin(i)[2:]
    ans = 0 + subete

    while len(nuri) < H+W:
        nuri = '0' + nuri 
    for j in range(H+W):
        if nuri[j] == '1':
            if j < H:
                ans -= yoko[j]
                for l in range(H,H+W):
                    if nuri[l] == '1':
                        if masu[j][l-H] == '#':
                            ans += 1
            if H <= j:
                ans -= tate[j-H]
    if ans == K:
        kotae += 1

     


print(kotae)





Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
const int MAXN=30010;
int n,ans,s1,s2,s3;
char c[MAXN];
int main () {
	scanf("%d%s",&n,c+1);
	for (int i=0;i<=9;i++) {
		for (int j=0;j<=9;j++) {
			for (int k=0;k<=9;k++) {
				s1=s2=s3=0;
				for (int l=1;l<=n;l++) {
					if (c[l]-'0'==k) {s3|=s2;}
					if (c[l]-'0'==j) {s2|=s1;}
					if (c[l]-'0'==i) {s1=1;}
					if (s3) {ans++;break;} 
				}
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
import numpy as np

input()
H = np.array([int(h) for h in input().split()])
k = np.array([1, -1])
c = 0
while (H >= 1).any():
    m = H[H >= 1].min()
    n_blocks = (np.convolve(H >= 1, k))
    c += (n_blocks < 0).sum() * m
    H = np.maximum(H - m, 0)

print(c)


Measured memory_bytes: 12508
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll d=1e9+5;
  auto f=[](ll x){
    return x*x*x*x*x;
  };
  ll k=0;
  rep(i,1,100000){
    if(f(i)-f(i-1)>=d){
      k=i;
      break;
    }
  }
  ll x;cin>>x;
  rep(i,-k,k+1){
    rep(j,i,k+1){
      if(f(j)-f(i)==x){
        cout<<j spa i<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
int A[MAX_N];

void solve() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b; a--; b--;
		A[a]++; A[b]++;
	}
	rep(i, 0, N) {
		if(A[i] % 2) {
			cout << "NO\n"; return;
		}
	}
	cout << "YES\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int K; cin >> K;
    int ans = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a;
  cin >> b;
 
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  } else {
    cout << "Even" << endl;
  }
}

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

long long h, w;
vector<vector<long long>> c;

long long solve();

int main() {
  cin >> h >> w;
  c.assign(h, vector<long long>(w, 0));
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      cin >> c[i][j];
      c[i][j] = 1 - c[i][j];
    }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      if (c[i][j]) {
        if (i != 0 && j != 0)
          c[i][j] = max(c[i][j],
                        min({c[i - 1][j], c[i][j - 1], c[i - 1][j - 1]}) + 1);
        res = max(res, c[i][j]);
      }
  return res * res;
}



Measured memory_bytes: 18132
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
  int H,W;
  cin >> H >> W;
  char S[H+1][W+1];
  REP(i,H)
    REP(j,W)
      cin >> S[i][j];

  REP(i,H)
    REP(j,W) {
      if (S[i][j]=='#' && S[i][j+1]=='#') S[i][j]=S[i][j+1]='B';
      if (S[i][j]=='#' && S[i+1][j]=='#') S[i][j]=S[i+1][j]='B';
      if (S[i][j]=='#' && S[i][j+1]=='B') S[i][j]=S[i][j+1]='B';
      if (S[i][j]=='#' && S[i+1][j]=='B') S[i][j]=S[i+1][j]='B';
      if (S[i][j]=='B' && S[i][j+1]=='#') S[i][j]=S[i][j+1]='B';
      if (S[i][j]=='B' && S[i+1][j]=='#') S[i][j]=S[i+1][j]='B';
    }

  bool flg=true;
  REP(i,H)
    REP(j,W)
      if (S[i][j]=='#') flg=false;

  cout << (flg?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b,d,i,j,c=0;
    string s;
    cin>>a>>s;
    b=s.length();
    for(i=0;i<b;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-12;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=1e5+5;
int n,x[N],y[N];
char d[N];

double f(double t){
	double min_x=1e18;
	double max_x=-1e18;
	double min_y=1e18;
	double max_y=-1e18;
	REP(i,n){
		double newx=x[i];
		double newy=y[i];
		if(d[i]=='L') newx-=t;
		else if(d[i]=='R') newx+=t;
		else if(d[i]=='U') newy+=t;
		else if(d[i]=='D') newy-=t;
		min_x=min(min_x,newx);
		max_x=max(max_x,newx);
		min_y=min(min_y,newy);
		max_y=max(max_y,newy);
	}
	return (max_x-min_x)*(max_y-min_y);	
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	REP(i,n) cin>>x[i]>>y[i]>>d[i];
	double l=0,r=1e9;
	double res=1e18;
	REP(_,200){
		double ml=(r+l*2.0)/3.0;
		double mr=(r*2.0+l)/3.0;
		double resl=f(ml);
		double resr=f(mr);
		res=min(res,min(resl,resr));
		if(resl<resr) r=mr;
		else l=ml;
	}
	cout<<fixed<<setprecision(15)<<res<<'\n';
}



Measured memory_bytes: 4688
import math
X = int(input())
count = 0
for i in range(X, 100004):
    search_end = math.ceil(math.sqrt(i))
    for j in range(2, search_end+1):
        if i % j == 0:
            count = 1
            break
    if count == 0 or (count == 1 and i == j):
        print(i)
        break
    count = 0


Measured memory_bytes: 9116
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n, d, x, a;
    cin >> n >> d >> x ;
    for (int i = 0; i < n; i++) {
        cin >> a;
        x += (d - 1) / a + 1;
    }
    cout << x << endl;
}







Measured memory_bytes: 256
N = int(input())
s = input()
t = input()

if s == t:
    print(len(s))
    exit()

x = N-1
for i in range(1,N):
    if s[i:] == t[:-i]:
        break
    else:
        x -= 1

print(len(s) + len(t) - x)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        string s = cin.next();
        string t = cin.next();
        int a=cin.nextInt();
        int b=cin.nextInt();
        string u=cin.next();
        if(s==u)a--;
        else if(t==u)b--;
        Console.WriteLine("{0} {1}",a,b);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int X, A;
int main(){

    cin >> X >> A;
    if(X < A){
        cout << 0 << endl;
    }
    else if(X >= A){
        cout << 10 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    int n,k ;
    cin >> n >>  k ;
    int p[n] ;
    for (int i = 0; i < n; i++) cin >> p[i] ;

    sort(p,p+n) ;

    int ans = 0 ;
    for (int i = 0; i < k; i++){
        ans+=p[i] ;
    }

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

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

int main(){
  vector<int>a(3);
  for(int i=0; i<3; ++i)cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  int sum=0;

   sum+=abs(a[0]-a[1])+abs(a[1]-a[2]);

  cout << sum << endl;
}
    

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

int main(){
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> a(A);
  vector<int> b(B);
  vector<int> c(C);
  for(int i=0;i<A;i++){
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  for(int i=0;i<B;i++){
    cin >> b[i];
  }
  sort(b.rbegin(), b.rend());
  for(int i=0;i<C;i++){
    cin >> c[i];
  }
  sort(c.rbegin(), c.rend());
  vector<int> ans(X+Y);
  for(int i=0;i<X;i++){
    ans[i]=a[i];
  }
  for(int i=0;i<Y;i++){
    ans[X+i]=b[i];
  }
  sort(ans.begin(), ans.end());
  for(int i=0;i<min(C,X+Y);i++){
    if(c[i]>ans[i]){
      ans[i]=c[i];
    }
    else break;
  }
  int64_t ANS=0;
  for(int i=0;i<X+Y;i++){
    ANS+=ans[i];
  }
  cout << ANS << endl;
  return 0;
}

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

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	int n;
	cin >> n;
	map<string, int> ans;
	string str;
	for( int i=0; i<n; i++ ) {
		cin >> str;
		if( !ans.count(str) ) {
			ans[str] = 0;
		}
		ans[str]++;
	}
	int max = 0;
	for( auto it=ans.begin(); it!=ans.end(); it++ ) {
		if( max<it->second ) {
			max = it->second;
		}
	}
	for( auto it:ans ) {
		if( it.second==max ) {
			cout << it.first << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 25216
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define F first
#define S second
#define M 1000000007

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll n,m,i,j;
	cin>>n>>m;
	ll a[m];
	for(i=0;i<m;i++)
	cin>>a[i];
	inc(a,m);
	ll d[m-1];
	for(i=0;i<m-1;i++)
	d[i]=a[i+1]-a[i];
	inc(d,m-1);
	ll s=0;
	for(i=0;i<m-n;i++)
	s+=d[i];
	cout<<s;
	
	return 0;
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    map<char,int> mp;
    for(int i=0;i<n;i++){
        char tmp;
        cin>>tmp;
        if(!mp.count(tmp)){
            mp[tmp]=1;
        }else{
            mp[tmp]++;
        }
    }
    if(mp.size()==4){
        cout<<"Four"<<endl;
    }else{
        cout<<"Three"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] g = new int[15][15];
        // 初期化
        for (int i = 0; i < 15; i++) {
            for (int j = 0; j < 15; j++) {
                g[i][j] = -1;
            }
        }
        // 証言
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            for (int j = 0; j < a; j++) {
                int x = sc.nextInt() - 1;
                int y = sc.nextInt();
                g[i][x] = y;
            }
        }
        int ans = 0;
        for (int i = 0; i < (1 << n); ++i) {
            int[] d = new int[n];
            for (int j = 0; j < n; j++) {
                if ((i >> j & 1) == 1) {
                    d[j] = 1;
                }
            }
            boolean flag = true;
            for (int j = 0; j < n; j++) {
                if (d[j] == 1) {
                    for (int k = 0; k < n; k++) {
                        if (g[j][k] == -1) continue;
                        if (g[j][k] != d[k]) flag = false;
                    }
                }
            }
            if (flag) {
                ans = Math.max(ans, Integer.bitCount(i));
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24532
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const N = Number(input[0])
  const h = input[1].split(' ').map(n => Number(n))
  let i = 0
  let ans = 0
  while (total(h) > 0) {
    while (h[i] <= 0) {
      i++
    }
    for (let j = i; j < N && h[j] > 0; j++) {
      h[j]--
    }
    ans++
  }
  console.log(ans)
}

const total = (h) => {
  let total = h.reduce((p, c) => {
    return p + c
  })
  return total
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);


int n, m;
int l[100100], r[100100];

int solve() {
    int L = -1, R = inf;
    for (int i = 0; i < m; i++) {
        L = max(L, l[i]);
        R = min(R, r[i]);
    }
    return max(0, R-L+1);
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> l[i] >> r[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

int main(int argc, char* argv[])
{
  int A, B, C, X;

  std::cin >> A >> B >> C >> X;
  int count = 0;
  for (int a = 0; a <= A; a++) {
    for (int b = 0; b <= B; b++) {
      for (int c = 0; c <= C; c++) {
	if (500 * a + 100 * b + 50 * c == X) {
	  count++;
	}
      }
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
void init()
{
    int n=0,sum=0;
    for(int i=1; i<=100; i++)
    {
        printf("%d %d\n",n,sum);
        n^=i;
        sum^=n;
    }
}
long long xo(long long x)///A0xorA1...xorAx
{
    long long n=0,sum=0;
    if(x<=7)
        for(long long i=1; i<=x; i++)
            {
                n^=i;
                //sum^=n;
            }
    else
    {
        long long m=x;
        m-=7;
        long long pos=m%8;
        if(x<4)
            for(long long i=1; i<=x; i++)
                n^=i;
        m-=3;
        long long pos1=n%4;
        for(long long i=x-pos1+1; i<=x; i++)
                n^=i;
        for(long long i=x-pos+1; i<=x; i++)
            {
                n^=i;
                //sum^=n;
            }
    }
    return n;
}
int main()
{
    long long l,r;
    //init();
    //scanf("%d",&T);

        scanf("%lld %lld",&l,&r);
        //cout << xo(r) << " " << xo(l-1) << endl;
        printf("%lld\n",xo(r)^xo(l-1));

    return 0;
}


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

typedef vector<vector<ll>> graph;

ll dfs(ll u, graph &g, vector<bool> &used)
{
    if (used[u] == true)
        return 1;
    used[u] = true;

    ll res = 1;
    for (auto &&v : g[u])
    {
        if (used[v] == false)
        {
            res += dfs(v, g, used);
        }
    }
    return res;
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B)
{
    /*
    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    sort(B.begin(), B.end());
    B.erase(unique(B.begin(), B.end()), B.end());
    */
    graph g = graph(N);
    for (ll i = 0; i < M; i++)
    {
        g[A[i]].push_back(B[i]);
        g[B[i]].push_back(A[i]);
    }
    vector<bool> used(N, false);
    ll size_max = 0;
    //cout << "debug" << endl;

    for (ll i = 0; i < N; i++)
    {
        ll tmp = dfs(i, g, used);
        size_max = max(size_max, tmp);
        //cout << tmp << endl;
    }
    cout << size_max << endl;
}

signed main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &A[i]);
        A[i]--;
        scanf("%lld", &B[i]);
        B[i]--;
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 29820
o = str(input())
e = str(input())

if len(o) == len(e):
    for i in range(len(o)):
        print(o[i],end='')
        print(e[i],end='')

else:
    for i in range(len(o)-1):
        print(o[i],end='')
        print(e[i],end='')
    print(o[-1])


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define chmax(a,b) a = max(a,b)

int dp[2][305][1000];
int a[105], b[105], c[105], d[105];

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

  int n,x,y;
  cin>>n>>x>>y;
  rep(i,n) cin>>a[i]>>b[i]>>c[i]>>d[i];

  auto cur = dp[0];
  auto nxt = dp[1];

  const int INF = 12345678;
  fill(cur[0], cur[303], -INF);

  cur[x][y+300] = 0;
  rep(i,n){
    fill(nxt[0], nxt[303], -INF);
    rep(j,301) for(int k=-300; k<=600; k++) if(cur[j][k+300]>=0){
      int tmp = cur[j][k+300];
      chmax(nxt[j][k+300], tmp);
      if(j>=a[i]) chmax(nxt[j-a[i]][k+300+b[i]], tmp);
      chmax(nxt[j][k+300-c[i]], tmp + d[i]);
    }
    swap(cur, nxt);
  }

  int ans = 0;
  rep(i,301) rep(j,601) ans = max(ans, cur[i][j+300]);

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5596