akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
//void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
//void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"

#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

///////////////////////////

int main(){fastio
    
    ll n;cin>>n;
    vector<l_l>a(n);
    rep(i,0,n-1)cin>>a[i].fi>>a[i].se;
    SORT(a);
    vector<l_l>lp(n),rp(n);
    lp[0]=a[0];
    rep(i,1,n-1){
        lp[i]=lp[i-1];
        Max(lp[i].fi,a[i].fi);
        Min(lp[i].se,a[i].se);
    }
    rp[n-1]=a[n-1];
    for(ll i=n-2;i>=0;i--){
        rp[i]=rp[i+1];
        Max(rp[i].fi,a[i].fi);
        Min(rp[i].se,a[i].se);
    }
    ll ans=0;
    rep(i,0,n-2){
        ll sl=max(0,lp[i].se-lp[i].fi+1);
        ll sr=max(0,rp[i+1].se-rp[i+1].fi+1);
        Max(ans,sl+sr);
    }
    rep(i,0,n-1){
        ll salone=a[i].se-a[i].fi+1;
        l_l sl={-inf,inf},sr={-inf,inf};
        if(i-1>=0)sl=lp[i-1];
        if(i+1<=n-1)sr=rp[i+1];
        l_l s={max(sl.fi,sr.fi),min(sl.se,sr.se)};
        ll sval=max(0,s.se-s.fi+1);
        Max(ans,sval+salone);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 4992
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b, c;
    scan(a, b, c);
    auto check = new bool[](b);
    long i = 1;
    while (!check[a * i % b])
    {
        check[a * i % b] = true;
        i++;
    }
    if (check[c])
        writeln("YES");
    else
        writeln("NO");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
sowa=0
hajime=[]

for x in input().split(" "):
    hajime.append(int(x))

if hajime[1]>0:
    i=2
    while i<=hajime[0]:
        sowa+=hajime[1]+i-1
        i+=1

elif hajime[1]==0:
    i=1
    while i<=hajime[0]:
        sowa+=hajime[1]+i-1
        i+=1

else:
    if hajime[0]+hajime[1]-1>=0:
        i=1
        while i<=hajime[0]:
            sowa+=hajime[1]+i-1
            i+=1
    else:
        i=1
        while i<=hajime[0]-1:
            sowa+=hajime[1]+i-1
            i+=1

print(sowa)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] color = new int[N];
    int[] dist = new int[N];
    color[0] = 1;
    color[N - 1] = -1;
    ArrayList[] edge = new ArrayList[N];
    for(int i = 0; i < N; i++) {
      edge[i] = new ArrayList<Integer>();
    }
    for(int i = 0; i < N - 1; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      edge[a].add(b);
      edge[b].add(a);
    }
    LinkedList<Integer> bque = new LinkedList<Integer>();
    LinkedList<Integer> wque = new LinkedList<Integer>();
    bque.add(0);
    wque.add(N - 1);
    int count = 0;
    while((bque.size() > 0) || (wque.size() > 0)) {
      if(bque.size() > 0) {
        boolean flg = true;
        while(flg && (bque.size() > 0)) {
          int v = bque.peek();
          if(dist[v] == count) {
            bque.poll();
            ArrayList<Integer> e = edge[v];
            for(int i = 0; i < e.size(); i++) {
              int u = e.get(i);
              if(color[u] == 0) {
                color[u] = 1;
                bque.add(u);
                dist[u] = count + 1;
              }
            }
          } else {
            flg = false;
          }
        }
      }
      if(wque.size() > 0) {
        boolean flg = true;
        while(flg && (wque.size() > 0)) {
          int v = wque.peek();
          if(dist[v] == count) {
            wque.poll();
            ArrayList<Integer> e = edge[v];
            for(int i = 0; i < e.size(); i++) {
              int u = e.get(i);
              if(color[u] == 0) {
                color[u] = -1;
                wque.add(u);
                dist[u] = count + 1;
              }
            }
          } else {
            flg = false;
          }
        }
      }
      count++;
    }
    int x = 0;
    for(int i = 0; i < N; i++) {
      if(color[i] == 1) x++;
    }
    String ans = "Snuke";
    if(x > N - x) ans = "Fennec";
    System.out.println(ans);
  }
}

