akhauriyash/Code-Regression huggingface dataset:
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define int ll
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ll func(ll zz,ll x,ll a,ll val,int i)
    {
        // cout<<val<<" "<<zz<<" "<<i<<" "<<x<<" "<<a<<endl;
        if(val > zz)
            return -1;
        if(i==-1)
        {
            if(val == 0)
                return -1;
            return val;
        }
        ll z=(1ll<<i);
        ll xb = (x&z);
        ll ab = (a&z);
        // cout<<val<<" "<<zz<<"..."<<i<<" "<<x<<" "<<a<<" "<<xb<<" "<<ab<<endl;
        if(xb == 0 && ab == 0)
        {
            return func(zz,x,a,val,i-1);
        }
        if (xb == 0 && ab > 0)
        {
            if (val + z > zz)
                return -1;
            return func(zz,x,a,val+z,i-1);
        }
        if (xb > 0 && ab == 0)
        {
            ll ans = func(zz,x,a,val+z,i-1);
            if (ans==-1)
            {
                return func(zz,x,a,val,i-1);
            }
            else
                return ans;
        }
        return -1;
    }

    signed main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j,ans=0,x=0;
            cin>>n;
            ll ar[n+1];
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
            }
            for(i=3;i<=n;++i)
            {
                x=(x^ar[i]);
            }
            // cout<<x<<endl;
            if ((ar[1]+ar[2]-x)%2!=0)
            {
                cout<<-1<<endl;
                return 0;
            }
            ans = func(ar[1],x,(ar[1]+ar[2]-x)/2,0,45);

            if(ans==-1)
                cout<<ans<<endl;
            else
                cout<<ar[1]-ans<<endl;

        }
        return 0;
    }


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

#define DEBUG(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define is_in(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
using namespace std;
typedef long long ll;
typedef vector<vector<int> > VVI;
const int INF = 1e9;
typedef pair<int, int> PII;

const int V_MAX = 100;

struct Edge {
    int to, cost;
    Edge(int _to, int _cost) : to(_to), cost(_cost) {}
};

vector<Edge> G[V_MAX];
vector<int> go_free[V_MAX];

struct State {
    int v, ticket, d;
    State (int _v, int _ticket, int _d) : v(_v), ticket(_ticket), d(_d) {}
    bool operator > (const State &b) const {return d > b.d;}
};

