akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<cmath>
using namespace std;

int pow(int x, int n){
  if(n == 0)return 1;
  int res = pow(x, n/2);
  if(n%2 == 1) return x*res*res;
  return res*res;
}

vector<int> Prime(int p){
  vector<bool> is_prime(p + 10, true);
  vector<int> prime;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= p; i++) {
    if(is_prime[i])prime.push_back(i);
    for (int j = 2*i; j <= p; j+=i) {
      is_prime[j] = false;
    }
  }
  return prime;
}

map<int, int> fact(int n){
  map<int, int> res;
  for (int i = 1; i*i <= n; i++) {
    if(n%i == 0){
      if(n/i == i)res[i]++;
      else res[i]++, res[n/i]++;
    }
  }
  return res;
}

int main(){
  int p, q;
  std::cin >> p >> q;
  int gcd = __gcd(p, q), ans = 1;
  p /= gcd;
  q /= gcd;
  set<int> s;
  for (int i = 2; i*i <= q; i++) {
    while(q%i == 0)s.insert(i), q/=i;
  }
  s.insert(q);
  for (auto i: s) {
    ans *= i;
  }
  std::cout << ans << std::endl;
  return 0;
}

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

int main()
{
	int N;
	deque < int > d;

	cin >> N;
	for ( int i = 0; i < N; i++ ) {
		int A, p;
		cin >> A;
		p = lower_bound(begin(d), end(d), A) - begin(d);
		if ( p == 0 ) d.push_front(A);
		else d[p - 1] = A;
	}

	cout << d.size() << endl;

	return ( 0 );
}


