akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 2000000011LL
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pll a, pll b)//true for a before b
{
	if(a.F*b.S < b.F*a.S)
		return 1;
	if(a.F*b.S > b.F*a.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 100;
const int SQRT = BUCK+9;

pii a[N];
set < pii > stl, str;//stl -> leftmost r, str -> rightmost l
int n;

ll func(int bit)
{
	int i, pt = 0, z;
	ll ans = 0;
	stl.clear();
	str.clear();
	fo(i,1,n+1)
	{
		stl.insert({a[i].S,i});
		str.insert({-a[i].F,i});
	}
	fo(i,1,n+1)
	{
		if((i&1) == bit)
			z = str.begin()->S;
		else
			z = stl.begin()->S;
		str.erase({-a[z].F,z});
		stl.erase({a[z].S,z});
		if(pt < a[z].F)
		{
			ans += abs(pt-a[z].F);
			pt = a[z].F;
		}
		else if(pt > a[z].S)
		{
			ans += abs(pt-a[z].S);
			pt = a[z].S;
		}
	}
	ans += abs(pt);
	return ans;
}

void solve()
{
	int i;
	ll ans = 0;
	cin >> n;
	fo(i,1,n+1)
		cin >> a[i].F >> a[i].S;
	ans = max(func(0), func(1));
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 12416
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	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 printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

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

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	N := readInt()
	Y := readInt()

	for x := 0; x <= N; x++ {
		for y := 0; y <= N; y++ {
			if N < x+y {
				continue
			}
			z := N - (x + y)
			if Y/1000 == x*10+y*5+z {
				println(x, y, z)
				return
			}
		}
	}
	println(-1, -1, -1)
}

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


Measured memory_bytes: 640
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> vec(n+1);
	int sum = 0;
	rep(i,n){
		int w;
		cin >> w;
		vec[i+1] = vec[i] + w;
		sum += w;
	}
	int minv = INF;
	reps(i,n){
		chmin(minv,abs(vec[i] - (sum - vec[i])));
	}
	cout << minv << '\n';
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  if(s=="keyence"){
    print("YES");
    return 0;
  }
  for (ll i = 0; i < sz(s);i++){
    for (ll j = i; j < sz(s);j++){
      string t = s;
      t.erase(t.begin() + i, t.begin() + j);
      if (t == "keyence"){
        print("YES");
        return 0;
      }
    }
  }
  print("NO");
}

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

int main()
{
	int N, M;
	int X[100005];
	int diff[100004];

	cin >> N >> M;

	for ( int i = 0; i < M; i++ ) {
		cin >> X[i];
	}
	sort(X, X + M);
	for ( int i = 0; i < M - 1; i++ ) {
		diff[i] = X[i + 1] - X[i];
	}

	sort(diff, diff + M - 1, greater<>());
	
	if ( N >= M ) {
		cout << 0 << endl;
	} else {
		cout << accumulate(diff, diff + M - 1, 0) - accumulate(diff, diff + N - 1, 0) << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 100000
#define SEN 2000000000

typedef struct Card{
  char suit;
  int value;
}C;

C L[MAX/2+2],R[MAX/2+2];

void merge(C A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1].value=R[n2].value=SEN;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else {
      A[k]=R[j++];
    }
  }
}

void mergeSort(C A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(C A[],int n,int p,int r){
  int i,j;
  C t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(C A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  C A[MAX],B[MAX];
  char S[10];
  int stable=1;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable=0;
  }
  
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



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

typedef long long 			ll;
typedef unsigned long long 	ull;

const int N = 1e3 + 20;
const int MAX_H = 4e4 + 20; 

ll a[N], b[N], dp[MAX_H];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	ll n, h;
	cin >> h >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for (int i = 0; i < h + 10; i++)
		dp[i] = INT_MAX;
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j <= h; j++) {
	     if (j - a[i] <= 0) {
		     if (dp[j] < b[i])
		     	continue;
			 else
			    dp[j] = b[i];
		 }
		 else if (dp[j] < dp[j - a[i]] + b[i])
		     continue;
		 else
		     dp[j] = dp[j-a[i]]+b[i];
		}
	}
	cout << dp[h] << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (2e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 100;
const int SQRT = BUCK+9;

inline int dig_sum(int n)
{
	int ans = 0;
	while(n > 0)
	{
		ans += (n%10);
		n /= 10;
	}
	return ans;
}

void solve()
{
	int n, i, ans = INF;
	cin >> n;
	fo(i,1,n+1)
		if(n-i >= i)
			ans = min(ans, dig_sum(i)+dig_sum(n-i));
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=200002;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 
 
ll int power(ll int a,ll int b)
{
	ll int ans=1,f=a;
	while(b)
	{
		 if(b&1)
		 ans=(ans*f)%mod;
		 b=b>>1;
		 f=(f*f)%mod;
	}
	return ans%mod;
}

int main()
{
   int n;
   cin>>n;
   int a[n],b[n];
   fo(i,0,n)
   cin>>a[i]>>b[i];
   sort(a,a+n);
   sort(b,b+n);
   int mn,mx;
   if(n%2)
   {
       mn=a[n/2];
       mx=b[n/2];
   }
   else
   {
       mn=a[n/2-1]+a[n/2];
       mx=b[n/2-1]+b[n/2];
   }
   cout<<mx-mn+1;

}

Measured memory_bytes: 5172
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int dp[MAX *10];

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int k; cin >> k;
	dp[1] = 7;
	rep2(i, 1, MAX * 10){
		dp[i+1] = (dp[i]) * 10 % k;
	}

	int ans = -1;
	int res = 0;
	rep2(i, 1, k+1){
		// print(res);
		res = (res + dp[i]) % k;
		if(res % k == 0) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7500
// AOJ 0309: New Drug Development
// 2017.12.24 bal4u@uu

#include <stdio.h>

#define M 1000000007
#define E   1
#define A   2
#define R   4
#define OPT 8
typedef struct { char info, lock; int n, ch[10]; } T;
T tbl[1002];
char tr['Z'];

int calc(int id)
{
	int i, n;
	long long s = 0;
	T *t = tbl+id;

	if (t->lock) return 0;
	t->lock = 1;
	n = t->n;

	if (t->info & E) {
		s = 1; for (i = 0; i < n; i++) s = s * (calc(t->ch[i])) % M;
	} else if (t->info & A) {
		s = 0; for (i = 0; i < n; i++) s += calc(t->ch[i]);
		s %= M;
	} else if (t->info & R) {
		s = 1; for (i = 0; i < n; i++) s = (s * (calc(t->ch[i]) + 1)) % M;
		s--; if (s < 0) s = M-1;
	}
	if (t->info & OPT) { if (++s == M) s = 0; }
	return (int)s;
}

int main()
{
	int n, i, a, b;
	char buf[10], *p;

	tr['E'] = E, tr['A'] = A, tr['R'] = R,  tr['?'] = OPT;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%s", buf);
		p = buf; while (*p) tbl[i].info |= tr[*p++];
	}
	for (i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		tbl[a].ch[tbl[a].n++] = b;
	}
	printf("%d\n", calc(1));
}

Measured memory_bytes: 1860
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n)cin >> v[i];
    ll x = 1;
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll tmp = (v[i]-1)/x;
        ans += tmp;
        if(v[i]==x){
            x++;
        }
        if(i==0){
            x = 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;

class tree{
public:
  int node;
  int depth = -1;
  int parent = -1;
  vector<int> child;
  tree(int n, int c){
    node = n;
    child.resize(c);
    for(int i=0; i<c; i++) cin >> child[i];
  }
  tree(){}

  bool operator<(const tree& r)const{
    return node < r.node;
  }
};

vector<tree> t;
void input(int n, int c){
  t[n].node = n;
  t[n].child.resize(c);
  for(int i=0; i<c; i++) cin >> t[n].child[i];
}
int getdepth(int pos, int depth){
  t[pos].depth = depth;
  for(int i=0; i<t[pos].child.size(); i++){
    getdepth(t[ t[pos].child[i] ].node, depth+1);
  }
  return 0;
}

string gettype(int node){
  if( t[node].parent == -1 ) return "root";
  else if( t[node].child.size() == 0 ) return "leaf";
  else return "internal node";
}

bool cl(tree l, tree r){
  return l.node < r.node;
}

int main(void) {

  int n;
  cin >> n;
  int a, b;
  t.resize(n);
  for(int i=0; i<n; i++){
    cin >> a >> b;
    // tree tmp(a, b);
    input(a, b);
    // t.push_back(tmp);
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<t[ t[i].node ].child.size(); j++){
      t[ t[ t[i].node ].child[j] ].parent = t[t[i].node].node;
    }
  }
  for(int i=0; i<n; i++){
    int now = t[i].node;
  }

  int r = -1;
  for(int i=0; i<n; i++) if( t[t[i].node].parent == -1 ) r = t[i].node;
  getdepth(r, 0);

  sort(t.begin(), t.end());

  for(int i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ", t[i].node, t[t[i].node].parent, t[t[i].node].depth);
    // cout << t[i].node<<gettype(t[t[i].node].node) << ", ";
    cout << gettype(t[i].node) << ", ";
    cout << "[";
    for(int j=0; j<t[i].child.size(); j++){
      if( j == t[i].child.size()-1 ) cout << t[i].child[j];
      else cout << t[i].child[j] << ", ";
    }
    cout << "]\n";
  }



  return 0;
}

// EOF

Measured memory_bytes: 7240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    sort(z.begin(), z.end());
    reverse(z.begin(), z.end());
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        if (n - 1 - (i / 2 * 2) != z[i])ans = 0;
    }
    ans *= modpow(2, n / 2, 1000000007);
    cout << ans << endl;
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	vector<vll> arr(19, vll(19, 0));
	M00(i, n) {
		string a;
		cin >> a;
		ll x = 0;
		int places = 0, dot = 0;
		M00(i, a.size()) {
			if(a[i] == '.') {
				dot = 1;
			} else {
				int d = a[i] - '0';
				x *= 10;
				x += d;
				places += dot;
			}
		}
		M00(i, 9 - places) x *= 10;

		int two = 0, five = 0;
		while(!(x & 1)) {
			two++;
			x >>= 1;
		}
		while(x % 5 == 0) {
			five++;
			x /= 5;
		}
		arr[min(two, 18)][min(five, 18)]++;
	}
	ll ans = 0;
	M00(i, 19) {
		M00(j, 19) {
			M00(k, 19) {
				M00(l, 19) {
					if(i + k >= 18 && j + l >= 18) {
						if(i == k && j == l) {
							ans += (arr[i][j] * (arr[i][j]-1))/2;
						} else if(19 * i + j > 19 * k + l) {
							ans += arr[i][j] * arr[k][l];
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;
long long mod = 1000000007,a[1000010],b[1000010],c[1010][1010] = {},mx[2][1010] = {},ans = 1;
int main(){
	int i,n,m;
	cin >> n >> m;
	for(i=1;i<=n*m;i++){
		a[i] = -1; b[i] = -1;
	}
	for(i=1;i<=n;i++){
		int x; cin >> x;
		a[x] = i;
	}
	for(i=1;i<=m;i++){
		int x; cin >> x;
		b[x] = i;
	}
	long long l = 0, r = 0;
	for(i=n*m;i>=1;i--){
		int x = a[i],y = b[i];
		if(x!=-1 && y!=-1){
			if(c[x][y]!=0 || mx[0][x]>i || mx[1][y]>i){
				cout << 0 << endl;
				return 0;
			}
			c[x][y] = i; mx[0][x] = i; mx[1][y] = i;
			l++; r++;
		}else{
			if(x==-1 && y==-1){
				if(l==0 || r==0){
					cout << 0 << endl;
					return 0;
				}
				(ans *= (l*r - n*m + i)) %= mod;
			}else if(x==-1){
				if(mx[1][y]>i){
					cout << 0 << endl;
					return 0;
				}
				(ans *= l) %= mod;
				mx[1][y] = i; r++;
			}else if(y==-1){
				if(mx[0][x]>i){
					cout << 0 << endl;
					return 0;
				}
				(ans *= r) %= mod;
				mx[0][x] = i; l++;
			}
		}
	}
	cout << ans << endl;
}
			

Measured memory_bytes: 22400
n = int(input())
x = [0] * n
#x = [[0]*3 for i in range(n)]

for i in range(0, n):
    x[i] = list(map(int, input().split()))

dp = [[0]*3 for i in range(n)]

for i in range(0, 3):
    dp[0][i] = x[0][i]

for i in range(0, n-1):
    dp[i+1][0] = max(dp[i][1], dp[i][2]) + x[i+1][0]
    dp[i+1][1] = max(dp[i][2], dp[i][0]) + x[i+1][1]
    dp[i+1][2] = max(dp[i][0], dp[i][1]) + x[i+1][2]

ans = 0
for i in range(0, 3):
    ans = max(ans, dp[n-1][i])

print(ans)


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

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

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

    cout << S << endl;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n , x;
bool cek[1000000005] , ceks;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> x;
		if(cek[x])ceks = true;
		cek[x] = true;
	}
	if(ceks)cout << "NO" << endl;
	else cout << "YES" << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) cin >> L[i];
	sort(L.begin(), L.end());
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (L[i] == L[j]) continue;
			for (int k = j + 1; k < N; k++) {
				if (L[j] == L[k] ||
					L[k] >= L[i]+L[j]) continue;
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#define int long long
const int mod = 1e9 + 7;
using namespace std;
int app(int arr[], int n) { 
   int sum = 0; 
   for (int i = 0; i < 61; i++) { 
      // Count of zeros and ones 
      int zc = 0, oc = 0; 
      // Individual sum at each bit position 
      int idsum = 0; 
      for (int j = 0; j < n; j++) { 
         if (arr[j] % 2 == 0) 
            zc++; 
         else
            oc++; 
         arr[j] /= 2; 
      } 
      // calculating individual bit sum 
      idsum = ((oc * zc % mod) * ((1LL << i) % mod)) % mod; 
      // final sum    
      sum += idsum; 
      sum %= mod;
   } 
   return sum; 
} 
int32_t main(){
    int n;
    cin>>n;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sum=app(arr,n);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2560
n = int(input())
def makediv(n):
	lower_divisors , upper_divisors = [], []
	i = 1
	while i*i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n//i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
k = makediv(n)
ans = 10**18
for i in k:
	t = n//i
	ans = min((t-1)+(i-1), ans)
print(ans)

Measured memory_bytes: 3372
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

int main(void) {
  int n;

  cin>>n;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
    cin>>v[i];
  }
  int c=0;
  for(int i=0; i<n; i++) {
    bool f=true;
    for(int j=0; j<i; j++) {
      if(v[i]<v[j])
	f=false;
    }
    if(f)
      c++;
  }
  std::cout << c << std::endl;
  return 0;
}



Measured memory_bytes: 256
import numpy as np
n,k=map(int,input().split())
a=np.sort(np.array(input().split(),'int64'))

plus=a[a>0]
zeros=np.sum(a==0)
minus=a[a<0]

def counter(T):
  c=0
  if T>=0:
    c+=zeros*n
  c+=np.searchsorted(a,T//plus,side='right').sum()
  c+=(n-np.searchsorted(a,(-T-1)//(-minus),side='right')).sum()
  c-=np.count_nonzero(a*a<=T)
  return c//2

left=-10**18
right=10**18
while abs(right-left)>1:
  mid=(left+right)//2
  if counter(mid)>=k:
    right=mid
  else:
    left=mid
print(right)

Measured memory_bytes: 34584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
   char a,b;
   cin>>a>>b;
   if(a<b){
       cout<<"<"<<endl;
   }else if(a>b){
       cout<<">"<<endl;
   }else{
       cout<<"="<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
input=sys.stdin.readline
n,q=map(int,input().split())
edges=[[] for i in range(n)]
cnt=[0]*n
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1;b-=1
  edges[a].append(b)
  edges[b].append(a)
for i in range(q):
  x,c=map(int,input().split())
  x-=1
  cnt[x]+=c
visited=[False]*n
check=deque([0])
visited[0]=True
while check:
  a=check.popleft()
  for i in edges[a]:
    if visited[i]==True:continue
    check.append(i)
    visited[i]=True
    cnt[i]+=cnt[a]
print(" ".join(map(str,cnt)))

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

using namespace std;

#define MAXN 3005
#define INF 1000000000000000LL
#define MOD 1000000007
#define pb push_back

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

int n;
double v[MAXN];
double dp[2][MAXN];

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

	cin >> n;

	for(int i = 1; i <= n; i++) cin >> v[i];

	for(int i = (n / 2) + 1; i <= n; i++) dp[0][i] = 1LL;

	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n - i; j++){
			//cout << "i " << i << " j " << j << " : " << dp[i][j] << endl;
			dp[i & 1][j] = dp[~i & 1][j + 1] * v[i];
			dp[i & 1][j] += dp[~i & 1][j] * (1.0 - v[i]);
			//cout << "i " << i << " j " << j << " : " << dp[i][j] << endl;
		}
	}

	cout << fixed << setprecision(10) << dp[n & 1][0] << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long K, std::string S) {
    if (S.length() <= K) {
        cout << S << endl;
    } else {
        rep(i, K) cout << S[i];
        cout << "..." << endl;
    }
}

int main() {
    long long K;
    scanf("%lld", &K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


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

int main()
{
    int n, ac = 0, wa = 0, tle = 0, re = 0;
    string s;
    cin >> n;
    while (n--)
    {
        cin >> s;
        if (s == "AC")
            ac++;
        else if (s == "WA")
            wa++;
        else if (s == "TLE")
            tle++;
        else if (s == "RE")
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int h,w,a,b;
	cin >> h >> w >> a >> b;
	vector<string> s(h);
	for(int i =0;i<h;i++)
	{
		for(int j =0;j<w;j++)
		{
			s[i].push_back('0');
		}
	}
	for(int i = 0;i<b;i++)
	{
		for(int j = 0;j<a;j++)
		{
			s[i][j] = '1';
		}
	}
	for(int i = b;i<h;i++)
	{
		for(int j = a;j<w;j++)
		{
			s[i][j] = '1';
		}
	}
	for(int i =0;i<h;i++)cout<<s[i]<<endl;
	return 0;
}

Measured memory_bytes: 2304
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vll a(n);
    rep(i,n)cin>>a[i];
    ll count1=0;
    ll count2=0;
    ll sum=0;
    if(a[0]!=0){
        sum+=a[0];
        rep2(i,1,n){
            if((sum+a[i])*sum>=0){
                count1+=abs(-abs(sum)/sum-sum-a[i]);
                sum=-abs(sum)/sum;
            }
            else sum+=a[i];
        }
        sum=-abs(a[0])/a[0];
        count2+=abs(-abs(a[0])/a[0]-a[0]);
        rep2(i,1,n){
            if((sum+a[i])*sum>=0){
                count2+=abs(-abs(sum)/sum-sum-a[i]);
                sum=-abs(sum)/sum;
            }
            else sum+=a[i];
        }
        cout<<min(count1,count2)<<endl;
        return 0;
    }
    sum=1;
    count1++;
    rep2(i,1,n){
        if((sum+a[i])*sum>=0){
            count1+=abs(-abs(sum)/sum-sum-a[i]);
            sum=-abs(sum)/sum;
        }
        else sum+=a[i];
    }
    sum=-1;
    count2++;
    rep2(i,1,n){
        if((sum+a[i])*sum>=0){
            count2+=abs(-abs(sum)/sum-sum-a[i]);
            sum=-abs(sum)/sum;
        }
        else sum+=a[i];
    }
    cout<<min(count1,count2)<<endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long

using namespace std;

signed main() {
  IOS;
  int N,K, ans=0;
  cin >> N >> K;
  int V[N+1];
  for (int i=1; i<=N; i++) {
    cin >> V[i];
  }

  for (int i=0; i<=min(K,N); i++) {
    for (int j=0; i+j<=min(K,N); j++) {
      vector<int> v;
      for (int x = 1; x <= i; x++) v.push_back(V[x]);
      for (int x = 0; x < j; x++) v.push_back(V[N-x]);
      sort(v.rbegin(), v.rend());

      int k2 = K - i - j;
      while (!v.empty() and k2 > 0 and v.back() < 0) {
        v.pop_back();
        k2--;
      }
      int sum = 0;
      for (auto x: v) sum += x;
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,m,x = map(int, input().split())

p = map(int, input().split())

count1 = count2 = 0

for i in p:
    if 0 < i <= x:
        count1 += 1
    elif x <= i <= n:
        count2 += 1
    
print(min(count1,count2))

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

// Frog A

long long dp[100001];
int main(int argc, char const *argv[]) {
    int n, h[100001];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i>=2){
            chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for (int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<< C <<endl;
#define VI vector <int>
#define VII vector <VI>
#define VL vector <LL>
#define VLL vector <VL>
#define VD vector <double>
#define VDD vector <VD>
#define PII pair <int, int>
#define PDD pair <double, double>
#define PLL pair <LL, LL>
#define VPII vector <PII>
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define EB emplace_back
#define FORE(a, b) for (auto &&a:b)
#define FIND(s, n) (s.find(n) != s.end())

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9;
const int MOD = INF + 7;

PII dp[(int)1e5 + 10][3];
//dp[i][j] : i回目で勝った(0)，あいこ(1), 負け(2)のときの最大ポイント　と　パーできる回数

int main(void) {
    string s;
    cin >> s;
    int N = s.length();
    dp[0][0] = dp[0][1] = dp[0][2] = MP(0, 0);
    FOR(i, 1, N + 1) {
        int id = i - 1;

        if (s[id] == 'g') { //あいてグー
            PII ma = MP(-INF, 0);
            REP(j, 3) {
                if (dp[i - 1][j].second == 0) continue;
                ma = max(ma, dp[i - 1][j]);
            }
            if (ma.second > 0) ma.second--;
            dp[i][0] = ma;
            if (dp[i][0].first != -INF) dp[i][0].first++;
            dp[i][1] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
            dp[i][1].second++;
            dp[i][2] = MP(-INF, 0);

        } else {    //あいてパー

            dp[i][0] = MP(-INF, 0);
            PII ma = MP(-1, 0);
            REP(j, 3) {
                if (dp[i - 1][j].second == 0) continue;
                ma = max(ma, dp[i - 1][j]);
            }
            if (ma.second > 0) ma.second--;
            dp[i][1] = ma;
            ma = MP(-1, -1);
            REP(j, 3) {
                if (dp[i - 1][j].second == 0) continue;
                ma = max(ma, dp[i - 1][j]);
            }
            if (ma.second != -1) ma.second++;
            dp[i][2] = ma;
            dp[i][2].first--;
        }
    }
    int win = max({dp[N][0].first, dp[N][1].first, dp[N][2].first});
    cout << win << endl;
}


Measured memory_bytes: 2816
{-
もし２進での桁がわかっているなら、2,8,32..を足してから
普通の２進表示をすれば、下から偶数ビットを反転したものになってるはず。
だから、-２進したときの桁がわかりさえすればいい。
マイナス２進のｎ桁での表示可能範囲はなにか？
-}

--init rate terms
series::Int->Int->Int->Int
series _ _ 0 = 0
series i r n = i*(div (r^n - 1) (r - 1))

--under 0
under0::Int->Int
under0 n = (snd.head) (dropWhile (\(v,_)->n<v) [(-series 2 4 i,2*i)|i<-[0..]])

--over1
over1::Int->Int
over1 n = (snd.head) (dropWhile (\(v,_)->v<n)  [(series 1 4 i,(i*2)-1)|i<-[0..]])

get_digit::Int->Int
get_digit n = if n <= 0 then under0 n else over1 n

positise::Int->Int
positise n = let dig = get_digit n in
          n + (series 2 4 (div dig 2))

bin::Int->Int->[Bool]
bin 0 _   = []
bin dig n = if (2^(dig-1))<=n then True:(bin (dig-1) (n - 2^(dig-1))) else False:(bin (dig-1) n)

positise2::[Bool]->[Bool]
positise2 ls = map (\(fl,v)->if mod fl 2 == 0 then not v else v) (zip [1..] (reverse ls))


solver::Int->String
solver 0 = "0"
solver n = let dig = get_digit n in
          (reverse.(map (\b->if b then '1' else '0')).positise2.(bin dig).positise) n


main::IO()
main=do
  nc<-getLine
  let n = read nc
  putStr ((solver n)++"\n")


Measured memory_bytes: 508
import math as m
def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
def koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*m.cos(m.radians(60))-(ty-sy)*m.sin(m.radians(60))+sx
    uy=(tx-sx)*m.sin(m.radians(60))+(ty-sy)*m.cos(m.radians(60))+sy
    koch(n-1,x1,y1,sx,sy)
    koch(n-1,sx,sy,ux,uy)
    koch(n-1,ux,uy,tx,ty)
    koch(n-1,tx,ty,x2,y2)
n=int(input())
koch(n,0,0,100,0)
plot(100,0)


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    sort(ALL(a));
    ll p = a[n -1];
    ll diff = LONG_MAX;
    ll q;
    REP(i, n - 1)
    {
        ll half;
        if (p % 2 == 0)
        {
            half = p / 2;
        }
        else
        {
            if (a[i] <= p / 2)
            {
                half = p / 2;
            }
            else
            {
                half = (p + 1) / 2;
            }       
        }
        
        if (abs(half - a[i]) < diff)
        {
            q = a[i];
            diff = abs(half - a[i]);
        }
    }

    cout << p << " " << q << endl;
}


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

int main(){ 
 int K,S; cin >> K >> S; int cnt = 0;
  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= K; y++){
      int z = S-x-y;
      if( z >= 0 && z <= K){ cnt++;}}}
  
  cout << cnt << endl; return 0;}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{

	static char[][] map;
	static int H;
	static int W;

	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		//int N =sc.nextInt();
		int N =sc.nextInt();
		int[] a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		int min = a[0];
		int max = a[N-1];
		
		
			System.out.println(max-min);

		
		



	}
}




class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





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

int main(){
    int i,c=0;
    char S[17];
    char s[17] = {'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6','\0'};
    scanf("%s",S);
    for(i=0;i<16;i++){
        if(S[i] != s[i]){c++;}
    }
    cout << c << endl;
    return 0;
}
    

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

using namespace std;

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if (m1 == 12) {
        if (m2 == 1 && d1 == 31 && d2 == 1) {
            cout << 1;
            return 0;
        }
    }

    if (m1 == 2 && m2 == 3 && d1 == 28 && d2 == 1) {
        cout << 1;
        return 0;
    }

    if (m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) {
        if ((m1 + 1) == m2 && d1 == 30 && d2 == 1) {
            cout << 1;
            return 0;
        }
    }

    if ((m1 + 1) == m2 && d1 == 31 && d2 == 1) {
        cout << 1;
        return 0;
    }

    cout << 0;
    return 0;
}


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

ans = 'UNRESTORABLE'
for i in range(len(s) - len(t), -1, -1):
    ds = s[i:i + len(t)]
    flg = True
    for j in range(len(t)):
        if (ds[j] != t[j]) and (ds[j] != '?'):
            flg = False
            break
    if flg:
        ans = s[:i] + t + s[i + len(t):]
        ans = ans.replace('?', 'a')
        break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    double a, b, x, d, c, ans;
    cin >> a >> b >> x;
    if(a*a*b/2.0 < x){
        d = (x-(a*a*b-x))/(a*a);
        b = b-d;
    }
    if(a*a*b/2.0 > x){
        a = 2*x/a/b;
    }
    ans = atan(a/b);
  ans = ans*(180/M_PI);
    printf("%.7f\n", 90-ans);
    return 0;
}

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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

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

const MOD: usize = 1e9 as usize + 7;

fn main() {
    input!{
      n: usize,
      m: usize,
      ss: [usize; n],
      ts: [usize; m],
    }
    let mut pos: Vec<_> =ss.iter().cloned().collect();
    pos.sort();
    pos.dedup();
    use std::collections::HashMap;
    let pos: HashMap<_, _> = pos.into_iter().enumerate().map(|(i, v)| (v, i)).collect();
    let mut indices = vec![vec![]; pos.len()];
    for i in 0..n {
        let s = ss[i];
        let idx = pos[&s];
        indices[idx].push(i);
    }
    // debug!(pos);
    // debug!(indices);
    let mut dp = vec![0usize; n+1];
    dp[0] = 1;
    for i in 0..m {
        let t = ts[i];
        if !pos.contains_key(&t) {
            continue;
        }
        let mut acm = vec![0usize; n+2];
        for i in 0..n+1 {
            acm[i+1] = acm[i] + dp[i];
            acm[i+1] %= MOD;
        }
        // debug!(acm);
        let posidx = pos[&t];
        for idx in indices[posidx].iter() {
            // debug!(idx);
            dp[idx + 1] += acm[idx+1];
            dp[idx+1] %= MOD;
        }
        // debug!(dp);
    }
    // debug!(dp);
    let mut ans = 0;
    for v in dp {
        ans += v;
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int maxN=1e3+100;
const long long int inf=1e12;
long long int n,ans,temp,m,k;
long long int arr[maxN][maxN];
// unordered_map<long long int,long long int> mp;

int visit[1000100];

int main()
{
    cin>>n>>m>>k;
    if(n*m == k)    return cout<<"Yes"<<endl,0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            visit[i*m + (n-i)*j - i*j] = 1;
        }
    }
    if(visit[k])
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
return 0;

}

Measured memory_bytes: 4352