akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] values = new int[N+1];
        for (int i=1; i<=N; i++) {
            values[i] = sc.nextInt();
        }
        int min = 0;
        int Max = 0;
      
      for (int i=1; i<=N; i++) {
        if (min == 0 || values[i] < min) {
          min = values[i];
        }  
        
        if (Max == 0 || Max < values[i]) {
          Max = values[i];
        }  

      }
            
           
        System.out.println(Max - min);
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N,K;
int W[111111],D[111111];

bool C(int x){
    int cnt=0;
    rep(i,N){
        if(W[i]>x)continue;
        cnt+=(x-W[i])/D[i]+1;
        if(cnt>=K)return true;
    }
    return false;
}

signed main(){
    cin>>N>>K;
    rep(i,N)cin>>W[i]>>D[i];

    int lb=0,ub=2000000000000000010ll;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(C(mid))ub=mid;
        else lb=mid;
    }

    cout<<ub<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        long ans = 1;
        long d = 0;
        for (int i = 0; i < n; i++) {
            d += l[i];
            if (d > x) {
                break;
            }
            ans++;
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 24660
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0

for k_a in range(A+1):
    for k_b in range(B+1):
        for k_c in range(C+1):
            if 500*k_a+100*k_b+50*k_c == X:
                count=count+1
print(count)


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int a, b, x;
  std::cin >> a >> b >> x;
  if ((a + b) >= x && x >= a)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    ll a,b,c,d,p;
    cin >> a >> b >> c >> d;
    if(a<=0&&c<=0){
        if(b<=0||d<=0){
            p = a*c;
        }
        else{
            p = max(a*c,b*d);
        }
    }
    else if(a>=0&&d<=0){
        p = a*d;
    }
    else if(b<=0&&c>=0){
        p = b*c;
    }
    else{
        p = b*d;
    }
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

struct Word
{
	char s[15];
	int count;
};

int n;
Word s[200020];

bool compare(const Word &a, const Word &b) {
	if (strcmp(a.s, b.s) < 0) {
		return true;
	}
	return false;
}



bool compareB(const Word &a, const Word &b) {
	if (a.count == b.count) {
		if ((strcmp(a.s, b.s) < 0))
			return true;
		return false;
	} else {
		return a.count > b.count;
	}
}



int main()
{
	scanf("%d\n", &n);
	for (int i = 0 ; i < n ; i++) {
		scanf("%s\n", s[i].s);		
	}

		
	sort(s, s + n, compare);
	
	char curS[110];
	std::vector<Word> maxS;
	Word newS;
	strcpy(newS.s, s[0].s);
	strcpy(curS, s[0].s);
	newS.count = 1;
	
	for (int i = 1 ; i < n ; i++) {
		if (strcmp(curS, s[i].s) == 0) {
			newS.count++;
		} else {
			maxS.push_back(newS);
			strcpy(newS.s, s[i].s);
			newS.count = 1;
			
			strcpy(curS, s[i].s);
		}
	}
	
	maxS.push_back(newS);
	sort(maxS.begin(), maxS.end(), compareB);
	int curMax = maxS[0].count;
	for (int i = 0 ; i < maxS.size() ; i++) {
		if (maxS[i].count == curMax) {
			printf("%s\n", maxS[i].s);
		} else {
			break;
		}
	}
		
		
	return 0;
}

Measured memory_bytes: 10736
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = LI()
print(x.index(0)+1)

Measured memory_bytes: 65260
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define MAX 100005
ll prime[MAX],k=0;
void bfs()
{
    queue<ll>q;
    ll i,j;
    q.push(1LL);
    q.push(2LL);q.push(3LL);q.push(4LL);q.push(5LL);q.push(6LL);q.push(7LL);q.push(8LL);q.push(9LL);
    while(1)
    {
        j=q.front();
        q.pop();
        string s;
        stringstream ss;
        ss<<j;
        ss>>s;
        for(char c='0';c<='9';c++)
        {
            if(abs((ll)s[s.size()-1]-(ll)c)<=1)
            {
                s.pb(c);
                stringstream ss1;
                ss1<<s;
                ss1>>j;
                prime[k++]=j;
                q.push(j);
                s.pop_back();
                if(k==MAX-3LL)return ;
            }
        }
    }
}
int main()
{
    prime[k++]=1;
    prime[k++]=2;
    prime[k++]=3;
    prime[k++]=4;
    prime[k++]=5;
    prime[k++]=6;
    prime[k++]=7;
    prime[k++]=8;
    prime[k++]=9;
    bfs();
    ll n;
    in(n);
    cout<<prime[n-1];endl;
}


Measured memory_bytes: 1536
#include  "stdio.h"

char trip[1001];
int i = 0;
int ans = 0;

int main() {

	for (i = 0; i < 1001; i++) {
		trip[i] = 0;
	}

	scanf("%s", trip);
	for (i = 0; i < 1001; i++) {
		if (trip[i] == 'N'&&ans % 2 == 0) {
			ans++;
		}
		else if (trip[i] == 'S'&&ans % 4 < 2) {
			ans+=2;
		}
		else if (trip[i] == 'W'&&ans % 8 < 4) {
			ans+=4;
		}
		else if (trip[i] == 'E'&&ans % 16 < 8) {
			ans+=8;
		}

	}
	if (ans == 15 || ans ==3 || ans ==12) {
		printf("Yes");
	}
	else printf("No");
		return 0;

}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	vector<int> L(N), R(N);
	for (int i = 1; i < N; ++i) {
		L[i] = max(L[i - 1], A[i - 1]);
	}
	for (int i = N - 2; i >= 0; --i) {
		R[i] = max(R[i + 1], A[i + 1]);
	}
	cout << R.front() << endl;
	for (int i = 1; i < N - 1; ++i) {
		cout << max(L[i], R[i]) << endl;
	}
	cout << L.back() << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::vector<P> G[100100];
int coloring[100100];
int D;

void dfs(int v, int p, int pc){
    int c = 1;

    for(auto &pa : G[v]){
        int w, i;
        std::tie(w, i) = pa;

        if(w == p){continue;}

        if(c == pc){c += 1;}

        coloring[i] = c;

        dfs(w, v, c);

        c += 1;
    }
}

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

  std::cin >> N;

  for(int i=0;i<N-1;++i){
      int A, B;
      std::cin >> A >> B;

      G[A].emplace_back(B, i);
      G[B].emplace_back(A, i);
  }

  for(int i=1;i<=N;++i){
      D = std::max<int>(D, G[i].size());
  }

  dfs(1, -1, -1);

  std::cout << D << std::endl;

  for(int i=0;i<N-1;++i){
      std::cout << coloring[i] << std::endl;
  }
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

int kosu[5];

int main() {
    int n;
    cin >> n;
    string s;
    REP(i, n) {
        cin >> s;
        if(s[0] == 'M') kosu[0]++;
        else if(s[0] == 'A') kosu[1]++;
        else if(s[0] == 'R') kosu[2]++;
        else if(s[0] == 'C') kosu[3]++;
        else if(s[0] == 'H') kosu[4]++;
    }
    ll ans = 0;


    REP(i, 2) REP(j, 2) REP(k, 2) REP(l, 2) REP(m, 2) {
        ll tmp = 1;
        if(i+j+k+l+m == 3) {
            if(i) {
                tmp *= kosu[0];
            }
            if(j) {
                tmp *= kosu[1];
            }
            if(k) {
                tmp *= kosu[2];
            }
            if(l) {
                tmp *= kosu[3];
            }
            if(m) {
                tmp *= kosu[4];
            }
            ans += tmp;
        }
    }

    cout << ans << endl;

    return 0;
}
 

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        
        int min = a[0];
        int max = a[0];
        long sum = a[0];
        
        for (int i = 1; i < n; i++) {
            min = Math.min(min, a[i]);
            max = Math.max(max, a[i]);
            sum += a[i];
        }
        
        System.out.println(min + " " + max + " " + sum);
    }

}