Measured memory_bytes: 640
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll dp[2000][2000];
ll d,a[2000];
ll rec(ll x,ll y){//x~y?????¨??£???
	if(dp[x][y]!=-1) return dp[x][y];
	if((y+1)%d==x) return dp[x][y]=0;
	if((y+2)%d==x) return dp[x][y]=a[(y+1)%d];
	ll res=0;
	//x-1?????????
	if(a[(x-2+d)%d]<a[(y+1)%d]){
		res=max(res,a[(x-1+d)%d]+rec((x-1+d)%d,(y+1)%d));
	}
	else{
		res=max(res,a[(x-1+d)%d]+rec((x-2+d)%d,y));
	}
	//y+1?????????
	if(a[(x-1+d)%d]<a[(y+2)%d]){
		res=max(res,a[(y+1)%d]+rec(x,(y+2)%d));
	}
	else{
		res=max(res,a[(y+1)%d]+rec((x-1+d)%d,(y+1)%d));
	}
	return dp[x][y]=res;
}
ll ans=0;
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>d;
	rep(i,d) cin>>a[i];
	rep(i,d){
		if(a[(i+1)%d]>a[(i-1+d)%d]){
			ans=max(ans,a[i]+rec(i,(i+1)%d));
		}
		else{
			ans=max(ans,a[i]+rec((i-1+d)%d,i));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 34404
import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数

    def root(self, x): #root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        elif self.parent[self.parent[x]] < 0:
            return self.parent[x]
        else:
            self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
            return self.parent[x]

    def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True

    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]


n,m=[int(i) for i in input().split()]

A=[[int(i)-1 for i in input().split()] for _ in range(m)]

ans = [0]*(m+1)
a = n*(n-1)//2
ans[0] = a

uf = UnionFind(n)
for i in range(m):
    j = m-i-1
    v1 = A[j][0]
    v2 = A[j][1]
#    print(v1,v2)
    if not uf.issame(v1,v2):
#        print(uf.parent)
        a -= uf.size(v1) * uf.size(v2)
        uf.merge(v1,v2)

    ans[i+1]=a

for i in range(m):
    print(ans[m-i-1])
    
    
    
    
    
    





Measured memory_bytes: 27192
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);

    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + (y1-y2) << " " << y2 + (x2-x1) << " " << x1 + (y1-y2) << " " << y1+ (x2-x1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_a

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll n;
ll dp_recursive(vector<ll> v , ll s ,ll e , ll cur){
    if(s>e){
        return 0;
    }
    ll ans = INT_MAX;
    if(cur+1 <=n){
        ans = min(ans ,abs(v[cur+1] - v[cur]) + dp_recursive(v , s+2 ,e ,cur+1) );
    }
    else{
        ans = min(ans , abs(v[cur+2] - v[cur]) + dp_recursive(v , s+3 ,e ,cur+2));
    }
    return ans;
}
ll func(vector<ll> h , ll n){
     vector<ll> dp(n+1); 
    dp[1] = 0;
    dp[2] =abs( h[2] - h[1] );
    for(int i = 3; i <= n ;i++){
        dp[i] = min( abs(h[i] - h[i-1]) + dp[i-1] , abs(h[i] - h[i-2]) + dp[i-2]);
    }
    return dp[n];
}
int main(){
    cin>>n;
    vector<ll>v(n+1);
    for(ll i = 1;i <=n ; i++){
        cin>>v[i];
    }
    //cout<<dp_recursive(v ,1 ,n , 1)<<endl;
    cout<<func(v , n)<<endl;
    
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin >> n;
  set<string> s;
  rep(i, n){
    string S; cin >> S;
    s.insert(S);
  }

  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 19220
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <list>

using namespace std;
int main() {
    string s;
    int q;
    cin >> s;
    cin >> q;
    list<char> a;
    for (string::iterator it = s.begin(); it != s.end(); it++) {
        a.push_back(*it);
    }
    bool rev = false;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;
            bool isf = rev == (f == 2);
            if (isf) {
                //s = c + s;
                a.push_front(c);
            } else {
                //s = s + c;
                a.push_back(c);
            }
        }
    }
    if (rev) {
        for (list<char>::reverse_iterator rit = a.rbegin(); rit != a.rend(); rit++) {
            cout << *rit;
        }
    } else {
        for (char c : a) {
            cout << c;
        }
    }
    return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define ll long long
#define mod7 1000000007
using namespace std;

void myfunc() {
    
}

int main() {
    int x;
  cin >> x;
  if(x)
    cout << '0' << endl;
  else
    cout << '1' << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD = 1e9 + 7;

ll x[100001];
ll y[100001];

ll mult(ll a, ll b)
{
	return (a*b)%MOD;
}

ll add(ll a, ll b)
{
	return (a+b)%MOD;
}

ll a[100001];
ll b[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m;cin>>n>>m;
	for(int i=0;i<n;i++) cin>>x[i];
	for(int i=0;i<m;i++) cin>>y[i];
	for(int i=0;i+1<n;i++) a[i]=x[i+1]-x[i];
	for(int i=0;i+1<m;i++) b[i]=y[i+1]-y[i];
	n--; m--;
	ll ans1 = 0;
	ll ans2 = 0;
	for(int i = 0; i < n; i++)
	{
		ans1 = add(ans1,mult(i+1,mult(n-i,a[i])));
	}
	for(int i = 0; i < m; i++)
	{
		ans2 = add(ans2,mult(i+1,mult(m-i,b[i])));
	}
	cout<<mult(ans1,ans2)<<'\n';
}


Measured memory_bytes: 3328
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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


int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int tgt = A.back() / 2;
    vector<pair<int, int>> B;
    rep(i, N-1) {
        B.push_back({abs(tgt-A[i]), A[i]});
        if(A.size() % 2) {
            B.push_back({abs(tgt+1-A[i]), A[i]});
        }
    }
    sort(B.begin(), B.end());
    cout << A.back() << " " << B[0].second << endl;

    return 0;
}



Measured memory_bytes: 5280
import java.util.*

val cin = Scanner(System.`in`)
fun main(args: Array<String>) {
    val n = cin.nextInt()
    val a = arrayListOf<Long>()

    for (i in 0 until n) {
        a.add(cin.nextLong())
    }
    println("${a.min()} ${a.max()} ${a.sum()}")
}



Measured memory_bytes: 44624
<?php
$n=trim(fgets(STDIN));
$o='';
for($i=1;$i<=$n;$i++){
  $x=$i;
  if(0==$x%3) $o.=' '.$i;
  else{
    while($x){
      if(3==$x%10){
        $o.=' '.$i;
        break;
      }
      $x=floor($x/10);
    }
  }
}
print $o;
?>

Measured memory_bytes: 15428
def zengo(l,n):
    if n<l[0]:
        return 0,l[0]-n
    elif n>l[-1]:
        return n-l[-1],0
    else:
        st=0
        ed=len(l)
        while ed-st>1:
            md=(st+ed)//2
            if n<l[md]:
                ed=md
            else:
                st=md
        return n-l[st],l[ed]-n

near=lambda x,y:min(x,y) if x*y else max(x,y)

jn,tn,qn,*tmp=map(int,open(0).read().split())
jz=tmp[:jn]
tz=tmp[jn:jn+tn]
q=tmp[jn+tn:]
for i in q:
    jb,jf=zengo(jz,i)
    tb,tf=zengo(tz,i)
    ans=[]
    if jb*tb:
        ans.append(max(jb,tb))
    if jf*tf:
        ans.append(max(jf,tf))
    jd=near(jb,jf)
    td=near(tb,tf)
    ans.append(jd+td+min(jd,td))
    print(min(ans))

Measured memory_bytes: 36612
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    lint res = 0;

    map<string, int> m;

    rep(i, n) {
        auto t = s[i];
        sort(all(t));
        res += m[t];
        m[t]++;
    }

    cout << res << endl;
    return 0;
}

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