int main()
{
    int N, M;
    while (cin>>N>>M, N||M) {
        rep(i, N) G[i].clear();
        rep(i, N) go_free[i].clear();

        rep(i, M) {
            int A, B, C;
            cin >> A >> B >> C;
            A--, B--;
            G[A].emplace_back(B, C);
            G[B].emplace_back(A, C);
        }

        for (int i=0; i<N; i++) {
            for (auto g : G[i]) {
                for (auto h : G[g.to]) {
                    if (h.to != i) {
                        go_free[i].push_back(h.to);
                        // cerr << "free : (" << i << ", "<< h.to << ")" << endl;
                    }
                }
            }
        }

        priority_queue<State, vector<State>, greater<State>> Q;
        map<PII, int> d;

        d[PII(0, 1)] = 0;
        Q.push(State(0, 1, 0));

        int ans;
        while (Q.size()) {
            State s = Q.top(); Q.pop();
            // cerr << s.v << " " << s.ticket << " " << s.d << endl;
            
            if (s.v == N-1) {
                ans = s.d;
                break;
            }

            if (d.count(PII(s.v, s.ticket)) && d[PII(s.v, s.ticket)] < s.d) continue;

            // no ticket
            for (auto e : G[s.v]) {
                int new_cost = d[PII(s.v, s.ticket)] + e.cost;
                if (!d.count(PII(e.to, s.ticket)) || d[PII(e.to, s.ticket)] > new_cost) {
                    d[PII(e.to, s.ticket)] = new_cost;
                    Q.push(State(e.to, s.ticket, new_cost));
                }
            }

            // with ticket
            if (s.ticket) {
                for (auto i : go_free[s.v]) {
                    if (!d.count(PII(i, 0)) || d[PII(i, 0)] > s.d) {
                        d[PII(i, 0)] = s.d;
                        Q.push(State(i, 0, s.d));
                    }
                }
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 3076
function Main(input) {
  const data = input.split("\n");
  const [n, m] = data[0].split(" ").map(n => Number(n));
  const ps = data[m+1].split(" ").map(n => Number(n));
  let result = 0;
    for (let i = 0; i < 2 ** n; i++) {
        let str = i.toString(2);
      	const cnt = n - str.length;
        for (let tmp = 0; tmp < cnt; tmp++) {
            str = "0" + str;
        }
    const switches = str.split("").map(s => Number(s));
    let isOk = true;
    for (let j = 1; j <= m; j++) {
    	const sList = data[j].split(" ");
      	let onNum = 0;
      	for (let k = 1; k <= sList[0]; k++) {
          if (switches[sList[k] - 1] === 1) onNum++;
        }
      	if (onNum%2 !== ps[j-1]) {
          isOk = false;
          break;
        }
      }
    if (isOk) result++;
  }
  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9856
#include<iostream>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;
int L[MAX/2+2],R[MAX/2+2];
llong merge(int A[],int n,int left,int mid,int right){
 int i,j,k;
 llong cnt=0;
 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]=R[n2]=SENTINEL;
 i=j=0;
 for(k=left;k<right;k++){
  if(L[i]<=R[j])A[k]=L[i++];
  else{
   A[k]=R[j++];
   cnt+=n1-i;
  }
 }
 return cnt;
}
llong mergeSort(int A[],int n,int left,int right){
 int mid;
 llong v1,v2,v3;
 if(left+1<right){
  mid=(left+right)/2;
  v1=mergeSort(A,n,left,mid);
  v2=mergeSort(A,n,mid,right);
  v3=merge(A,n,left,mid,right);
  return v1+v2+v3;
 }
 else return 0;
}
int main(){
 int A[MAX],n,i;
 cin>>n;
 for(i=0;i<n;i++)cin>>A[i];
 llong ans = mergeSort(A,n,0,n);
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 4616
#include <bits/stdc++.h>
#define ll long long
#define ulli unsigned long long int
#define ld long double  
using namespace std; 

void solve() {
    int n;
    cin >> n;

    int ans = 1;

    while (ans<<1 <= n) {
        ans = ans<<1;
    }
    cout << ans << "\n";
}

int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    //cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 


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

long long dp[3005][3005];
long long arr[3005];

long long rekur(int a,int s)
{
	if((s-a)==1)
	{
		return max(arr[a],arr[s]);
	}
	if(a==s)return arr[a];
	if(dp[a][s]!=-1)return dp[a][s];
	dp[a][s]=0;
	dp[a][s]=max(arr[a]+min(rekur(a+2,s),rekur(a+1,s-1)),arr[s]+min(rekur(a+1,s-1),rekur(a,s-2)));
	return dp[a][s];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	int z;
	cin>>z;
	long long total=0;
	for(int q=1;q<=z;q++)
	{
		cin>>arr[q];
		total+=arr[q];
	}
	
	long long asd=rekur(1,z);
//	cout<<asd<<endl;
	long long dsa=total-asd;
	asd=asd-dsa;
	cout<<asd<<endl;
}

Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

int main(){
  int n;
  cin >> n;

  int life;
  int count = 0;
  vector<int> monster(n,0);
  while(cin >> life){
    monster[count] = life;
    count++;
    if (count == n) {
      break;
    }
  }

  int size = monster.size();

  sort(monster.begin(),monster.end());
  while(true){
    for (int i = 1; i < size; i++) {
      if ((monster[i] = monster[i] % monster[0]) == 0) {
        monster.erase(monster.begin() + i);
        size--;
      }
    }
    if (size == 1) {
      break;
    }
    sort(monster.begin(),monster.end());
  }

  cout << monster[0] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 110
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll a,b,count=1;
    cin >> a >> b;
    for (ll i=0;i<a;i++){
        count*=100;
    }
    if (b==100){
        cout << count*101 << endl;
        return 0;
    }
    cout << count*b << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <utility>
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

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


	int n;
	cin>>n;
  bool z=false;
	cpp_int a[n];
	cpp_int ans=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
      if(a[i]==0)
        z=true;
// 		(a[i]==0) flag=1;
// 		//ans*=a[iif];
	}
//	if(flag==1) {
//		cout<<0;
//		return 0;
//	}
//	sort(a, a+n, greater<ld>());
  
  if(z)
  {
    cout<<0;
  return 0;
  }
  
	for(int i=0;i<n;i++){
		ans = ans*a[i];
      if(ans>1000000000000000000) {
		cout<<-1<<"\n";
		return 0;
	}
	}
	
	cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll P = 998244353;
ll fact[200000];

// Extended Euclid's greatest common divisor algorithm
// Find (x, y, g)
// where $a*x + b*y = g$ and g is the greatest common divisor of (a, b)
ll ext_gcd(ll a, ll b, ll &x, ll &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}
	ll nx, ny;
	ll g = ext_gcd(b, a%b, nx, ny);
	x = ny;
	y = nx - a/b *ny;
	return g;
}

// Modular inverse of x given modulo p, y
// x*y = 1 mod p
// <=> x*y + z*p = 1
ll inv_mod(ll x, ll p){
	ll y,z;
	ext_gcd(x, p, y, z);
	return y>=0 ? y : p+(y%p);
}


// Modular factorial of n, also counting p's appearance e
// n! = a * p^e
// return: a % p
// n! = n * (n-1) * ... * (k*p+1) *
//      (k*p) * (k*p-1) * ... ((k-1)*p+1) *
//      ...
//      p * (p-1) * ... * 2 * 1   (k = floor(n/p))
//    = (n%p) * ... * 1 *
//      (k*p) * (p-1) * ... * 1 *
//      p * (p-1) * ... * 1       (mod p, preserving p's multiples)
//    = (n%p)! * p^k * k! * (p-1)^k
//    = (n%p)! * p^k * k! * (p-1)^(k%2)
//
// From the facts:
//   (p-1)! = p-1 (mod p) (c.f. Willson's theorem)
//   (p-2)**2 = 1 (mod p)
ll fact_mod(ll n, ll p, ll &e){
	if(n == 0){
		e = 0;
		return 1;
	}

	ll na = fact_mod(n/p, p, e);

	e += n/p;
	ll a = na * fact[n%p] % p;

	if((n/p)%2) a = a * (p-1)%p;
	return a;
}


// Modular combination (n, m) given module p
// (n, m) = n!/(n-m)!m!
//        = (a_n * p^(e_n)) / ((a_{n-m} * p^(e_{n-m}) * (a_m * p^e_m))
//        = a_n / (a_{n-m} * a_m) * p^(e_n - e_{n-m} - e_m)
ll comb_mod(ll n, ll m, ll p){
	ll e1,e2,e3;
	ll a1 = fact_mod(n, p, e1);
	ll a2 = fact_mod(m, p, e2);
	ll a3 = fact_mod(n-m, p, e3);

	if(e1 > e2+e3) return 0;
	else return a1*inv_mod(a2*a3%p, p)%p;
}

int main(){
	fact[0] = fact[1] = 1;
	for(int i=2; i<200000; i++) fact[i] = fact[i-1]*i%P;
	int N, K;
	cin >> K >> N;

	ll all = comb_mod(N+K-1, K-1, P);
	for(int t=2; t<=2*K; t++){
		ll ans = all;
		int m = t/2+1-max(1, t-K);
		int sign = 1;
		for(int l=1; l<=min(N/2, m); l++){
			ans -= sign * comb_mod(N+K-1-2*l, K-1, P) * comb_mod(m, l, P) % P;
			sign *= -1;
			ans += P;
			ans %= P;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 1920
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())
w = list(map(int, input().split()))

sa = sum(w)

s = 0
dmin = float('inf')
for i in range(n):
    s += w[i]
    d = abs((sa - s) - s)
    dmin = min(dmin, d)

print(int(dmin))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> v(h+2,vector<char>(w+2));
  
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      v[i][j]='%';
    }
  }
  
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cin>>v[i][j];
    }
  }
  
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      int cnt=0;
      if(v[i-1][j-1]=='#') cnt++;
      if(v[i][j-1]=='#') cnt++;
      if(v[i+1][j-1]=='#') cnt++;
      if(v[i-1][j]=='#') cnt++;
      if(v[i+1][j]=='#') cnt++;
      if(v[i-1][j+1]=='#') cnt++;
      if(v[i][j+1]=='#') cnt++;
      if(v[i+1][j+1]=='#') cnt++;
      if(v[i][j]=='.'){
        cout<<cnt;
      }else if(v[i][j]=='#'){
        cout<<'#';
      }
    }
    cout<<endl;
  }
  
}
///////////////////////////