Measured memory_bytes: 102056
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll N;
vector<ll> x, y, t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	t.push_back(0);
	x.push_back(0);
	y.push_back(0);
	for(int i = 0; i < N; i++) {
		int tmpX, tmpY, tmpT;
		cin >> tmpT >> tmpX >> tmpY;
		t.push_back(tmpT);
		x.push_back(tmpX);
		y.push_back(tmpY);
	}

	
	for(int i = 0; i < N; i++) {
		ll dt = t[i + 1] - t[i];
		ll dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if(dt < dist) {
			cout << "No" << endl;
			return 0;
		}
		if(dt % 2 == dist % 2) continue;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;


	
}


Measured memory_bytes: 2912
mod utils {
    use std::error::Error;
    use std::io::stdin;
    use std::str::FromStr;

    #[allow(dead_code)]
    pub fn read_line<T>() -> Result<Vec<T>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        let mut line = String::new();
        let _ = stdin().read_line(&mut line)?;
        let parsed_line = line.split_whitespace()
            .map(|x| x.parse::<T>())
            .collect::<Result<Vec<T>, T::Err>>()?;

        Ok(parsed_line)
    }

    #[allow(dead_code)]
    pub fn read_lines<T>(n: usize) -> Result<Vec<Vec<T>>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        (0..n).map(|_| read_line()).collect()
    }
}

fn solve() -> Result<(), Box<std::error::Error>> {
    let header = utils::read_line::<usize>()?;
    let n_nodes = header[0];
    let n_edges = header[1];
    let edges = utils::read_lines::<i32>(n_edges)?;
    let mut distances = vec![vec![None as Option<i32>; n_nodes]; n_nodes];

    for i in 0..n_nodes {
        distances[i][i] = Some(0);
    }

    // initial distance
    for edge in edges {
        distances[edge[0] as usize][edge[1] as usize] = Some(edge[2]);
    }

    // update distances
    for k in 0..n_nodes {
        for i in 0..n_nodes {
            for j in 0..n_nodes {
                let d_ikj = if distances[i][k].is_some() && distances[k][j].is_some() {
                    Some(distances[i][k].unwrap() + distances[k][j].unwrap())
                } else {
                    None
                };
                let d_ij = distances[i][j];

                distances[i][j] = if d_ij.is_some() {
                    if d_ikj.is_some() {
                        Some(std::cmp::min(d_ij.unwrap(), d_ikj.unwrap()))
                    } else {
                        d_ij
                    }
                } else {
                    if d_ikj.is_some() {
                        d_ikj
                    } else {
                        None
                    }
                };
            }
        }
    }

    let has_negative_cycle = distances
        .iter()
        .enumerate()
        .find(|&(i, row)| (*row)[i].unwrap_or(0) < 0)
        .is_some();

    if has_negative_cycle {
        println!("NEGATIVE CYCLE");
        return Ok(());
    }

    for row in distances {
        let row_string: String = row.iter()
            .map(|d_opt| match *d_opt {
                Some(d) => d.to_string(),
                None => "INF".to_string(),
            })
            .collect::<Vec<String>>()
            .join(" ");
        println!("{}", row_string);
    }
    Ok(())
}

fn main() {
    match solve() {
        Err(err) => panic!("{}", err),
        _ => (),
    };
}



Measured memory_bytes: 5056
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N=ii()
    d = defaultdict(int)
    for _ in range(N):
        d[input()]+=1
    m = max(d.values())
    ss = [s for s in d.keys() if d[s]==m]
    ss.sort()
    for s in ss:
        print(s)

main()







Measured memory_bytes: 34228
// 問題の URL を書いておく
// https://atcoder.jp/contests/abc167/tasks/abc167_e

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