using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int N;
int t[110], v[110];
int lim[50010];
 
long long int dp[5][205];
 
int main() {
    while (cin >> N) {
        for (int i = 0; i < N; ++i) 
          cin >> t[i], t[i] *= 2;
        int ans = 0;
        for (int i = 0; i < N; ++i) {
            cin >> v[i], v[i] *= 2;
            for (int j = ans; j < ans + t[i]; ++j) {
                lim[j] = v[i];
            }
            ans += t[i];
        }
        
        for (int i = 0; i < 5; ++i){
          for (int j = 0; j < 205; ++j){
            dp[i][j] = -1e27;
          }
        }
      
        dp[0][0] = 0;
        for (int i = 0; i < ans; ++i) {
          
            for (int j = 0; j < 205; ++j) {
                
                if (j + 1 <= min(lim[i], lim[i+1])) {
                  chmax(dp[(i+1)%2][j+1], dp[i%2][j] + j*2+1);
                }
              
                if (j <= min(lim[i], lim[i+1])){
                  chmax(dp[(i+1)%2][j], dp[i%2][j] + j*2);
                }
              
                if (j - 1 >= 0 && j - 1 <= min(lim[i], lim[i+1])){
                  chmax(dp[(i+1)%2][j-1], dp[i%2][j] + j*2-1);
                }
            }
            
            for (int j = 0; j < 205; ++j) dp[i%2][j] = -1e27;
          
        }
        
       printf("%.10lf\n",(double)dp[0][0]*0.125);
    }
}
 
 
 


Measured memory_bytes: 384
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    char x;
    cin >> x;
    cout << ((x >= 'a' && x <='z') ? 'a' : 'A') << endl;
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
const int mod = 1e9+7;

int a[N];
int fact[N];

int binpow(long long b, long long e) {
  if (!e) return 1;
  if (e&1) return b*binpow(b, e-1)%mod;
  return binpow(b*b%mod, e/2);
}