Measured memory_bytes: 256
N, x = map(int, input().split())
a = [int(i) for i in input().split()]
ans = 0
for i in range(N - 1):
    if a[i] + a[i + 1] > x and x - a[i] >= 0:
        ans += a[i] + a[i + 1] - x
        a[i + 1] = x - a[i]
    elif a[i] + a[i + 1] > x and x - a[i] < 0:
        ans += a[i] + a[i + 1] - x
        a[i + 1] = 0
        a[i] = a[i] - x
print(ans)


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

class lei
{
public:
	int data;
	lei *next;
	lei *pre;
};

int biaoji = 0;
lei *ptail;
lei *head;

int insert()
{
	lei *p;
	p = new lei;
	cin >> p->data;
	if (biaoji == 0)
	{
		p->pre = ptail;
		ptail->next = p;
		ptail = p;
		p->next = NULL;
		biaoji = 1;
	}
	else
	{
		biaoji = 0;
		p->next = head->next;
		head->next->pre = p;
		head->next = p;
		p->pre = head;
	}
	return 0;
}


int main()
{
	int n;
	while (cin >> n)
	{
		lei kong;
		kong.data = 0;
		kong.next = NULL;
		kong.pre = NULL;
		ptail = &kong;
		head = &kong;
		for (int i = 0; i < n; i++)
		{
			insert();
		}

		if (n % 2 == 0)
		{
			lei *p = head->next;
			for (int i = 0; i < n; i++)
			{
				cout << p->data;
				if (i != n - 1)
				{
					cout << " ";
				}
				p = p->next;
			}
			cout << endl;
		}
		else
		{
			lei *p = ptail;
			for (int i = 0; i < n; i++)
			{
				cout << p->data;
				if (i != n - 1)
				{
					cout << " ";
				}
				p = p->pre;
			}
			cout << endl;
		}
		lei *p;
		for (int i = 0; i < n; i++)
		{
			if (head->next != NULL)
			{
				p = head->next;
				head->next = head->next->next;
				delete(p);
			}
		}

	}

	return 0;
}