template<int Mod>
struct MintBase {
  int64_t x; // typedef long long int64_t;
  MintBase(int64_t x=0):x((x%Mod+Mod)%Mod){}
  MintBase operator-() const { return MintBase(-x);}
  MintBase& operator+=(const MintBase a) {
    if ((x += a.x) >= Mod) x -= Mod;
    return *this;
  }
  MintBase& operator-=(const MintBase a) {
    if ((x += Mod-a.x) >= Mod) x -= Mod;
    return *this;
  }
  MintBase& operator*=(const MintBase a) { (x *= a.x) %= Mod; return *this;}
  MintBase operator+(const MintBase a) const { return MintBase(*this) += a;}
  MintBase operator-(const MintBase a) const { return MintBase(*this) -= a;}
  MintBase operator*(const MintBase a) const { return MintBase(*this) *= a;}
  MintBase pow(int64_t t) const {
    if (!t) return 1;
    MintBase a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime Mod
  MintBase inv() const { return pow(Mod-2);}
  MintBase& operator/=(const MintBase a) { return *this *= a.inv();}
  MintBase operator/(const MintBase a) const { return MintBase(*this) /= a;}
};

//const int Mod = 1000000007;
//const int Mod = 998244353;

using mint = MintBase<998244353>;

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint factorial(const mint& x)
{
    mint ans = 1;
    for(mint i = x.x; i.x != 0; i -= 1)
    {
        ans *= i;
    }
    return ans;
}

mint factorial(const mint& x, const mint& n)
{
    mint ans = 1;
    mint m = x;
    for(int64_t i = 0; i < n.x; ++i)
    {
        ans *= m;
        m -= 1;
    }
    return ans;
}

mint Combination(int64_t x, int64_t y)
{
    return  factorial(x, y) / factorial(y);
}

int main(int argc, const char* argv[])
{
    int n, m, k;
    cin >> n >> m >> k;

    vector<mint> mul(n);
    mul[0] = m;
    for(int i = 1; i < n; ++i)
    {
        mul[i] = mul[i - 1] * (m - 1);
    }

    mint ans = 0;
    mint upper = 1;
    mint lower = 1;
    for(int i = 0; i <= k; ++i)
    {
        mint c = 1;
        if(i > 0)
        {
            upper *= (n - i);
            lower *= i;
            c = upper / lower; 
        }
        auto paint = mul[n - 1 - i];
        ans += c * paint;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4756
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
int N;
void f(int T)
{
	printf("%02d:%02d:%02d",T/3600,T/60%60,T%60);
}
main()
{
	while(cin>>N,N)
	{
		vector<pair<int,int> >A;
		for(int i=0;i<N;i++)
		{
			vector<int>a(3);
			cin>>a[0]>>a[1]>>a[2];
			sort(a.begin(),a.end());
			do{
				for(int d=0;d<60;d++)
				{
					int m=a[1],hm=a[0]%5*12;
					if(hm<=m&&m<hm+12)
					{
						A.push_back(make_pair(a[0]/5*3600+a[1]*60+a[2],i));
					}
					for(int k=0;k<3;k++)a[k]=(a[k]+1)%60;
				}
			}while(next_permutation(a.begin(),a.end()));
		}
		sort(A.begin(),A.end());
		int ansL=0,ansR=43200;
		int cnt[10]={},ecnt=0,r=0;
		for(int l=0;l<A.size();l++)
		{
			while(ecnt<N&&r<A.size())
			{
				ecnt+=!cnt[A[r++].second]++;
			}
			if(ecnt==N)
			{
				int L=A[l].first,R=A[r-1].first;
				if(ansR-ansL>R-L)
				{
					ansL=L;
					ansR=R;
				}
			}
			ecnt-=!--cnt[A[l].second];
		}
		f(ansL);
		cout<<" ";
		f(ansR);
		cout<<endl;
	}
}


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

int main() {
    string s;
    int ans = 0;
    cin >> s;
    for(int i = 1; i < s.size()/2; ++i) {
        bool f = true;
        for(int j = 0; j < i; ++j) {
            if(s[j] != s[j+i]) f = false;
        }
        if(f) ans = max(ans, i*2);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
s = input()

con = []
prev = s[0]
cnt = 1
for ss in s[1:]:
    if ss == prev:
        cnt += 1
    else:
        prev = ss
        con.append(cnt)
        cnt = 1
else:
    con.append(cnt)

idx = 0
cnt = 1
res = []
res.append(0) if s[0] == '<' else res.append(con[idx])
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        if s[i] == '<':
            res.append(cnt)
        else:
            res.append(con[idx]-cnt)
        cnt += 1
    else:
        idx += 1
        if s[i] == '<':
            res.append(max(cnt, con[idx]))
        else:
            res.append(0)
        cnt = 1
res.append(0) if s[-1] == '>' else res.append(con[-1])

print(sum(res))


Measured memory_bytes: 23836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a == 12)
    {
        if(c == 1) cout << 1 << endl;
        else cout << 0 << endl;
    }
    else
    {
        if(c == a+1) cout << 1 << endl;
        else cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;
    int k2 = 4*x - y;
    int t2 = -2*x+y;
    if(k2>= 0 && t2>=0 && k2%2==0 && t2%2 == 0) {
        cout << "Yes" << endl;
    } else {
        cout <<"No" << endl;
    }
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                int[] C = new int[N];
                int[] S = new int[N];
                int[] F = new int[N];
                for (int i = 1; i < N; i++) {
                        C[i] = sc.nextInt();
                        S[i] = sc.nextInt();
                        F[i] = sc.nextInt();
                }
                int[] output = new int[N+1];

                for (int i = 1; i < N; i++) {
                        for (int j = i; j < N; j++) {
                                if (output[i] < S[j]) {
                                        output[i] = S[j] + C[j];
                                } else if (output[i] % F[j] == 0) {
                                        output[i] += C[j];
                                } else {
                                        output[i] += F[j] - output[i] % F[j] + C[j];
                                }
                        }
                }

                for (int i = 1; i <= N; i++) {
                        System.out.println(output[i]);
                }
        }
}


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

int main(){
  int n;
  cin>>n;
  vector<pair<pair<string,int>,int>> a;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    a.push_back(make_pair(make_pair(s,-1*p),i));
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout<<a.at(i).second<<endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,x,y,ans=0;
    cin >> n >> x;
    rep(i,n){
        cin >> y;
        ans=gcd(ans,abs(x-y));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
n = onem()
a = l()


if n % 2 == 0:
    po = [a[i] for i in range(n)]
    
    for i in range(n-3,-1,-1):
        po[i] += po[i+2]

    ans = sum(a[0::2])
    ans = max(ans,sum(a[1::2]))
    co = 0
    for i in range(0,n,2):
        if i+1 <= n-1:
            ans = max(ans,co+po[i+1])
        else:
            ans = max(ans,co)
        co += a[i]

    print(ans)

else:
    po = [a[i] for i in range(n)]
    mi = [-Max for i in range(n)]
    
    for i in range(n-3,-1,-1):
        po[i] += po[i+2]

    ans = sum(a[1::2])
    ans = max(ans,sum(a[0::2]) - a[-1])
    l1 = [-Max for i in range(n)]
    for i in range(n):
        if i != n-1:
            l1[i] = po[i+1]


    for i in range(n-1,-1,-1):
        if i == n-1:
            continue
        elif i == n-2:
            mi[i] = l1[i]
        else:
            mi[i] = max(mi[i+2]+a[i],l1[i])


    l1 = mi

        
    co = 0

    for i in range(0,n,2):
        if i + 2 <= n-1:
            ans = max(ans,co+l1[i+1],co+po[i+2])
        elif i+1 <= n-1:
            ans = max(ans,co+l1[i+1])
        else:
            ans = max(ans,co)
        
        co += a[i]
    co = 0
    for i in range(1,n,2):
        ans = max(ans,co+po[i+1])
        co += a[i]
    print(ans)









Measured memory_bytes: 140552
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define MOD 1000000007
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------

struct BIT
{
  vector<ll> bit;
  int M;
  BIT(int n){
    M = n;
    bit.resize(M+1);
    rep(i, bit.size()){bit[i]= 0;}
  }

  void add(int a, ll w) { // aを +w  aは 1-indexed
    for(int x=a; x<=M; x+= x& -x){
      bit[x] += w;
    }
  }

  ll sum(int a) { // [1,a] 1-indexed
    ll ret=0;
    for(int x=a; x>0; x-= x& -x){
      ret+= bit[x];
    }
    return ret;
  } // 左上のものをすべて足す
};

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    ll A[N];
    rep(i,N) cin>>A[i];
    ll geta=N+5;
    ll low = -1; // 一番小さい値より1つ前
    ll high = INF; // 一番でかい値より1つあと
    while (abs(high - low) > 1) {
        ll mid = (high + low) / 2;
        ll num=0;
        BIT bi(N*2+10);
        ll sum=0;
        bi.add(geta,1);
        rep(i,N){
            int val;
            if(A[i]<=mid) val=1; else val=-1;
            sum+=val;
            num+=bi.sum(sum+geta-1);
            bi.add(sum+geta, 1);
        }
        //db(num);
        ( num>(N+1)*N/4 ? high : low ) = mid;
        // medianがmid以下になる連続部分列の個数numが、全体の半分より大きいか
    }

    cout<< high <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

using namespace std;

int main(){
    int N; cin >> N;
    vector<long long> v;
    for (int i=0; i< N ; i++) {
        long long H; cin >> H;
        v.push_back(H);
    }
    
    int max = 0;
    int count = 0;
    for (int i=0; i< N-1; i++) {
        if (v.at(i) >= v.at(i+1)) {
            count++;
        }
        else {
            if (max < count) max = count;
            count=0;
        } 
    }
    if (max < count) max = count;

    cout << max << endl;
}

Measured memory_bytes: 1400
import numpy as np
limit = 10**5
def Eratosthenes(limit):
	is_prime = np.full(limit+1, True)
	is_prime[:2] = False
	for p in range(2,limit+1):
		if p**2 > limit:
			break
		if is_prime[p]:
			is_prime[p**2::p] = False

	return is_prime

is_prime = Eratosthenes(limit)

fullfill = np.zeros(limit+1,np.int32)

for p in range(limit+1):
	if p*2+1 > limit:
		break
	elif is_prime[p] and is_prime[2*p-1]:
		fullfill[2*p-1] = 1

ans = np.add.accumulate(fullfill)

Q = int(input())
A = []
for _ in range(Q):
	l,r = map(int, input().split())
	A.append(ans[r]-ans[l-1])

print(*A)

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

bool solve() {
    int C[3][3];
    for ( int i = 0; i < 3; i++ ) {
        for ( int j = 0; j < 3; j++ ) {
            cin >> C[i][j];
        }
    }
    for ( int j = 0; j < 2; j++ ) {
        int d = C[0][j+1] - C[0][j];
        for ( int i = 1; i < 3; i++ ) {
            if ( C[i][j+1] - C[i][j] != d ) return false;
        }
    }
    for ( int i = 0; i < 2; i++ ) {
        int d = C[i+1][0] - C[i][0];
        for ( int j = 1; j < 3; j++ ) {
            if ( C[i+1][j] - C[i][j] != d ) return false;
        }
    }
    return true;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, cnt = 1, ans = 0;
  scanf("%lld", &n);
  string s[n];
  for(i = 0; i < n; ++i) cin >> s[i];
  sort(s, s + n);
  for(i = 1; i < n; ++i) {
    if(s[i] == s[i - 1]) cnt++;
    else cnt = 1;
    if(cnt > ans) ans = cnt;
  }
  cnt = 1;
  if(ans == 1) for(i = 0; i < n; ++i) cout << s[i] << endl;
  else for(i = 1; i < n; ++i) {
    if(s[i] == s[i - 1]) {
      cnt++;
      if(cnt == ans) cout << s[i] << endl;
    } else cnt = 1;
  }
  return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main() {
	long long N,M;
	cin >> N >> M;
	vector<long long> h(2*N,0),v(N+1,0),t(M),s(M);
	long long i,j,k;
	for(i=0;i<N;i++) {
		cin >> j;
		v[i+1] = v[i] + j;
		cin >> j;
		if(i>0)h[2*i] = h[2*i-1]+abs(j-(h[2*i-1]-h[2*i-2]));
		h[2*i+1] = h[2*i] + j;
	}
	for(i=0;i<M;i++)cin >> t[i] >> s[i];
	vector<vector<long long>> dp(M+1,vector<long long>(N+1,-1));
	dp[0][0] = 0;
	long long l,r;
	bool f;
	vector<vector<pair<pair<long long,long long>,long long>>> a(2,vector<pair<pair<long long,long long>,long long>>(1,pair<pair<long long,long long>,long long>(pair<long long,long long>(h[2*N-1]-h[0],0),0)));
	vector<bool> ed(N);
	for(i=0;i<M;i++) {
		vector<pair<pair<long long,long long>,long long>>().swap(a[(i+1)%2]);
		sort(a[i%2].begin(),a[i%2].end(),greater<pair<pair<long long,long long>,long long>>());
		for(j=0;j<N;j++)ed[j] = false;
		for(j=0;j<a[i%2].size();j++)if(dp[i][a[i%2][j].first.second] == a[i%2][j].second) {
			if(dp[i][a[i%2][j].first.second] >= s[i] && dp[i+1][a[i%2][j].first.second] < dp[i][a[i%2][j].first.second]) {
				dp[i+1][a[i%2][j].first.second] = dp[i][a[i%2][j].first.second];
				a[(i+1)%2].push_back(pair<pair<long long,long long>,long long>(pair<long long,long long>(h[2*N-1]-h[2*a[i%2][j].first.second]+dp[i+1][a[i%2][j].first.second],a[i%2][j].first.second),dp[i+1][a[i%2][j].first.second]));
			}
			f = true;
			for(k=a[i%2][j].first.second+1;k<=N && f;k++) {
				if(ed[k])f = false;
				else if(t[i] < v[k])f = false;
				else {
					if(dp[i][a[i%2][j].first.second]+h[max(2*a[i%2][j].first.second,2*k-1)]-h[2*a[i%2][j].first.second] >= s[i]) {
						if(dp[i+1][k] < dp[i][a[i%2][j].first.second]+h[max(2*a[i%2][j].first.second,2*k-1)]-h[2*a[i%2][j].first.second]) {
							dp[i+1][k] = dp[i][a[i%2][j].first.second]+h[max(2*a[i%2][j].first.second,2*k-1)]-h[2*a[i%2][j].first.second];
							a[(i+1)%2].push_back(pair<pair<long long,long long>,long long>(pair<long long,long long>(h[2*N-1]-h[2*k]+dp[i+1][k],k),dp[i+1][k]));
						}
					}
					ed[k] = true;
				}
			}
		}
	}
	long long ans = -1;
	for(i=0;i<=N;i++) {
		if(dp[M][i] != -1)ans = max(ans,t[M-1]-v[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 26764
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  string s;
  cin >> n >> k >> s;
  k--;
  for ( int i = 0; i < n; i++ ) {
    if ( i == k ) cout << (char)tolower(s[i]);
    else cout << s[i];
  } 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <map>
#include <vector>
#include <string>
#define int long long
signed main()
{
	int n,m;
	map<int,int> mp;
	cin>>n>>m;
	vector<int> v(n+1);
	for(int i=0;i<m;i++)
	{
		int x;
		string y;
		cin>>x>>y;
		if(v[x]==0)
		{
			if(y=="WA")
				mp[x]++;
			else
				v[x]=1;
		}
	}

	int count=0,sum=0;
	for(int i=1;i<=n;i++)
	{
		if(v[i]==1)
		{
			count++;
			sum+=mp[i];
		}
	}

	cout<<count<<" "<<sum<<endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> e(n+1);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<int> fen(n+1, INF), sun(n+1, INF);
  fen[1] = 0;
  fen[n] = INF-1;
  sun[n] = 0;
  sun[1] = INF-1;
  queue<int> q;
  auto update = [&](int now, vector<int> &vec) {
    for(auto next : e[now]) {
      //cout << "now" << now << "next" << next << endl;
      if(vec[next] == INF) {
        vec[next] = vec[now]+1;
        q.push(next);
      }
    }
  };

  q.push(1);
  while(!q.empty()) {
    int now = q.front(); q.pop();
    update(now, fen);
  }
  q.push(n);
  while(!q.empty()) {
    int now = q.front(); q.pop();
    update(now, sun);
  }
  int f=0,s=0;
  for(int i = 1; i <= n; ++i) {
    if(fen[i] <= sun[i]) ++f;
    else ++s;
  }
  if(f > s) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}

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

#define MAX 10000

int main(void){
  int n,data[MAX+1],des[2],num,max,mnum;

  for(;;){

    max = mnum = 0;

    for( int i = 0 ; i <= MAX ; i++ )
	data[i] = 0;

    cin >> n;
    if( n == 0 ) break;
    for( int i = 0 ; i < n ; i++ ){
      cin >> num >> des[1] >> des[0];
      data[num] = des[0] + des[1];

      if( data[num] > max ){
	max = data[num];
	mnum = num;
      }

    }

    cout << mnum << " " << max << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
N = int(input())
a = list(map(int,input().split()))

num=0

j=0

for i in range(1,N+1):
    while(j<N):
        if a[j]==i:
            num+=1
            j+=1
            break
        j+=1

    if j==N:
        break

if num==0:
    ans=-1
else:
    ans=N-num
print(ans)
    

Measured memory_bytes: 77516
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a) <= d || (abs(b-a) <=d &&(c-b) <=d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

//??°?????????lowlink???????????????????????¢????????¨??????????????????
//?¨??????? O(|V|+|E|)
void lowlink(vector<int>graph[], int n, vector<int>&low, vector<pair<int, int>>&br, vector<int>&jnt) {
	low.resize(n);
	vector<int>ord(n);//DFS?????????
	vector<bool>vis(n);//?¨???????????????????
	//?????°????????????
	function<void(int, int, int&)>dfs = [&](int v, int p, int &k) {
		vis[v] = true;
		ord[v] = k++;
		low[v] = ord[v];
		bool joint = false;
		int cnt = 0;
		for (auto nxt : graph[v]) {
			if (!vis[nxt]) {
				cnt++;
				dfs(nxt, v, k);
				low[v] = min(low[v], low[nxt]);
				if (p >= 0 && ord[v] <= low[nxt]) joint = true;
				if (ord[v] < low[nxt])br.push_back({ min(v,nxt),max(v,nxt) });
			}
			else if (nxt != p) {
				low[v] = min(low[v], ord[nxt]);
			}
		}
		if (p < 0 && cnt > 1) joint = true;
		if (joint) jnt.push_back(v);
	};
	int k = 0;
	for (int i = 0; i < n; ++i)
		if (!vis[i])dfs(i, -1, k);
}

int N, M;
vector<int>graph[123456];

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int s, t;
		cin >> s >> t;
		graph[s].push_back(t);
		graph[t].push_back(s);
	}
	vector<int>low, jnt;
	vector<pair<int, int>>br;
	lowlink(graph, N, low, br, jnt);
	sort(jnt.begin(), jnt.end());
	for (int i : jnt) {
		cout << i << endl;
	}
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    int ans=0;
    FOR(i,1,k+1){
        FOR(j, 1, k + 1)
        {
            int ab = gcd(i, j);
            FOR(j, 1, k + 1)
            {
                int abc = gcd(ab, j);
                ans += abc;
            }
        }
    }
    
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,k,ans,inv,add;
int a[2005];
int b[2005],c[2005];

int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			if(a[j]>a[i]) b[i]++; 
		}
		for(int j=1;j<=n;j++){
			if(a[j]>a[i]) c[i]++;
		}
	}
	inv=(mod+1)/2;
	for(int i=1;i<=n;i++){
		add=1ll*k*(k-1)%mod;
		add=1ll*add*inv%mod;
		add=1ll*add*c[i]%mod;
		add=(add+1ll*k*b[i]%mod)%mod;
		ans+=add,ans%=mod;
	}
	printf("%d\n",ans);
	
	return 0;
}

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

using namespace std;

typedef long long int ll;
#define f first
#define s second
#define Mp make_pair
#define pb push_back
#define Lb lower_bound
#define Ub upper_bound
#define all(x) x.begin(), x.end()
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

const int Maxn = 100000+5, N = 100+5, Mod = 1000*1000*1000 + 7, inf = 1000*1000*1000;
int n, h[Maxn], dp[Maxn];
int main(){
    fast_io
    cin >> n;
    for (int i = 0; i < n; i++) cin >> h[i];
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
/*
 * I'm strong. Stronger than all of you. Extremely strong.
 * I can kill all those Titans there. Even if I'm alone.
 * You're either incompetent or you're spineless cowards.
 * How pathetic.
 * You can sit here and suck on your fingers. Yeah, do that.
 * ~ Mikasa Ackerman
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  int k;
  cin >> k;
  VI x(k);
  for (int i = k - 1; i >= 0; i--)
    cin >> x[i];
  LL cmin = 2, cmax = 2;
  LL nextmin, nextmax;
  for (auto v : x) {
    if (((cmax / v) - (cmin - 1) / v) > 0)
      ;
    else {
      cout << -1 << endl;
      return 0;
    }
    if (cmin % v == 0)
      nextmin = cmin;
    else
      nextmin = cmin + v - (cmin % v);
    nextmax = cmax - (cmax % v) + v - 1;
    cmin = nextmin;
    cmax = nextmax;
  }
  cout << nextmin << " " << nextmax << endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
const int N=55;
long long dp[N][N*N];
int n,a,x[N];
int main()
{
    scanf("%d %d",&n,&a);
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x[i]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=n;j>=1;j--)
        {
            for(int k=N*j;k>=x[i];k--)
            {
                    dp[j][k]=dp[j][k]+dp[j-1][k-x[i]];
            }
        }
    }
    long long sum=0;
    for(int i=1;i<=n;i++)
        sum+=dp[i][a*i];
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

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

double a, b, x, ans;
bool KK[101];

int main() {

	cin >> a >> b >> x;
	ans = 0.00000;
	
	if (a * b / 2 * a <= x)//あまり傾けられない
	{
		ans = (a*a*b - x) / (a*a*a/2);
		ans = atan(ans);	
	}
	else
	{
		ans = atan(a*b*b/2 / x);
	}

	//double M_PI = 3.14159265;

	ans = ans / M_PI * 180.00000;

	printf("%.10f\n", ans);
	
}

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


#define int                long long int
#define jaldichal          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                 push_back
#define mk                 make_pair
#define R                  return
#define C                  continue
#define line               "\n"
#define space              " "
#define sizee(v)           ((int)((v).size()))
#define arrsize            200005
#define odd(x)             ((int)(x&1))
#define fi                 first
#define se                 second
#define all(x)             x.begin(),x.end()
#define w(x)               int x;cin>>x;for(int i=1;i<=x;i++)

#define vi                 vector<int>
#define vii                vector<pair < int , int > > 
#define setbits(x)         __builtin_popcountll(x)
#define pii                pair<int, int>
int n,m;

void solve()
{
  vi v;
  cin>>n;
  v.reserve(n+1);
  for(int i=1;i<=n;i++)
    cin>>v[i];
  vi cost(n+1,0);
  cost[1]=0;
  cost[2]=abs(v[2]-v[1]);

  for(int i=3;i<=n;i++)
  {
    cost[i] +=  min( cost[i-1] + abs(v[i] - v[i-1]) , cost[i-2] + abs(v[i] - v[i-2]));
  }
  cout<<cost[n]<<line;

}
signed main()
{    
    jaldichal
    solve();



return 0;
}

Measured memory_bytes: 4776
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut l: Vec<usize> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();

    l.sort();

    let mut count = 0;
    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            let a = l[i];
            let b = l[j];

            if !can_triangle(a, b, l[j + 1]) {
                continue;
            }

            if can_triangle(a, b, l[n - 1]) {
                count += n - 1 - j;
                continue;
            }

            let mut left = j + 1;
            let mut right = n - 1;
            while left + 1 < right {
                let mid = (right + left) / 2;
                if can_triangle(a, b, l[mid]) {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            count += left - j;
        }
    }
    return count.to_string();
}

fn can_triangle(a: usize, b: usize, c: usize) -> bool {
    return a < b + c && b < c + a && c < a + b;
}


Measured memory_bytes: 4352
using System;
using System.Linq;

public class Hello{
    public static void Main(){
        var n = Int32.Parse(Console.ReadLine());

        var ret = 0;
        for(var i = 0; i < n; ++i){
            var r = Console.ReadLine().Split(' ').Select(s => Int32.Parse(s)).ToList();
            ret += r[1] + 1 - r[0];
        }
        Console.WriteLine(ret);
    }
}



Measured memory_bytes: 11220
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var q = sc.nextInt();
		var q1 = new int[q];
		var q2 = new int[q];
		for (var i = 0; i < q; i++) {
			q1[i] = sc.nextInt();
			q2[i] = sc.nextInt();
		}
		sc.close();

		var sum = (long) (n - 2) * (n - 2);
		var x = new HashMap<Integer, Integer>();
		var y = new HashMap<Integer, Integer>();
		var x2 = new Main().new SortedList();
		var y2 = new Main().new SortedList();
		x.put(n, n);
		y.put(n, n);
		x2.add(n);
		y2.add(n);
		for (var i = 0; i < q; i++) {
			var qt = q1[i];
			var qv = q2[i];
			if (qt == 1) {
				var v = search(x, x2, qv, n);
				sum -= v - 2;
				update(y, y2, v, qv);
			} else {
				var v = search(y, y2, qv, n);
				sum -= v - 2;
				update(x, x2, v, qv);
			}
		}
		System.out.println(sum);
	}

	private static int search(HashMap<Integer, Integer> map, SortedList list, int key, int n) {
		var mapKey = list.searchValue(key);
		var result = map.get(mapKey);
		return result;
	}

	private static void update(HashMap<Integer, Integer> map, SortedList list, int key, int value) {
		if (map.containsKey(key)) {
			map.put(key, Math.min(map.get(key), value));
			list.add(key);
		} else {
			map.put(key, value);
			list.add(key);
		}
	}

	public class SortedList {
		List<Integer> list;

		public SortedList() {
			this.list = new ArrayList<Integer>();
		}

		public SortedList(List<Integer> list) {
			this.list = list;
		}

		public int get(int index) {
			return list.get(index);
		}

		public void add(int value) {
			list.add(search(value), value);
		}

		public int remove(int index) {
			return list.remove(index);
		}

		public int searchValue(int value) {
			return list.get(search(value));
		}

		private int search(int value) {
			var min = 0;
			var max = list.size();
			while (max - min > 1) {
				var mid = min + (max - min) / 2;
				if (list.get(mid) <= value) {
					min = mid;
				} else {
					max = mid;
				}
			}

			if (max - min == 1 && list.get(min) <= value) {
				min++;
			}
			return min;
		}
	}
}


Measured memory_bytes: 70068
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <stdio.h>
using namespace std;


int main(void){
    string s;
    cin >> s;
    bool isBad=false;

    for(int i = 1;i < 4;i++)
    {
        if(s[i]==s[i-1])
        {
            isBad=true;
        }
    }

    if(isBad)
    {
        cout << "Bad"<<endl;
    }else
    {
        cout << "Good"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256