int nCr(int n, int k) {
  return 1LL * fact[n] * binpow(fact[k], mod-2) % mod * binpow(fact[n-k], mod-2) % mod;
}

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  fact[0] = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    if (i) {
      fact[i] = 1LL*fact[i-1]*i%mod;
    }
  }
  sort(a, a+n);
  long long ans = 0;
  for (int i = n-1; i >= k-1; --i) {
    ans = (ans + 1LL * a[i] * nCr(i, k-1) % mod) % mod;
  }
  for (int i = 0; i <= n-k; ++i) {
    ans = (ans - (1LL * a[i] * nCr(n-i-1, k-1)) % mod + mod) % mod;
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4512
using System;
using System.Linq;
using static System.Console;
using static System.Math;
class E { static void Main() => new K(); }
class K
{
	int[] G() => ReadLine().Split().Select(x => int.Parse(x)).ToArray();
	public K()
	{
		var I = G();
		WriteLine(Max(0, 2 * G().Max() - I[0] - 1));
	}
}


Measured memory_bytes: 2904
import os, sys, re, math

N = int(input())

s = math.sqrt(N)
upper = math.ceil(s)
lower = math.floor(s)

val1 = N
val2 = N
while val1 == N and val2 == N:
    if N % upper == 0:
        val1 = N // upper + upper - 2
    if N % lower == 0:
        val2 = N // lower + lower - 2
    upper += 1
    lower -= 1

print(min(val1, val2))


Measured memory_bytes: 3188
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(0)
  exit()
ans = 1
for i in range(len(A)):
  ans = ans * A[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
  else:
    pass
  
print(ans)


Measured memory_bytes: 21536
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int lr[501][501];

int main() {
	int N, M, Q;
	scanf("%d %d %d", &N, &M ,&Q);
	rep(i, 0, M) {
		int l, r;
		scanf("%d %d", &l, &r);
		++lr[l][r];
	}
	rep(i, 1, N + 1) {
		rep(j, 1, N + 1) {
			lr[i][j] += lr[i][j - 1]; 
		}
	}
	rep(i, 1, N + 1) {
		rep(j, 1, N + 1) {
			lr[j][i] += lr[j - 1][i]; 
		}
	}
	rep(i, 0, Q) {
		int p, q;
		scanf("%d %d", &p, &q);
		printf("%d\n", lr[q][q] - lr[p-1][q] - lr[q][p-1] + lr[p-1][p-1]);
	}
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin >>s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
const int N = 1e5+10;

void solve(int n) {
	vector<int> a(n);
	REP(i, 0, n) cin >> a[i];

	using P = pair<int, int>;

	P dp[2][N];
	REP(i, 0, 2) REP(j, 0, N) dp[i][j] = P(-1000,0);
	dp[0][0] = P(0,0);
	REP(i, 0, n) {
		int tmp = a[i] % 1000;
		if (tmp == 0) tmp = 1000;
		REP(j, 0, N) dp[(i+1)&1][j] = P(-1000,0);
		REP(j, 0, 100001) {
			if (tmp <= 500) {
				if (j + 500 - tmp < N) dp[(i + 1) & 1][j + 500 - tmp] = max(dp[(i + 1) & 1][j + 500 - tmp], P(dp[i & 1][j].first+1,dp[i&1][j].second-a[i]));
			}
			else{
				if (j - (tmp - 500) >= 0) dp[(i + 1)&1][j - (tmp - 500)] = max(dp[(i + 1)&1][j - (tmp - 500)], P(dp[i & 1][j].first + 1, dp[i & 1][j].second - a[i]));
				if(j+1000-tmp < N) dp[(i + 1)&1][j + 1000 -tmp] = max(dp[(i + 1)&1][j + 1000 - tmp], P(dp[i & 1][j].first, dp[i & 1][j].second - a[i]));
			}
			dp[(i + 1) & 1][j] = max(dp[(i + 1) & 1][j], dp[i & 1][j]);
		}
	}

	P ans = P(0,0);
	REP(i, 0, N) ans = max(ans, dp[n&1][i]);

	cout << ans.first << " " << -ans.second << endl;
}

int main() {
	int n;
	while (cin >> n, n) {
		solve(n);
	}
	return 0;
}


Measured memory_bytes: 4628
#include<bits/stdc++.h>
using namespace std;
int a[10]={1,3,5,7,8,10,12};
int b[10]={4,6,9,11};
int main(){
	int m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if(m1==2&&d1==28)
		puts("1");
	else{
		int f=0;
		for(int i=0;i<7;i++){
			if(a[i]==m1&&d1==31){
				f=1;
				puts("1");
				return 0;
			}
		}
		if(f==0){
			for(int i=0;i<4;i++){
				if(b[i]==m1&&d1==30){
					f=1;
					puts("1");
					return 0;;
				}
			}
		}
		puts("0");
	}
} 

Measured memory_bytes: 256
#n=int(input())
n,k=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(1,n+1):
    p=i
    count=0
    while p<k:
        count+=1
        p=p*2
    ans+=(0.5**count)
ans=ans/n
print('{:.11f}'.format(ans))

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

using namespace std;
typedef long long unsigned int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int n; cin >> n;
    int m; cin >> m;
    vector <int> bit_s_list;
    REP(i ,n){
        bit_s_list.push_back(0);
    }
    int k;
    int s;
    REP(i, m){
        cin >> k;
        REP(j, k){
            cin >> s;
            bit_s_list[s-1] += pow(2, i);
        }
    }
    int bit_correct_l = 0;
    int b;
    REP(i, m){
        cin >> b;
        bit_correct_l += b * pow(2, i);
    }
    int ans = 0;
    int bit_cand_l = 0;
    REP(i, pow(2, n)){
        REP(j, n){
            if (int(i/pow(2, j)) % 2){
                bit_cand_l = bit_cand_l ^ bit_s_list[j];
            }
        }
        if (bit_cand_l == bit_correct_l){
            ans++;
        }
        bit_cand_l = 0;
    }
    cout << ans << endl;
    return 0;
}

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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr i64 INF = std::numeric_limits<i64>::max()/2;


struct S {
	i64 a;
	i64 b;
};

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	i64 h, n;

	std::cin >> h >> n;

	std::vector<S> v(n);

	for(i64 i=0; i<n; ++i)
	{
		i64 a, b;
		std::cin >> a >> b;
		v[i] = {a, b};
	}
	
	i64 dp[h+1];
	dp[0]=0;
	for(i64 i=1;i<h+1;++i)
	{
		dp[i]=INF;
	}

	for(i64 i=0;i<h+1;++i)
	{
		for(i64 j=0;j<n;++j)
		{
			dp[i] = std::min(dp[i], dp[std::max(i-v[j].a, i64(0))]+v[j].b);
		}
	}

	i64 ans = dp[h];

	std::cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define INF 1e9

int n;
string s;
vector<int> g[2000];

struct T { int L, R, num; };

T dfs(int cur, int par) {
    int sumR = 0, num = 0, maxL = 0, maxL_R = 0;
    for (int to : g[cur]) if (par != to) {
        T ch = dfs(to, cur);
        sumR += ch.R;
        num += ch.num;
        if ((maxL < ch.L) || (maxL == ch.L && maxL_R > ch.R)) {
            maxL = ch.L;
            maxL_R = ch.R;
        }
    }
    if (s[cur] == '1') num++;
    return { max(0, maxL - (sumR - maxL_R)) + num, sumR + num, num };
}

int main(void){
    cin >> n >> s;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int res = INF;
    rep(root, n){
        T p = dfs(root, -1);
        if (p.L == p.num && (p.R - p.num)%2 == 0) {
            res = min(res, (p.R - p.num)/2);
        }
    }
    cout << (res < INF ? res : -1) << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const long long N = 2e5+7;
const long long mod = 1e9+7;
long long w, h, a, b, ans = 0, uu[N];
long long poww(long long a, long long b){
	if(!b) return 1;
	if(b == 1) return a%mod;
	long long d = poww(a,b/2);
	if(b%2 == 0) return (d*d)%mod;
	else return (d*((d*a)%mod))%mod;
}
 
long long C(long long k, long long n){
	if(k == 0) return 1;
	if(k == n) return 1;
	long long res = (uu[n]*((poww(uu[n-k], mod-2)*poww(uu[k], mod-2))%mod))%mod;
	return res;
}
 
long long take_ans(long long x, long long y, long long m, long long n){
	return C(m-x, m+n-x-y);
}
signed main(){
	cin >> w >> h >> a >> b;
	uu[0] = 1;
	for(long long i = 1; i <= 2e5+4; ++i){
		uu[i] = (uu[i-1]*i)%mod;
	}
	for(long long i = 1; i <= w-a; ++i){
		if(i == 1) ans += (take_ans(1,1,i,b+1)*take_ans(i,b+1,w,h))%mod;
		else ans += (((take_ans(1,1,i,b+1)-take_ans(1,1,i-1,b+1)+mod*mod)%mod)*take_ans(i,b+1,w,h))%mod;
		ans%=mod;
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 998244353;
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//abcのbed乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];
ll dp[800005];


int main(){	
	cin>>n>>k;
	b = k;
	for(i=0;i<n;i++){
		cin>>x[i];
		sum += x[i];
	}
	sort(x,x+n);
	for(i=0;i<n;i++){
		if(k>=x[i]){
			k -= x[i];
			ans ++;
		}
	}
	if(ans==n && sum != b){
		ans--;
	}
	p(ans);
	
	
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  vector<int> v(n,-1);

  for(int i = 0; i < m; ++i){
    int x, y; cin >> x >> y;x--;y--;
    ChangeMax(v[y], x);
  }

  int sum = 0, cut = -1;

  for(int i = 0; i < n; ++i){
    if(v[i] != -1 && v[i] > cut){
      sum++;
      cut = i-1;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 768
import math,fractions
a=list(map(int,input().split()))
A=a[1]-a[0]+1
B=a[1]//a[2]-(a[0]-1)//a[2]
C=a[1]//a[3]-(a[0]-1)//a[3]
d=int((a[2]*a[3])/fractions.gcd(a[2],a[3]))
D=(a[1]//d)-(a[0]-1)//d
print(A-B-C+D)


Measured memory_bytes: 64492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll mod=INF;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int c=0;
    rep(i,n) c=(c^a[i]);
    rep(i,n){
      int f=(c^a[i]);
      cout << f << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4044
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)

//グローバル変数宣言
 ll p=0,q=0;//r=0;

int main()
{
  ll n,m;
  cin>>n>>m;
  vl l(m),r(m);
  q=n;
  rep(i,m){cin>>l[i]>>r[i];p=max(p,l[i]);q=min(q,r[i]);}
  ll a=0;
  a=max(a,q-p+1);
  print(a)
}

Measured memory_bytes: 4592
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int a,b;
  cin >> a >> b;
  
  int ans = -1;
  REP(i,10000){
    int c = i * 0.08;
    int d = i * 0.1;
    if(c == a && d == b){
	  ans += i+1;
      break;
    }
    else{
      continue;
    }
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 3644
k = int(input().split(" ")[1])
s = input()

arr = []
if s[0] is "0": 
  arr.append(0)
arr.append(1)
for i in range(1,len(s)):
  if s[i-1] is s[i]:
    arr[-1] += 1
  else:
    arr.append(1)
if s[-1] is "0": 
  arr.append(0)

sums = [0]
for i in range(len(arr)):
  sums.append(sums[i] + arr[i])
t = 2*k+1
m = 0
for i in range(0,len(arr),2):
  m = max(m,sums[min(len(sums)-1,i+t)]-sums[i])
print(m)


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

ll bit_count(ll bits) {
    ll cnt = 0;
    for (; bits != 0; bits >>= 1) {
        cnt += bits & 1;
    }
    return cnt;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll ans = 1ll << 60;

    rep(bit, 1 << N) {
        if (bit_count(bit) != K) continue;
        if ((bit & 1) == 0) continue;

        ll now = 0;
        ll prev = 0;
        rep(j, N) {
            if (bit >> j & 1) {
                ll diff = max(prev + 1ll - a[j], 0ll);
                now += diff;
                chmax(prev, a[j] + diff);
            }
            prev = max(prev, a[j]);
        }
        chmin(ans, now);
    }

    cout << ans << endl;
}


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

int main(void) {
  string S;
  string T;

  cin >> S;
  cin >> T;
  char tmp;
  int num = S.size();
  for (int i = 0; i < num; i++) {
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
    tmp = S[S.size()-1];
    S.erase(S.end()-1);
    S = tmp + S;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;


int main() {
  vector<vector<int> > A(3, vector<int>(3, 0));
  rep(i, 3) rep(j, 3) cin >> A[i][j];

  int N;
  cin >> N;

  vector<int> b(N);
  rep(i, N) cin >> b[i];

  vector<vector<int> > B(3, vector<int>(3, 0));
  rep(k, N) rep(i, 3) rep(j, 3) {
    if (A[i][j] == b[k]) B[i][j] = 1;
  }

  bool ans = false;
  rep(i, 3) if (B[i][0] && B[i][1] && B[i][2]) ans = true;
  rep(i, 3) if (B[0][i] && B[1][i] && B[2][i]) ans = true;
  if (B[0][0] && B[1][1] && B[2][2]) ans = true;
  if (B[2][0] && B[1][1] && B[0][2]) ans = true;

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import bisect
import sys

A, B, Q = map(int,input().split())
s = [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18]
t = [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*B))) + [10**18]


def solve(s,t,x):
    ans = 10**18
    for i in range(2):
        a, b = (s, t) if i==0 else (t, s)
        posX1 = bisect.bisect_left(a,x)
        for j in range(2):
            ax = a[posX1 -j]
            posX2 = bisect.bisect_left(b,ax)
            for k in range(2):
                bx = b[posX2-k]
                ans = min(ans, abs(x-ax)+abs(bx-ax))
    return ans

for _ in range(Q):
    x = int(input())
    print(solve(s,t,x))

Measured memory_bytes: 14476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, i;
  in(n);
  string s, t;
  in2(s, t);
  ll dp[n];
  if(s[0] == t[0]){
    a = 0;
    i = 1;
    dp[0] = 3;
  }
  else{
    a = 1;
    i = 2;
    dp[1] = 6;
  }
  while(i < n){
    if(a == 0){
      if(s[i] == t[i]){
        dp[i] = 2 * dp[i - 1] % mei;
        i++;
      }
      else{
        dp[i + 1] = 2 * dp[i - 1] % mei;
        a = 1;
        i += 2;
      }
    }
    else{
      if(s[i] == t[i]){
        dp[i] = dp[i - 1] % mei;
        a = 0;
        i++;
      }
      else{
        dp[i + 1] = 3 * dp[i - 1] % mei;
        i += 2;
      }
    }
  }
  out(dp[n - 1]);
  memi;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int *fact, *fact_inv;

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int A(int N, int x){
	if(N - x < 0 || N - x > x - 1 || x - 1 < 0){
		return 0;
	}
	else{
		return MOD(MOD(fact[x - 1] * fact_inv[N - x]) * MOD(fact[x] * fact_inv[2 * x - N - 1]));
	}
}

signed main(){
	int N, i, ans = 0;
	scanf("%lld", &N);
	fact = (int *)malloc(sizeof(int) * (N + 1));
	fact_inv = (int *)malloc(sizeof(int) * (N + 1));
	fact[0] = 1;
	fact_inv[0] = 1;
	fact_inv[1] = 1;
	for(i = 1; i <= N; i++){
		fact[i] = MOD(fact[i - 1] * i);
	}
	for(i = 2; i <= N; i++){
		fact_inv[i] = MOD(-(p / i) * fact_inv[p % i]);
	}
	for(i = 1; i <= N; i++){
		fact_inv[i] = MOD(fact_inv[i] * fact_inv[i - 1]);
	}
	for(i = 1; i < N; i++){
		ans = MOD(ans + i * MOD(MOD(fact[N - 1 - i] * A(N - 1, i)) - MOD(fact[N - i] * A(N - 1, i - 1))));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 15744
#include <iostream> 
#include <cstdio> 
#include <cstdlib>  
#include <algorithm> 
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> backet(1e6, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        backet[a[i]]++;
        backet[a[i] + 1]++;
        if(a[i])
        backet[a[i] - 1]++;
    }
    int ans = 0;
    for (int i = 0; i < 1e6; i++) {
        if (backet[i] == 0) continue;
        ans = max(ans, backet[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7396
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int A[N], B[N];
    for(int i = 0; i < N; i++) {
        B[i] = 0;
    }
    for(int i = 1; i < N; i++) {
        cin >> A[i];
        B[A[i] -= 1]++;
    }
    for(int i = 0; i < N; i++) {
        cout << B[i] << endl;
    }
}


Measured memory_bytes: 5180
#include <tuple>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
using ll	= long long;
using ull	= unsigned long long;
using ld	= long double;
using pii	= pair<int,int>;
using pll	= pair<ll,ll>;
using vi	= vector<int>;
using vb	= vector<bool>;
using vc	= vector<char>;
using vvi	= vector<vi>;
using vvb	= vector<vb>;
using vpii	= vector<pii>;
using vpll	= vector<pll>;
using vll	= vector<ll>;
using vull	= vector<ull>;
using vvll	= vector<vll>;
#define ever (;;)
#define f first
#define s second
#define pb emplace_back
#define sz size()
#define graph vector<vertex>
#define deg(X) (int)G[X].e.size()
#define INF 1234567890
#define INFll 2000000000000000000
#define maxe(X, Y) if((Y) > (X)) (X) = (Y)
#define mine(X, Y) if((Y) < (X)) (X) = (Y)
#define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i)
#define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i)
#define bend(X) X.begin(), X.end()
pii operator+(const pii& A, const pii& B) { return {A.f+B.f, A.s+B.s}; }
pii operator-(const pii& A, const pii& B) { return {A.f-B.f, A.s-B.s}; }
pii operator-(const pii& A) { return {-A.f, -A.s}; }

//
// END OF DEFINES
//

int n;
vll T;
vvll DP;
vll P;

bool in() {
	scanf("%d", &n);
	T.resize(n);
	P.resize(n+1);
	DP.resize(n, vll(n));
	rep(i, 0, n)
		scanf("%lld", &T[i]);
	
	return true;
}

ll get(int a, int b) {
	return P[b+1]-P[a];
}

ll solve() {
	rep(i, 1, n+1)
		P[i] = P[i-1] + T[i-1];
	
	rep(i, 0, n)
		DP[i][i] = T[i];
	rep(l, 1, n) {
		rep(i, 0, n-l) {
			int j = i+l;
			DP[i][j] = get(i, j) - min(DP[i+1][j], DP[i][j-1]);
		}
	}
	
	ll X = DP[0][n-1];
	ll Y = get(0, n-1)-X;
	return X-Y;
	
	return -INF;
}

int main() {
	int noOfTests = 1;
	//scanf("%d", &noOfTests);
	
	while(noOfTests --> 0) {
		if(!in()) {
			printf("popsute wejscie\n");
			continue;
		}
		ll result = solve();
		if(result == ll(-'t'))
			printf("TAK\n");
		else if(result == ll(-'n'))
			printf("NIE\n");
		else if(result != -INF)
			printf("%lld\n", result);
	}
	
	return 0;
}


Measured memory_bytes: 70784
/*
 * FileName:     C
 * CreatedDate:  2020-05-30 13:55:59 +0900
 * LastModified: 2020-05-30 14:09:03 +0900
 */

#include <stdio.h>
#include <stdlib.h>
long int gcd(long int *a, int n){
    for(int i=1;i<n;i++){
        long int x = a[i];
        long int y = a[i-1];
        long int r;
        while(x%y!=0){
            r=x%y;
            x=y;
            y=r;
        }
        a[i]=y;
    }
    return a[n-1];
}
int main(void){
    int n;scanf("%d",&n);
    long int *a = malloc(n*sizeof(long int));
    for(int i=0;i<n;i++){scanf("%ld",a+i);}
    long int g = gcd(a,n);
    printf("%ld\n",g);
    free(a);
    return 0;
}


Measured memory_bytes: 896
#include<cstdio>
using namespace std;
const int N=200005;
int A[N],i,j,k,n,m,T,f;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

bool check(int a,int b,int c)
{
	return a<b&&b<c||b<c&&c<a||c<a&&a<b;
}

int main()
{
	n=read();
	for (i=1;i<=n;++i) A[read()]=i;
	for (i=n-1;i;--i)
	{
		if (T)
		{
			if (!check(A[f],A[i],A[i+1]))
				++T,f=i+1;
		}
		else
			if (A[i]>A[i+1])
				++T,f=i+1;
	}
	printf("%d\n",T);
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
int main(){
    char s[11];
    int f=0;
    scanf("%s",s);
    if(s[0]>'2') f=1;
    else if(s[0]=='2'&&s[1]>'0') f=1;
    else if(s[0]=='2'&&s[1]=='0'&&s[2]>'1') f=1;
    else if(s[0]=='2'&&s[1]=='0'&&s[2]=='1'&&s[3]>'9') f=1;
    else if(s[0]=='2'&&s[1]=='0'&&s[2]=='1'&&s[3]=='9'&&s[5]>'0') f=1;
    else if(s[0]=='2'&&s[1]=='0'&&s[2]=='1'&&s[3]=='9'&&s[5]=='0'&&s[6]>'4') f=1;

    if(f==1)
        printf("TBD");
    else
        printf("Heisei");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int N,can=1;
    cin >>N;
    vi A(N);
    FOR(i,0,N-1){
        cin >>A[i];
    }
    if(N==1){
        cout <<1;
    }else{
        if(N%2==0){
            vi aaa(N/2,2);
            FOR(i,0,N-1){
                FOR(k,0,(N/2)-1){
                    if(A[i]==(2*k+1)){
                        aaa[k]--;
                        if(aaa[k]<0) can=0;
                        break;
                    }
                }
                if(can==0) break;
            }
            if(can==0) cout <<0;
            if(can==1) {
                unsigned long long nn=1;
                FOR(i,1,N/2){
                    nn=(nn*2)%(unsigned long long)(pow(10,9)+7);
                }
                cout <<nn;
            }
        }
        if(N%2==1){
            vi aaa(N/2+1,2);
            aaa[0]=1;
            FOR(i,0,N-1){
                FOR(k,0,N/2){
                    if(A[i]==(2*k)){
                        aaa[k]--;
                        if(aaa[k]<0) can=0;
                        break;
                    }
                }
                if(can==0) break;
            }
            if(can==0) cout <<0;
            if(can==1) {
                unsigned long long nn=1;
                FOR(i,1,N/2){
                    nn=(nn*2)%(unsigned long long)(pow(10,9)+7);
                }
                cout <<nn;
            }
        }
    }

    return 0;
}





Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD (998244353)
int main(void) {
  int N, S;
  cin >> N >> S;
  vector <long long> dp(S+1);
  dp[0] = 1;
  for (int i = 1; i <= N; i++) {
    int A;
    cin >> A;
    vector <long long> p(S+1);
    swap(dp, p);
    for (int i = 0; i <= S; i++) {
      dp[i] += p[i]+p[i];
      dp[i] %= MOD;

      if (i+A <= S) {
        dp[i+A] += p[i];
        dp[i+A] % MOD;
      }
    }
  }
  cout << dp[S] << endl;
  return 0;
}


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

const int N=110;
int n;string s[N];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		cin>>s[i];
		if(i!=1&&s[i][0]!=s[i-1][s[i-1].length()-1]) return puts("No"),0;
		for(int j=1;j<i;j++) {
			if(s[i]==s[j]) return puts("No"),0;
		}
	}
	return puts("Yes"),0;
}

Measured memory_bytes: 256
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */

struct cmp
{
	bool operator() (pii a, pii b) {
		return (a.l < b.l);
	}
};

int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

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

int dp[2001];

int go(int x) {
	if (x < 0)
		return 0;
	if (dp[x] != -1)
		return dp[x];
	int ans = 0;
	for (int i = 3; i <= 2000; i++) {
		ans += go(x - i);
		ans %= mod;
	}
	return dp[x] = ans;

}


signed main()
{

// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	haha
	int s;
	cin >> s;
	for (int i = 0; i <= 2000; i++)
		dp[i] = -1;
	dp[0] = 1;
	cout << go(s);








}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> a(W + 2, '#');
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int j = 0; j < H; j++) {
    for (int i = 0; i < W; i++) {
      cin >> a.at(i + 1);
    }
    for (int i = 0; i < W + 2; i++) {
      cout << a.at(i);
    }
    cout << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int N, K;
  cin >> N >> K;
  ll ans = 0;
  vector<int> Hi(N);
  rep(i, N)
    cin >> Hi.at(i);
  sort(Hi.begin(),Hi.end(), greater<int>());
  if(K > N)
    ans = 0;
  else{
    for(int i = K; i < N; i++){
      ans += Hi.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024