Measured memory_bytes: 8448
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> String -> Int
solve bN s = VU.foldl' mAdd 0 vecF
  where
  vecF = foldl' op (VU.fromListN 1 [1]) s
  op vec '<' = VU.scanl' mAdd 0 vec
  op vec '>' = VU.scanr' mAdd 0 vec

-------------------------------------------------------------------------------

mPrime = 10^9 + 7

mAdd :: Int -> Int -> Int
mAdd x y = let w = x + y in if w < mPrime then w else w - mPrime
-- mAdd x y = (x + y) `mod` mPrime

mSub :: Int -> Int -> Int
mSub x y = let w = x - y in if w >= 0 then w else w + mPrime
-- mSub x y = (x - y) `mod` mPrime    -- ok even if x < y

mMul :: Int -> Int -> Int
mMul x y = (x * y) `mod` mPrime


readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      [bs_s]:remLines2 = remLines1
      s = B.unpack bs_s
  in solve bN s

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "4\n<><\n"
inp2 = "5\n<<<<\n"
inp3 = "20\n>>>><>>><>><>>><<>>\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == 5
test2 = tv2 == 1
test3 = tv3 == 217136290
alltest = test1 && test2 && test3



Measured memory_bytes: 2428
#include<cstdio>
#include<iostream>
#include<vector> 
#include<algorithm>
#include<cstring>
#define mk make_pair
#define pk push_back 
#define int long long 
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;
const int N=2e5+5;
int n,mn[N<<2];
#define tl id<<1
#define tr id<<1|1
#define mid (l+r>>1)
#define lson tl,l,mid
#define rson tr,mid+1,r
void update(int id,int l,int r,int p,int v){
	if(l==r) return mn[id]=min(mn[id],v),void();
	p<=mid?update(lson,p,v):update(rson,p,v);
	mn[id]=min(mn[tl],mn[tr]);
}
int query(int id,int l,int r,int ll,int rr){
	if(ll<=l&&r<=rr) return mn[id];
	if(rr<=mid) return query(lson,ll,rr);
	else if(ll>mid) return query(rson,ll,rr);
	else return min(query(lson,ll,rr),query(rson,ll,rr));
}
pi a[N];
int y[N];
vector<int> t;
signed main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i].first>>a[i].second,t.pk(a[i].second);sort(&a[1],&a[n+1]);
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	for(int i=1;i<=n;++i) y[i]=lower_bound(t.begin(),t.end(),a[i].second)-t.begin()+1;
	int ans=0;	
	
	memset(mn,0x3f,sizeof mn);
	for(int i=1;i<=n;++i){
		int tmp=a[i].first+a[i].second;
		ans=max(ans,tmp-query(1,1,n,1,y[i]));
		update(1,1,n,y[i],tmp);
	}	 
	memset(mn,0x3f,sizeof mn);
	for(int i=1;i<=n;++i){
		int tmp=a[i].first-a[i].second;
		ans=max(ans,tmp-query(1,1,n,y[i],n));
		update(1,1,n,y[i],tmp);
	}		
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 15444
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static String s;
	static long x;
	
	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		s = br.readLine();
		x = 0;
		
		for(int i=0; i<= s.length(); i++) f(i, 0, s);
		System.out.println(x);
	}
	
	static void f(int plus, long sum, String str){
		if(plus != 0){
			for(int i=1; i<str.length()-plus+1; i++){
				f(plus-1, Long.parseLong(str.substring(0, i))+sum, str.substring(i, str.length()));
			}
		}else{
			x += sum + Long.parseLong(str);
		}
	}
}


Measured memory_bytes: 8784
from copy import deepcopy
H, W, K = map(int, input().split())
board = [[0]*(W+1) for _ in range(H+1)]
for i in range(1,H+1):
    board[i] = list(map(int, list(input())))+[0]