Measured memory_bytes: 43068
#include<iostream>
using namespace std;
int main()
{
  int H,N,a,i,s=0;
  cin>>H>>N;
  for(i=0;i<N;i++)
  {
    cin>>a;
    s+=a;
  }
  if(s==H||s>H)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}
    

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

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll h, w;
ll dp[1111][1111];
char a[1111][1111];

int main(){
    cin >> h >> w;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }

    dp[1][1] = 1;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(a[i + 1][j] == '.')
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
            if(a[i][j + 1] == '.')
                dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
        }
    }

    cout << dp[h][w] << '\n';

    return 0;
}

/*
3
10 40 70
20 50 80
30 60 90

10  40  70
90  120 120
150 180 210
*/


















Measured memory_bytes: 10368
#include<iostream>
#include<bitset>

using namespace std;

typedef long long ll;

int N, A[2010];

bitset<(2010 * 2010)> dp;

int main() {
	cin >> N;
	ll Sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i]; 
		Sum += A[i];
	}
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		dp |= (dp << A[i]);
	}
	
	for (ll ans = ((Sum + 1) / 2); ans <= 2000 * 2000; ans++) {
		if (dp[ans]) {
			cout << ans << endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    ll N;
    cin >> N;
    vll X(N);
    cin >> X;
    vll Y(X);
    sort(Y.begin(), Y.end());
    ll a;
    for (int i = 0; i < N; ++i) {
        a = X[i];
        ll pos = lower_bound(Y.begin(), Y.end(), a) - Y.begin();
        if (pos < (N >> 1)) {
            cout << Y[N >> 1] << endl;
        } else {
            cout << Y[(N - 1) >> 1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <climits>
#include  <vector>
#define ll long long
#define REP(a,b) for(int a=0; a<b; a++)
using namespace std;
#define abc aa

vector <ll> rope;

int main() {
  ios_base::sync_with_stdio(false);
  int N, L;
  cin >> N >> L;
  REP(i, N){
    ll temp;
    cin >> temp;
    rope.push_back(temp);
  }
  bool possible = false;
  int last = INT_MAX;
  REP(i, N-1){
    if(rope[i]+rope[i+1] >= L){
      possible = true;
      last = i;
    }
  }
  if(possible){
    cout << "Possible" << endl;
    REP(i, last){
      cout << i+1 << endl;
    }
    for(int i = N-2; i >= last; i--){
      cout << i+1 << endl;
    }
  }else{
    cout << "Impossible" << endl;
  }
}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class T>
inline void out(T a) {
	cout<<a<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int A,B,C,K;

void input() {
	cin>>A>>B>>C>>K;
}

void solve() {
	while(A>=B) {
		B*=2;
		K--;
	}
	while(B>=C) {
		C*=2;
		K--;
	}
	if(K<0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,k,t,i, x[522];
    cin>>a>>b>>k;
    t=b-a+1;
    if(t%2!=0)
        t++;
    t=t/2;
    if(k>=t)
    {
        for(i=a;i<=b;i++)
            cout<<i<<endl;
    }
    else
    {
        for(i=1;i<=k;i++)
        {
            cout<<a<<endl;
            a++;
        }
        for(i=1;i<=k;i++)
        {
            x[i]=b;
            b--;
        }
        for(i=k;i>=1;i--)
        {
            cout<<x[i]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int n, k;
string s;

vector<int> v;

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

        cin >> n >> k >> s;

        int i=0,j=0;
        while (i<n) {
                v.push_back(i);

                j = i;
                while (s[i] == s[j] && j<n)
                        j++;
                i = j;
        }
        v.push_back(n);

        REP(z,v.size())
                debug(v[z]);

        int m = 0;
        REP(z, v.size()) {
                int idx = v[z];
                if(s[idx] == '0') {
                        m = max(m, v[min(z+2*k, (int)v.size()-1)]-v[z]);
                }else{
                        m = max(m, v[min(z+2*k+1, (int)v.size()-1)]-v[z]);
                }
        }
        cout << m <<endl;

        return 0;
}


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

int n,r;

int main(){
	cin>>n>>r;
	if (n>=10) cout<<r;
	else {
		cout<<r+100*(10-n);
	}
	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 long long ll;
using P = pair<int,int>;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    string ans;

    if (a == b && b != c) {
        ans = "Yes";
    } else if(a == c && c != b) {
        ans = "Yes";
    } else if(b == c && b != a) {
        ans = "Yes";
    } else {
        ans = "No";
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        static long mod = 1_000_000_000 + 7;

        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            long n = in.nextInt();
            long a = in.nextInt();
            long b = in.nextInt();

            long ans = power(2, n, mod) - 1;
            ans -= C(n, a, mod);
            ans -= C(n, b, mod);

            while (ans < 0)
            {
                ans += mod;
            }

            out.print(ans);
        }

        static long power(long a, long n, long m)
        {
            long ret = 1;
            for (; n > 0; n >>= 1, a = a * a % m)
            {
                if (n % 2 == 1)
                {
                    ret = ret * a % m;
                }
            }
            return ret;
        }

        static long C(long N, long K, long mod)
        {
            long x = 1, y = 1;
            for (int i = 1; i <= K; i++)
            {
                x = x * (N - i + 1) % mod;
                y = y * i % mod;
            }
            return x * power(y, mod - 2, mod) % mod;
        }

    }
}



Measured memory_bytes: 21844
object Main extends App{
    def f(n: Int): Unit = {
        g(n, 1)
        if (n == 9) {
            return
        } else {
            f(n + 1)
        }
    }

    def g(i: Int, j: Int): Unit = {
        println(i + "x" + j + "=" + i * j)
        if (j == 9) {
            return
        } else {
            g(i, j + 1)
        }
    }

    f(1)
}

Measured memory_bytes: 43656
n,k = map(int, input().split())
a = list(map(int, input().split()))

sums = []
for i in range(n):
    b = a[i]
    sums.append(b)
    for j in range(i+1,n):
        b+=a[j]
        sums.append(b)
sums.sort()
b = [format(x,'040b') for x in sums]

for i in range(40):
    one = []
    for j in range(len(b)):
        if b[j][i]=='1':
            one.append(b[j])
    if len(one)>=k:
        b = []+one

ans = int(b[0],2)
for i in range(1,len(b)):
    ans = ans&int(b[i],2)
print(ans)

Measured memory_bytes: 144360
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a, b;

int main()
{
	string ans = "No";
	string s;
	cin >> s;
	if (s[2] == s[3]) {
		if (s[4] == s[5]) {
			ans = "Yes";
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
inline void rd(int &x)
{
	int f=1;char c=getchar();x=0;
	while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=x*10+c-48;c=getchar();}x*=f;
}
int main()
{
	int n,m,ans=0,a[2000];
	rd(n);rd(m);
	for(int i=1;i<=n;i++) rd(a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(i==n&&m!=a[i]) break;
		if(m>=a[i]) {m-=a[i];ans++;}
	}
	printf("%d",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, L;
  cin>>N>>L;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  int index = -1;
  for(int i=0;i<N-1;++i) {
    if(A[i]+A[i+1]>=L) index = i+1;
  }
  if(index==-1) {
    cout<<"Impossible"<<endl;
    return 0;
  }
  cout<<"Possible"<<endl;
  for(int i=1;i<index;++i) cout<<i<<endl;
  for(int i=N-1;i>=index;--i) cout<<i<<endl;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct station { 
  ll l, r, d; 
  bool operator< ( const station &x ) const { return d<x.d; };
};

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

struct SegTree {
  int size;
  vector<ll> pos;
  SegTree(ll N) { size = 1; while(size<N) size<<=1; pos.resize(2*size,0); }
  ll operator[](const ll &x) const { return pos[x+size]; }

  void build() { per(i,size) operate(i); }
  void set(ll x, const ll v) { pos[x+size] = v; }
  void update(ll x, const ll v) { set(x,v); x+=size; while (x>>=1) operate(x); }
  ll query(ll a, ll b) {
    ll L = 0, R = 0;
    for (a+=size, b+=size; a<b; a>>=1, b>>=1) {
      if (a&1) { L = q(L,pos[a]); a++; }
      if (b&1) { b--; R = q(R,pos[b]); }
    }
    return q(L,R);
  }
  void operate(ll i) { pos[i] = pos[i*2] + pos[i*2+1]; }
  ll q(ll x, ll y) { return x + y; }
};

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

int main() {
  int N, M; cin >> N >> M;
  station s[N]; rep(i,N) { cin >> s[i].l >> s[i].r; s[i].d = s[i].r-s[i].l+1; }
  sort(s,s+N);
  // rep(i,N) cout << s[i].l << "~" << s[i].r << endl;

  SegTree st(M+2);

  ll pos = 0;
  repr(i,1,M+1) {
    while (pos!=N&&s[pos].d==i) {
      st.update(s[pos].l, st[s[pos].l]+1);
      st.update(s[pos].r+1, st[s[pos].r+1]-1);
      pos++;
    }
    // cout << i << "->" << pos << " ";
    ll result = N-pos;
    for (ll j=i; j<=M; j+=i) result += st.query(0,j+1);
    cout << result << endl;
    // rep(j,M+1) cout << st[j] << " "; cout << endl;
  }
  return 0;
}

Measured memory_bytes: 9984
str_to_int = lambda value: int(value)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

answer = 0
previous = -1
for Ai in A:
    delicious = B[Ai - 1]

    has_bonus = Ai - previous is 1
    bonus = C[previous - 1] if has_bonus  else 0

    answer += (delicious + bonus)

    previous = Ai

print(answer)


Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

    static void exec(MyScanner in, PrintWriter out) {
        /* int n = */in.nextInt();
        String s = in.next();
        int k = in.nextInt() - 1;
        out.println(s.replaceAll("[^" + s.substring(k, k + 1) + "]", "*"));
    }

    public static void main(String[] args) {
        PrintWriter w = new PrintWriter(System.out);
        exec(new MyScanner(System.in), w);
        w.flush();
    }

    static final class MyScanner {
        static final int BUFFER_SIZE = 8192;
        private final InputStream in;
        private final byte[] buffer = new byte[BUFFER_SIZE];
        private int point;
        private int readLength;
        MyScanner(InputStream in) {
            this.in = in;
        }
        private int readByte() {
            if (point < readLength) {
                int result = buffer[point];
                point += 1;
                return result;
            }
            try {
                readLength = in.read(buffer);
            } catch (IOException e) {
                throw new AssertionError(null, e);
            }
            if (readLength == -1) {
                return -1;
            }
            point = 1;
            return buffer[0];
        }
        private static boolean isPrintableCharExceptSpace(int c) {
            return 33 <= c && c <= 126;
        }
        String next() {
            StringBuilder b = new StringBuilder();
            int c = readByte();
            while (!(c == -1 || isPrintableCharExceptSpace(c))) {
                c = readByte();
            }
            if (c == -1) {
                throw new NoSuchElementException();
            }
            do {
                b.appendCodePoint(c);
                c = readByte();
            } while (c != -1 && isPrintableCharExceptSpace(c));
            return b.toString();
        }
        long nextLong() {
            int c = readByte();
            while (!(c == -1 || isPrintableCharExceptSpace(c))) {
                c = readByte();
            }
            if (c == -1) {
                throw new NoSuchElementException();
            }
            boolean minus = false;
            if (c == '-') {
                minus = true;
                c = readByte();
            }
            long result = 0L;
            do {
                if (!('0' <= c && c <= '9')) {
                    throw new InputMismatchException();
                }
                result = result * 10L + (c - '0');
                c = readByte();
            } while (c != -1 && isPrintableCharExceptSpace(c));
            return minus ? -result : result;
        }
        int nextInt() {
            long n = nextLong();
            if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
                return (int) n;
            }
            throw new InputMismatchException();
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21204
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn doit(adj: Vec<Vec<(usize, i64)>>, s: usize) -> Vec<i64> {
    let n = adj.len();
    let mut pot: Vec<i64> = vec![std::i64::MAX; n];
    let mut heap = std::collections::BinaryHeap::new();

    pot[s] = 0;
    heap.push((0, s));

    while let Some((negp, v)) = heap.pop() {
        let p = -negp;
        if p > pot[v] {
            continue;
        }
        // println!("{} {}", p, v);

        for &(tv, d) in adj[v].iter() {
            let tp = p + d;
            if tp < pot[tv] {
                pot[tv] = tp;
                heap.push((-tp, tv));
            }
        }
    }

    return pot;
}


fn main() {
    let n: usize = read();
    let m: usize = read();
    let s: usize = read::<usize>() - 1;
    let t: usize = read::<usize>() - 1;

    let mut adj: Vec<Vec<(usize, i64, i64)>> = vec![vec![]; n];

    for _ in 0..m {
        let u: usize = read::<usize>() - 1;
        let v: usize = read::<usize>() - 1;
        let a: i64 = read();
        let b: i64 = read();
        adj[u].push((v, a, b));
        adj[v].push((u, a, b));
    }

    let fwd = doit(
        adj.iter().map({|a|
            a.iter().map({|&(v, a, b)| (v, a)}).collect()
        }).collect(),
        s
    );
    let bwd = doit(
        adj.iter().map({|a|
            a.iter().map({|&(v, a, b)| (v, b)}).collect()
        }).collect(),
        t
    );

    let mut t: i64 = std::i64::MAX;
    let mut ans = vec![0; n];
    for i in (0..n).rev() {
        t = std::cmp::min(t, fwd[i] + bwd[i]);
        ans[i] = t;
    }
    for i in 0..n {
        println!("{}", 1_000_000_000_000_000 - ans[i]);
    }
}


Measured memory_bytes: 28924
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a, b;
    cin >>a >>b;
    int ans = a - (2 * b);
    if(ans >= 0)
        cout <<ans;
    else 
        cout <<0;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused)]

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//入力マクロここまで

const INI: u64 = 0;

use std::cmp::*;

fn main() {
    input! {
        n: usize,
        abc: [(u64, u64, u64);n],
    }

    let mut dp: Vec<Vec<u64>> = vec![vec![INI; 3]; n];

    dp[0][0] = abc[0].0;
    dp[0][1] = abc[0].1;
    dp[0][2] = abc[0].2;

    for i in 1..n {
        dp[i][0] = max(dp[i - 1][1] + abc[i].0, dp[i - 1][2] + abc[i].0);
        dp[i][1] = max(dp[i - 1][0] + abc[i].1, dp[i - 1][2] + abc[i].1);
        dp[i][2] = max(dp[i - 1][0] + abc[i].2, dp[i - 1][1] + abc[i].2);
    }

    dp[n - 1].sort();

    println!("{}", dp[n - 1][2]);
}


Measured memory_bytes: 14588
n = int(input())
s = []
for i in range(n):
    s.append(input())
print("AC x {}".format(s.count("AC")))
print("WA x {}".format(s.count("WA")))
print("TLE x {}".format(s.count("TLE")))
print("RE x {}".format(s.count("RE")))


Measured memory_bytes: 16296
#include<stdio.h>

int main(){
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  if(a==7&&b==5&&c==5) printf("YES\n");
  else if(a==5&&b==7&&c==5) printf("YES\n");
  else if(a==5&&b==5&&c==7) printf("YES\n");
  else printf("NO\n");
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <string>
#include <cstdlib> //絶対値利用のため
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

//const int INF = INT_MAX / 2;



int main() {
	string S;
	cin >> S;
	int counter = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == '1') counter++;
	}
	int s = S.length();

	cout << s - abs(counter-(s - counter)) << endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long LL;
using namespace std;
struct node{
	int x,y;
}a[105];
int cmp(node z,node k){
	return z.x < k.x;
}
int main(){
	int n;
	while(~scanf("%d",&n)){
		memset(a,0,sizeof(a));
		int j = 0;
		for(int i = 1;i <= n;i++){
			a[i].y = i;
			a[i].x = 0;
			j = i;
			while(j % 2 == 0){
				j = j / 2;
				a[i].x++;
			}	
		}
		sort(a + 1,a + 1 + n,cmp);
		printf("%d\n",a[n].y);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int x, y, c = 0;
    cin >> x >> y;
    int a[x];
    for (int i = 0; i < x; i++)
    {
        cin >> a[i];
    }

    sort(a, a + x);
    for (int i = 0; i < y; i++)
    {
        c = c + a[i];
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;

signed main(){
  string N;
  cin >> N;
  
  int ans = N.at(0) - '0';
  ans--;
  if( N.size() > 1 ) ans += 9*(N.size()-1);
  
  int ans2 = 0;
  for( int i = 0; i < N.size(); i++ ){
    ans2 += N.at(i) - '0';
  }
  
  cout << max(ans, ans2) << endl;
  
  
}

Measured memory_bytes: 256
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

int main()
{
    IOS;//ifstream fin("input.txt");ofstream fout("output.txt");
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll dp[n][n][2];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        {
            dp[i][j][0]=0;
            dp[i][j][1]=LL_INF;
        }
    for(int i=0;i<n;i++)
    {
        dp[i][i][0]=a[i];
        dp[i][i][1]=-a[i];
    }
    int j;
    for(int l=2;l<=n;l++)
    {
        for(int i=0;i<=(n-l);i++)
        {
            j=i+l-1;
            dp[i][j][0]=max(a[i]+dp[i+1][j][1],a[j]+dp[i][j-1][1]);
            dp[i][j][1]=min(dp[i+1][j][0]-a[i],dp[i][j-1][0]-a[j]);
        }
    }
    cout<<dp[0][n-1][0]<<endl;
    return 0;
}


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


int main(){
	int n;
	string s;
	cin >> n >> s;
	if(n>=s.size()) cout << s << endl;
	else{
		for(int i=1;i<=s.size();i++){
			if(i>n){
				cout << "..." << endl;
				return 0;
			}
			else cout << s[i-1];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  int n, l;
  cin >> n >> l;
  
  vector<string> data;

  for (int i=0; i<n; i++) {
    string str;
    cin >> str;
    data.push_back(str);
  }

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

  for (auto str:data) cout << str;
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    string s,t;
    cin >>s >> t;

    map<char, VI> char_map;

    REP(i,SZ(s)){
        char_map[s[i]].PB(i);
    }
    REP(i,SZ(s)){
        char_map[s[i]].PB(i+SZ(s));
    }

    LL ans = 0;
    int ptr = 0;
    for(auto c: t){
        if(!SZ(char_map[c])){
            cout<<-1<<endl;
            return 0;
        }
        ptr = *lower_bound(ALL(char_map[c]), ptr) + 1;
        if(ptr >= SZ(s)){
            ptr -= SZ(s);
            ans += SZ(s);
        }
    }

    ans += ptr;
    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 1724
/*

	<LowerCommonAncestor>

*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;



struct Graph
{
	struct edge
	{
		int to;
	};

	int n;
	vector<vector<edge>> edges;

	Graph(int N)
	{
		n = N;
		edges.resize(n,vector<edge>());
	}

	int size() const
	{
		return n;
	}

	vector<edge>& operator[](int v)
	{
		return edges[v];
	}
};


struct Lca
{
	int n;
	int log2_n;
	vector<vector<int>> parent;
	vector<int> depth;

	Lca(Graph& g , int root)
	{
		n = g.size();
		log2_n = floor(log2(n) + 2);
		parent.resize(log2_n,vector<int>(n));
		depth.resize(n);

		dfs(g,root,-1,0);
		for(int k = 0;k + 1 < log2_n;k++)
		{
			for(int v = 0;v < n;v++)
			{
				if(parent[k][v] < 0)
					parent[k + 1][v] = -1;
				else
					parent[k + 1][v] = parent[k][parent[k][v]];
			}
		}
	}

	void dfs(Graph &g , int v,int p,int d)
	{
		parent[0][v] = p;
		depth[v] = d;
		for(auto& e : g[v])
		{
			if(e.to != p)
				dfs(g,e.to,v,d + 1);
		}
	}

	int get(int u,int v)
	{
		if(depth[u] > depth[v]) swap(u,v);
		for(int k = 0;k < log2_n;k++)
		{
			if((depth[v] - depth[u]) >> k & 1)
			{
				v = parent[k][v];
			}
		}
		if(u == v) return u;
		for(int k = log2_n - 1;k >= 0;k--)
		{
			if(parent[k][u] != parent[k][v])
			{
				u = parent[k][u];
				v = parent[k][v];
			}
		}
		return parent[0][u];
	}
};

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

	Graph g(n);
	for(int i = 0;i < n;i++)
	{
		int k;
		cin >> k;
		for(int j = 0;j < k;j++)
		{
			int c;
			cin >> c;
			g[i].push_back({c});
		}
	}

	Lca lca(g,0);

	int q;
	cin >> q;

	for(int i = 0;i < q;i++)
	{
		int u,v;
		cin >> u >> v;

		cout << lca.get(u,v) << endl;
	}

	return 0;
}






Measured memory_bytes: 18948
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int dup = 0;
  bool exist[100001] = {};
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (exist[a]) dup++;
    else exist[a] = 1;
  }
  cout << n - dup - dup % 2 << endl;
  return 0;
}

Measured memory_bytes: 384