def drop(board_copy):
    change = True
    score = 0
    p = 0
    while change:
        change = False
        for i in range(2,H+1):
            ser = 1
            for j in range(1,W+1):
                if board_copy[i][j]>0 and board_copy[i][j]==board_copy[i][j-1]:
                    ser += 1
                else:
                    if ser>=K:
                        score += 2**p*board_copy[i][j-1]*ser
                        change = True
                        for k in range(i,0,-1):
                            board_copy[k][j-ser:j] = board_copy[k-1][j-ser:j]
                    ser = 1
        p += 1
    return score
ans = 0
for h in range(2,H+1):
    for w in range(W):
        board_copy = deepcopy(board)
        for k in range(h,0,-1):
            board_copy[k][w] = board[k-1][w]
        ans = max(ans,drop(board_copy))
print(ans)

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

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int max_val = A[0];
  int max_idx = 0;
  int min_val = A[0];
  int min_idx = 0;
  for (int i = 1; i < N; i++) {
    if (max_val < A[i]) {
      max_val = A[i];
      max_idx = i;
    }
    if (min_val > A[i]) {
      min_val = A[i];
      min_idx = i;
    }
  }

  if (abs(max_val) >= abs(min_val)) {
    if (min_val < 0) {
      cout << 2 * (N - 1) << endl;
      for (int i = 1; i <= N; i++) {
        if (i != max_idx + 1)
          cout << max_idx + 1 << " " << i << endl;
      }
    } else {
      cout << N - 1 << endl;
    }
    for (int i = 1; i < N; i++) {
      cout << i << " " << i + 1 << endl;
    }
  } else {
    if (max_val > 0) {
      cout << 2 * (N - 1) << endl;
      for (int i = 1; i <= N; i++) {
        if (i != min_idx + 1)
          cout << min_idx + 1 << " " << i << endl;
      }
    } else {
      cout << N - 1 << endl;
    }
    for (int i = N; i > 1; i--) {
      cout << i << " " << i - 1 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
void print(int x)
{
	if (x >= 10)
		print(x / 10);
	putchar('0' + x % 10);
}
void write(int x, char c)
{
	if (x < 0)
		putchar('-'), x = -x;
	print(x);
	putchar(c);
}
int lcm(int x, int y)
{
	return x / __gcd(x, y) * y;
}
int main()
{
	int x = read();
	int k = lcm(360, x);
	if ((k / 360) & 1)
		write(k / x, '\n');
	else
		write(lcm(720, x) / x, '\n');
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main(){
    int64_t n,a,b ;
    cin >> n >> a >> b ;
    int64_t ans = 0 ;
    int64_t num = n / (a+b) ;
    ans += num * a ;
    n = n % (a+b) ;
    if (n >= a )
    {
        ans += a ;
    }else
    {
        ans += n ;
    }
    
    
    cout << ans << endl ;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        String output = "";
        for(int i = 0;i < y + 2;i++){
        	output += "#";
        }
        output += "\n";
        int j = 0;
        while(j < x){
        	output += "#";
        	String input2 = br.readLine();
        	output += input2;
        	output += "#\n";
        	j += 1;
        }
        for(int i = 0;i < y + 2;i++){
        	output += "#";
        }

        System.out.println(output);

    }

}

Measured memory_bytes: 33492
#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()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n; cin >> n;
    vector<int> v(n);
    ll ans = 1e8;
    rep(i, n) cin >> v[i];
    for(int i = 0; i <= 100; i++){
        ll sum = 0;
        for(int j = 0; j < n; j++){
            int d = abs(i-v[j]);
            sum += d*d;
        }
        ans = min(ans, sum);
    }
    cout<< ans << endl;
    system("pause");
}

Measured memory_bytes: 504
n, m = gets.chomp.split(' ').map(&:to_i)
lrs = m.times.map { gets.chomp.split(' ').map(&:to_i) }

min_n = 1
max_n = n
lrs.each do |l, r|
    min_n = [l, min_n].max
    max_n = [r, max_n].min
end

puts (min_n..max_n).count


Measured memory_bytes: 11388
#include<bits/stdc++.h>
using namespace std;
const int mod = 200003;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define fr(s,n) for (int i=(int)(s);i<(int)(n);i++)
#define lc cout<<"\n"
//double pi=2*acos(0.0);
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC";
    }
    else{
        cout<<"ABC";
    }
}



Measured memory_bytes: 3556
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

N = int(input())
VW = [[int(x)-1 for x in input().split()] for _ in range(N-1)]

"""
直径に次数1の頂点が生えている
"""

graph = [[] for _ in range(N)]
deg = [0] * N
for v,w in VW:
    graph[v].append(w)
    graph[w].append(v)
    deg[v] += 1
    deg[w] += 1

def dijkstra(start):
    INF = 10**10
    dist = [INF] * N
    q = [(start,0)]
    while q:
        qq = []
        for v,d in q:
            dist[v] = d
            for w in graph[v]:
                if dist[w] == INF:
                    qq.append((w,d+1))
        q = qq
    return dist

dist = dijkstra(0)
v = dist.index(max(dist))
dist = dijkstra(v)
w = dist.index(max(dist))
diag = v,w

def create_perm(start):
    arr = []
    v = start
    parent = None
    next_p = 1
    while True:
        n = 0
        next_v = None
        for w in graph[v]:
            if w == parent:
                continue
            if next_v is None or deg[next_v] < deg[w]:
                next_v = w
            if deg[w] == 1:
                n += 1
        if next_v is None:
            return arr + [next_p]
        if deg[next_v] == 1:
            n -= 1
        arr += list(range(next_p+1,next_p+n+1))
        arr.append(next_p)
        next_p += n+1
        parent = v
        v = next_v

P = create_perm(diag[1])

Q = create_perm(diag[0])

if len(P) != N:
    answer = -1
else:
    if P > Q:
        P = Q
    answer = ' '.join(map(str,P))
print(answer)



Measured memory_bytes: 53640
#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 fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, k, m = 0;
  cin >> n >> k;
  deque<int> d;
  rep(i, n){
    int e;
    cin >> e;
    d.push_back(e);
  }
  rep(i, k+1){
    rep(j, k-i+1){
      int t = 0, a = 0, b = 0;
      deque<int> c = d;
      priority_queue<int, vector<int>, greater<int>> pq;
      while(a < i && !c.empty()){
        pq.push(c.front());
        c.pop_front();
        ++a;
      }
      while(b < j && !c.empty()){
        pq.push(c.back());
        c.pop_back();
        ++b;
      }
      rep(l, k-a-b){
        if(pq.empty()) break;
        if(pq.top() < 0) pq.pop();
        else break;
      }
      while(!pq.empty()){
        t += pq.top();
        pq.pop();
      }
      m = max(m, t);
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
n=io.read("*n","*l")
t={0,0,0,0,0,0,0,0,0}
for i=1,n do
    rate=io.read("*n")//400
    if rate>=8 then
        rate=8
        t[rate]=t[rate]+1
    else
        t[rate]=1
    end
end

colormin=0
colormax=0
for rate,v in pairs(t) do
    if rate~=8 then
        colormin=colormin+v
    end
    colormax=colormax+v
end
if colormin==0 then
    colormin=1
end
print(colormin,colormax)

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n,m,ans;
  cin>>n>>m;
  if(n==1 && m==1) ans=1;
  else if(n==1) ans=m-2;
  else if(m==1) ans=n-2;
  else{
    ans=(n-2)*(m-2);
  }
  cout<<ans<<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();
        double bunsi = 0.0;
        for(int i = 0; i < N; i++){
            bunsi += 1.0 / (double)sc.nextInt();
        }
        System.out.println(1.0 / bunsi);
    }
}


Measured memory_bytes: 22864
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	ll h, w;
	ll stage[100][100];
	ll a[10000];
	cin >> h >> w;
	ll n;
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}

	//ぐるぐるぬっていく
	ll posx = 0,posy = 0;
	ll dx = 1;
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < a[i]; j++) {
			stage[posx][posy] = i + 1;
			if (posx + dx > w - 1 || posx + dx < 0) {
				posy++;
				dx = -dx;
			}
			else {
				posx += dx;
			}
		}
	}

	for (ll j = 0; j < h; j++) {
		for (ll i = 0; i < w; i++) {
			cout << stage[i][j];
			if (i != w - 1) {
				cout << " ";
			}
		}
		if (j != h) {
			cout << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> x(N, 0);
    vector<int> y(N, 0);
    vector<int> towns(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
        towns[i] = i;
    }

    double sum = 0;
    int count = 0;
    do {
        for (int i = 1; i < towns.size(); ++i) {
            int prev = towns[i - 1];
            int curr = towns[i];
            double len = sqrt(pow(x[curr] - x[prev], 2) + pow(y[curr] - y[prev], 2));
            sum += len;
        }
        ++count;
    } while (next_permutation(towns.begin(), towns.end()));

    cout << setprecision(15) << (sum / (double)count) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
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
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll k;

int main(void){
	scanf("%lld",&k);
	printf("%d\n",50);
	ll cnt=k/50LL;
	ll rest=k%50LL;
	for(int i=0;i<50;i++){
		if(i<50LL-rest || rest==0)printf("%lld%c",49LL+cnt-rest,i+1==50?'\n':' ');
		else printf("%lld%c",49LL+cnt+51LL-rest,i+1==50?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n, m;
    cin >> n >> m;
    vector<pair<LL,LL>> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i].second >> a[i].first;
    }
    sort(a.begin(), a.end(), greater<pair<LL,LL>>());
    set<LL> days;
    for(LL day = 0; day < m; ++day){
        days.insert(-day);
    }
    LL ans = 0;
    for(auto p: a){
        auto it = days.lower_bound(p.second-m);
        if(it != days.end() && *it >= p.second-m){
            days.erase(it);
            ans += p.first;
        }
    }
    cout << ans << endl;
    return 0;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

using bs=bitset<160*160>;

int H,W;
int A[88][88];

bs dp[88][88];

signed main(){
	cin>>H>>W;
	rep(i,H)rep(j,W)cin>>A[i][j];
	rep(i,H)rep(j,W){
		int b;cin>>b;
		A[i][j]-=b;
	}

	dp[0][0][80+A[0][0]]=1;
	dp[0][0][80-A[0][0]]=1;
	rep(i,H)rep(j,W){
		if(i+1<H){
			dp[i+1][j]|=dp[i][j]<<(80+A[i+1][j]);
			dp[i+1][j]|=dp[i][j]<<(80-A[i+1][j]);
		}
		if(j+1<W){
			dp[i][j+1]|=dp[i][j]<<(80+A[i][j+1]);
			dp[i][j+1]|=dp[i][j]<<(80-A[i][j+1]);
		}
	}

	int ans=1001001001;
	rep(i,160*160){
		if(dp[H-1][W-1][i]==0)continue;
		int tmp=i-(H-1+W-1+1)*80;
		chmin(ans,abs(tmp));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 22656
//
//AtCoder Beginner Contest 170
//C - Forbidden List
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int x, n;
    cin >> x >> n;

    vector<int> p(n);
    REP(i, n) cin >> p[i];

    int u = -1;
    int l = -1;
    FOR(i, x, 101){
        bool f=true;
        REP(j, n){
            if (i == p[j]) {
                f=false;
                break;
            }
        }
        if (f){
            u=i;
            break;
        }
    }
    FORD(i, x-1, 0){
        bool f=true;
        REP(j, n){
            if (i == p[j]) {
                f=false;
                break;
            }
        }
        if (f){
            l=i;
            break;
        }
    }

    if (abs(x-u) >= abs(x-l)){
        cout << l << endl;
    }else {
        cout << u << endl;
    }

/*
    ll mv = 999999999;
    FOR(i, 1, 100){
        bool flag = true;
        REP(j,n){
            if (i == p[j]) {
                flag = false;
                break;
            }
        }
        if (flag){
            mv = min(mv, abs(x-i));
        }
    }
    bool f=false;
    REP(i,n){
        if (p[i]==x-mv) f=true;
    }
    if (f) cout << x+mv << endl;
    else cout << x-mv << endl;
*/
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	int max3(int a, int b, int c) {
		int max = ((a < b) ? b : a);
		return (max < c)? c : max;
	}
	
	void doIt() {
		int n = sc.nextInt() + 1;
		int m = sc.nextInt();
		boolean b[] = new boolean[n];
		Arrays.fill(b, true);
		for(int i = 0; i < m; i++) 
			b[sc.nextInt()] = false;
		int dp[] = new int[n];
		Arrays.fill(dp, 0);
		dp[0] = 1;
		for(int i = 0; i < n; i++) {
			if(b[i]) {
				if(i + 1 < n) {
					dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
				}
				if(i + 2 < n) {
					dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
				}
			}
		}
		System.out.println(dp[n - 1]);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

using namespace std;
int main(){
    int n;
    cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<n;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			i+=2;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

double dist(pii xy1, pii xy2) {
    pii diff = xy1 - xy2;
    return sqrt(diff.first * diff.first + diff.second * diff.second);
}

signed main() {
    fio();
    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 1) {
        cout << "Odd" << endl;
    }
    else {
        cout << "Even" << endl;
    }
}

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

using namespace std;

int n;

deque< int > s;

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

	for(int i = 1 ; i <= n ; i++)
	{
		int v;
		scanf("%d",&v);

		if( i%2 == 1 ) s.push_back( v );
		else s.push_front( v ); 
	}

	for(int i = 1 ; i <= n ; i++)
	{
		if( n%2 == 0 )
		{
			printf("%d ",s.front());
			s.pop_front();
		}
		else
		{
			printf("%d ",s.back());
			s.pop_back();
		}
	}
}

Measured memory_bytes: 2944
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
s = s.split(", ").map(&:to_i)
puts s[gets.to_i-1]

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***スニペット***
ifelse, isprime, torad, todeg, lcm, bfs
****************/

//隣接リスト
vector<int> to[100005];

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

    cout << n*n*n ENDL;
    
    return 0;
}

Measured memory_bytes: 5916
#include<iostream>
using namespace std;
#define ll long long

int main()
{
	int count = 0, t = 0;
	ll X;
	cin >> X;
	for (int i = 1; t < X; i++) {
		t += i;
		count++;
	}

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



Measured memory_bytes: 256
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n, m = map(int, input().split())
    from bisect import insort_left as il
    pref = [[] for _ in range(n)]
    for i in range(m):
        p, y = map(int, input().split())
        p -= 1
        il(pref[p], (y, i))
    
    def tostr(x):
        return '0'*(6-len(str(x+1)))+str(x+1)

    ans = [0]*m    
    for i in range(n):
        x = pref[i]
        for j in range(len(x)):
            ans[x[j][1]] = tostr(i)+tostr(j)
    
    for x in ans:
        print(x)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38732
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())


N=II()
INL=LI()

INL.sort()

ma = INL[-1]
mi = INL[0]

INL = INL[1:-1]

resl = []
if INL:
    if mi > 0:
        for i in INL:
            resl.append((mi,i))
            mi -= i
    else:
        for i in INL:
            if i < 0:
                resl.append((ma,i))
                ma -= i
            else:
                resl.append((mi,i))
                mi -= i

print(ma - mi)
for li in resl:
    print(li[0], li[1])
print(ma, mi)


Measured memory_bytes: 62748
#include<stdio.h>
#include<string.h>
 
int main(void){
  int i=0,N;
  int c0=0,c1=0,c2=0,c3=0;  
  
  scanf("%d",&N);
  
  char s[N][256];
  
  for(i=0;i<N;i++){
    scanf("%s",s[i]);
    if(strcmp(s[i],"AC")==0)
      c0++;
    if(strcmp(s[i],"WA")==0)
      c1++;
    if(strcmp(s[i],"TLE")==0)
      c2++;
    if(strcmp(s[i],"RE")==0)
      c3++;
  }
  printf("AC x %d\n",c0);
  printf("WA x %d\n",c1);
  printf("TLE x %d\n",c2);
  printf("RE x %d\n",c3);
  return 0;
}

Measured memory_bytes: 26728
s = input()
count = 0
for i in range(len(s)):
    if i %2 == 0:
        tile = "0"
    else:
        tile = "1"
    if s[i] == tile:
        count += 1
if len(s) //2 + 1 > count:
    print(count)
else:
    print(len(s)-count)
    

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
int n,a[200010];
ll sum[200010];
ll GetAns(ll x1,ll x2,ll x3,ll x4)
{
	ll Max=max(x1,max(x2,max(x3,x4))),Min=min(x1,min(x2,min(x3,x4)));
	return Max-Min;
}
ll abs(ll x,ll y) { return abs(x-y);}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	int l=1,r=3;
	ll ans=1LL<<60;
	for (int i=2;i<=n-1;i++)
	{
		while (l<i-1&&abs(sum[l],sum[i]-sum[l])>abs(sum[l+1],sum[i]-sum[l+1])) l++;
		while (r<n-1&&abs(sum[r]-sum[i],sum[n]-sum[r])>abs(sum[r+1]-sum[i],sum[n]-sum[r+1])) r++;
		ans=min(ans,GetAns(sum[l],sum[i]-sum[l],sum[r]-sum[i],sum[n]-sum[r]));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,f[110001][21],ans,s[110001];
vector<int> w[110001];
void dfs(int u,int p)
{
	for(int v:w[u])
		if(v!=p)
		{
			dfs(v,u);
			for(int j=0;j<18;j++)f[u][j]+=f[v][j];
		}
	int j=0;
	for(int i=17;i>=0;i--)
		if(f[u][i]>1){j=i+1;break;}
	while(f[u][j])j++;
	ans=max(ans,j);
	f[u][j]++;
	while(j--)f[u][j]=0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		w[x].push_back(y);
		w[y].push_back(x);
	}
	dfs(1,-1);
	printf("%d\n",ans);
}

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

num = int(input())
height_list = [int(string) for string in input().split()]

jump_num = 0
rtn = 0
for i in range(num-1):
  if height_list[i] >= height_list[i+1]:
    jump_num += 1
  else:
    rtn = rtn if rtn >= jump_num else jump_num
    jump_num = 0
rtn = rtn if rtn >= jump_num else jump_num
    
print(rtn)

Measured memory_bytes: 14224