akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N,M,ans = 0; cin >> N >> M;
  rep(i,N+M) ans += i;
  ans -= N*M;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
int main(){
IOS;
lli n;
cin>>n;
lli a[n+1],b[n],i,j,sum=0;
for(i=0;i<=n;i++){
    cin>>a[i];
    sum+=a[i];
}
for(i=0;i<n;i++){
    cin>>b[i];
}
lli ans=0;
for(i=0;i<n;i++){
    lli x=min(a[i],b[i]);
    a[i]-=x;
    b[i]-=x;
    x=min(b[i],a[i+1]);
    b[i]-=x;
    a[i+1]-=x;
}
lli total=0;
for(i=0;i<=n;i++){
    total+=a[i];
}
cout<<sum-total<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main() {
  char C;
  cin >> C;
  int moji = (int) C + 1;
  cout << (char) moji << endl;
  return 0;
}

Measured memory_bytes: 256
n,x,y = map(int,input().split())
d = [0 for i in range(0,n)]
for i in range(1,n+1):
    for j in range(i+1,n+1):
        dist = min(j-i, abs(i-x) +1 + abs(j-y))
        d[dist]+=1
for i in range(1,n):
    print(d[i])



Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100100;

map<LL,int> qaq;

void DSY(){
	puts("-1");
	exit(0);
}

int sz[N];

vector<int> es[N];
LL dd[N]={0};
LL d[N];
void dsy(int x,int fa=-1){
	for(vector<int>::iterator it=es[x].begin();it!=es[x].end();++it){
		if(*it==fa)continue;
		dsy(*it,x);
		dd[x]+=dd[*it]+sz[*it];
	}
}

vector<pair<int,int> > ess;
void ae(int u,int v){
	if(u>v)swap(u,v);
	ess.push_back(pair<int,int>(u,v));
	es[u].push_back(v);
	es[v].push_back(u);
}
void print(){
	sort(ess.begin(),ess.end());
	for(vector<pair<int,int> >::iterator it=ess.begin();it!=ess.end();++it){
		printf("%d %d\n",it->first,it->second);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&d[i]);
		qaq[d[i]]=i;
		sz[i]=1;
	}
	int cnt=n;
	for(map<LL,int>::reverse_iterator it=qaq.rbegin();it!=qaq.rend();++it){
		int x=it->second;
		LL ddd=it->first;
		if(sz[x]*2==n)DSY();
		LL nd=ddd+sz[x]-(n-sz[x]);
		if(cnt==1){
			dsy(x);
			if(dd[x]!=d[x])DSY();
			break;
		}
		if(!qaq.count(nd)){
			DSY();
		}else{
			int v=qaq[nd];
			ae(x,v);
			sz[v]+=sz[x];
		}
		cnt--;
	}
	print();
	return 0;
}

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

int main(){
  string T;
  cin >> T;
  int L=T.size();
  for(int i=0; i<L; i++){
    if(T.at(i)=='?'){
      T.at(i)='D';
    }
  }
  cout << T << endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,W;
	cin>>n>>W;
	ll a[n+2],b[n+2];
	for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
	}
	ll dp[n+1][W+1];
    for (int i = 0; i <= n; i++) {
        for (int w = 0; w <= W; w++) {
            if (i == 0 || w == 0)
                dp[i][w] = 0;
            else if (a[i - 1] <= w)
                dp[i][w] = max(b[i - 1] + dp[i - 1][w - a[i - 1]],dp[i - 1][w]);
            else dp[i][w] = dp[i - 1][w];
        }
    }
	cout<<dp[n][W]<<endl;
}


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

const int MOD = (int)1e9+7;

int main(){
  long long K,A,B;
  cin >> K >> A >> B;

  if(A+2>=B){
    cout << 1+K << endl;
    return 0;
  }
  if(K<A+1){
    cout << 1+K << endl;
    return 0;
  }

  long long ans;
  ans=B;
  K-=A+1;
  while(K>0){
    long long x=ans/A;
    if(2*x>K){
      x=K/2;
      if(K%2!=0){
        ans++;
        K--;
      }
    }
    ans=ans-x*A+x*B;
    K-=2*x;
  }
  
  cout << ans << endl;

  return 0;
}


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

//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 SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
    bool ret = true;
    if (x < 2) {
        ret = false;
    }
    for (LL i = 2; i <= sqrt(x); i++) {
        if (x%i == 0) {
            ret = false;
        }
    }
    return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    LL n,m;
    cin >> n >> m;
    vector<LL> a(n,0),sum(n,0);
    map<LL,LL> mp;
    cin >> a[0];
    sum[0] = a[0];
    mp[sum[0] % m]++;
    for (LL i = 1; i < n; i++) {
        cin >> a[i];
        sum[i] += sum[i-1] + a[i];
    mp[sum[i] % m]++;
    }

    LL ans = mp[0];
    for (auto&& var : mp) {
        ans += var.second*(var.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
#define ll long long int

int n;
ll k;
map < int, ll > m;

int main()
{
    cin >> n >> k;
    for(int i = 1 ; i <= n ; i++)
    {
        int a, b;
        cin >> a >> b;
        m[a] += b;
    }
    ll c = 0;
    for(auto it : m)
    {
        c += it.second;
        if(c >= k)
        {
            cout << it.first;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 4224
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    for c in s.trim().chars() {
        let n = c as u8;
        print!(
            "{}",
            if 65 <= n && n <= 90 {
                (n + 32) as char
            } else if 97 <= n && n <= 122 {
                (n - 32) as char
            } else {
                c
            }
        );
    }
    println!();
}



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

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> PQ;
  rep(i, n) {
    int x;
    cin >> x;
    PQ.push(x);
  } 

  rep(i, m) {
    int x;
    x = PQ.top();
    x /= 2;
    PQ.pop();
    PQ.push(x);
  }
  
  ll sum = 0;
  rep(i, n) {
    sum += PQ.top();
    PQ.pop();
  } 
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
	int h1,m1,h2,m2; cin>>h1>>m1>>h2>>m2;
	int k; cin>>k;
	int x=60*h1+m1;
	int y=60*h2+m2;
	int ans=0;
	fore(i,x,y+1) if(i+k-1<=y) ans++;
	cout<<max(0,ans-2)<<"\n";
}

Measured memory_bytes: 3608
// VALUE THE SACRIFICES..
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define out_of_reach ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mod 1000000007
// -----------------------------------------------------------------
void solve()
{
    int n,i,j,x,m,k,u,y;
    string s;
    cin>>s;
    j=0;
    rep(i,3)
        if(s[i]=='A')
            ++j;
    if(j==1 || j==2)   cout<<"Yes";
    else    cout<<"No";
}
signed main()
{
    int t=1;
    //  cin>>t;
    string s;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
def main():
    from string import ascii_lowercase
    dic = {s: i for i, s in enumerate(ascii_lowercase)}
    rdic = {i: s for i, s in enumerate(ascii_lowercase)}
    N = int(input())
    ans = []

    def dfs(n, s):
        if N < n:
            return
        elif n == N:
            ans.append(s)
            return
        else:
            for i in range(max([dic[c] for c in s])+2):
                v = s + rdic[i]
                dfs(n+1, v)
    dfs(1, "a")
    ans.sort()
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 69340
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println( solve(N, A) );
    }

    private static long solve(int N, long[] A) {
        long a0 = A[0];
        if( a0 > 0 ) {
            long p = solve1(N, A, a0, 0);
            long m = solve1(N, A, -1, a0 + 1);
            return Math.min(p, m);
            
        } else if( a0 < 0 ) {
            long p = solve1(N, A, 1, Math.abs(a0) + 1);
            long m = solve1(N, A, a0, 0);
            return Math.min(p, m);

        } else {
            long p = solve1(N, A, 1, 1);
            long m = solve1(N, A, -1, 1);
            return Math.min(p, m);
        }
    }

    private static long solve1(int N, long[] A, long sum, long ans) {
        for (int i = 1; i < N; i++) {
            long a = A[i];

            if( sum > 0 ) {
                // 次はminusになるのを期待
                if( a + sum >= 0 ) {
                    // sumが-1になるような値にまで変更する
                    //   a + sum が 5 の場合、6 だけ操作すると -1 にできる
                    long diff = a + sum + 1L;
                    ans += diff;
                    sum = -1;

                } else {
                    sum += a;
                }

            } else {
                if( a + sum <= 0 ) {
                    long diff = Math.abs(a + sum) + 1L;
                    ans += diff;
                    sum = 1;

                } else {
                    sum += a;
                }
            }
        }
        return ans;
    }
}


Measured memory_bytes: 49696
N = int(input())

R0 = int(input())
R1 = int(input())

minR = min(R0, R1)
maxv = R1 - R0

for i in range(N-2):
    Ri = int(input())
    if Ri < minR:
        minR = Ri
    elif maxv < Ri - minR:
        maxv = Ri - minR

print(maxv)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
int main()
{
	long long n;
	cin>>n;
	vector<long long> a(n);
	for(int i=0;i<n;i++)
	{
	cin>>a[i];
	}
	vector<long long>dp(n);
	dp[n-1]=0;
	dp[n-2]=abs(a[n-1]-a[n-2]); 
	for(int i=n-3;i>=0;i--)
	{
		dp[i]=min(dp[i+1]+abs(a[i]-a[i+1]),dp[i+2]+abs(a[i]-a[i+2]));
	}
	cout<<dp[0]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str = next<string>();
	if (str == "ABC") cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3640
#include <iostream>

using ll = long long;
constexpr int AMAX = 100000;
ll cnt[AMAX + 1];
int main(){
  int N;
  ll K;
  std::cin >> N >> K;
  for (int i = 0;i< N; ++i) {
    int A, B;
    std::cin >> A >> B;
    cnt[A] += B;
  }
  for (int ans = 1; ans <= AMAX; ++ans){
    if (K <= cnt[ans]){
      std::cout << ans << std::endl;
      break;
    }
    K -= cnt[ans];
  }
  return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_N = 100000;


int main(int argc, char *args[]) {
	string S;
	cin >> S;
	int N = S.size();
	int counter = 0;
	int ans;

	for (int i = 0; i < N; i += 2) {
		if (S[i] == '0')counter++;
	}
	for (int i = 1; i < N; i += 2) {
		if (S[i] == '1')counter++;
	}
		
	ans = min(counter, N - counter);
	cout << ans << endl;

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

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

    rep(i,n/1000+2){
        if(n-i*1000<=0){
            cout<<(n-i*1000)*(-1)<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3600
n = int(input())
s = input()
if n%2==1:
  print("No")
else:
  x = n//2
  ans = True
  for i in range(x):
    if(s[i] != s[x+i]):
      ans = False
  if(ans):
    print("Yes")
  else:
    print("No")
  

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N, R;
  cin >> N >> R;
  if(N >= 10){
    cout << R << endl;
  }else{
    cout << R + 100*(10-N) << endl;
  }
  return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;

struct SegTree {
  int seg_tree_size = 1;
  int nums_size;
  vector<ll> data;

  SegTree(int origin_size, vector<ll> a) {
    // 簡単のため数列の要素数が2のべき乗と考える
    while(seg_tree_size < origin_size) seg_tree_size *= 2;
    nums_size = seg_tree_size;
    seg_tree_size = seg_tree_size * 2 - 1;

    // 2分木の要素数は2*要素数-1
    // n + n/2 + n/4 + n/8 + ... 1 = 2*n-1
    data = vector<ll> (seg_tree_size, -1);
    for (int i = 0; i < origin_size; i++) {
      update(i, a[i]);
    }
  }

  // k番目の値をxに変更
  void update(int k, int a){
    // 葉のノードの番号
    k += (seg_tree_size - nums_size);
    data[k] = a;

    // 登りながら更新
    while(k > 0) {
      k = (k-1) / 2;
      data[k] = max(data[k * 2  + 1], data[k * 2 + 2]);
    }
  }


  // [a, b)の最小値を求める
  // kは節点の番号。l, rはその節点が[1, r)に対応づいている
  // (a, b, 0, 0, n)として呼び出す。
  int query(int a, int b, int k, int l, int r){
    // cout << l << " : " << r << endl;
    // cout << a << " : " << b << endl;
    // 交差しなければ
    if(r <= a || b <= l) return -1;
    // [a, b)が[1, r)を完全に含んでいれば、この節点の値
    if(a <= l && r <= b) return data[k];
    // そうでなければ、2つの子の最小値
    else{
      int vl = query(a, b, k*2+1, l, (l+r)/2);
      int vr = query(a, b, k*2+2, (l+r)/2, r);
      // cout << min(vl, vr) << endl;
      return max(vl, vr);
    }
  }

  int query(int a, int b){
    return query(a, b, 0, 0, nums_size);
  }

};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  SegTree st(n, v);
  // print(st.data);

  cout << st.query(1, n) << endl;
  for (int i = 1; i < n-1; i++) {
    cout << max(st.query(0, i), st.query(i+1, n)) << endl;
  }
  cout << st.query(0, n-1) << endl;

}


Measured memory_bytes: 7552
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use std::io::Read;

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

    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();

    let g = gcd(a, b);

    println!("{}", a + b - g + 1);
}

fn gcd(n: usize, m: usize) -> usize {
    if m == 0 {
        n
    } else {
        gcd(m, n % m)
    }
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
int main()
{
     int n,m,x;
cin>>n>>m>>x;
vector<int> v;
for(int i=0;i<m;i++)
{
int y;
cin>>y;
v.push_back(y);
}
auto it=lower_bound(v.begin(),v.end(),x);
if(it==v.end())
{
cout<<0<<endl;
return 0;
}
if(it==v.begin())
{
cout<<0<<endl;
return 0;
}
int u=it-v.begin();
cout<<min(u,m-u)<<endl;
}

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

public class Main {

	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}

	private long solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long [] array = new long[N+1];
		long sum=0;
		for(int i=1;i<=N;i++){
			array[i] = sc.nextLong();
			sum += array[i];
		}

		long [][]dp = new long[3002][3002];

		long X = solve(array, 1, N, 1, dp);
		long Y = sum-X;
		return X-Y;
	}


	private long solve(long[]array, int left, int right, int turn, long[][] dp) {

		if(left>right) return 0;
		if (dp[left][right] != 0) return dp[left][right];

		long answer =0;
		if (turn==1) {
			long leftVal = array[left] + solve(array, left+1, right, 0, dp);
			long rightVal = array[right] + solve(array, left, right-1, 0, dp);
			answer = Math.max(leftVal, rightVal);
		} else {
			long leftVal = solve(array, left+1, right, 1, dp);
			long rightVal = solve(array, left, right-1, 1, dp);
			answer = Math.min(leftVal, rightVal);
		}

		dp[left][right] = answer;

		return answer;
	}

}

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

int main(){
    int n;
    cin >> n;
    P max1,max2;
    max1 = P(-2, -1);
    max2 = P(-2, -2);
    rep(i,n){
        int a;
        cin >> a;
        if(max1.second< a){
            max1 = P(i,a);
        }else if(max2.second < a && a <= max1.second){
            max2 = P(i,a);
        }else continue;
    }
    rep(i,n){
        if(max1.first == i){
            cout << max2.second << endl;;
            continue;
        }else{
            cout << max1.second << endl;;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    struct edge{
        ll from;
        ll to;
        ll cost;
    };

    ll n,m;
    cin>>n>>m;
    vector<edge> E(m);
    rep(i,m){
        ll s,t,d;
        cin>>s>>t>>d;
        s--; t--;
        E[i]={s,t,-d};
    }

    vector<ll> dist(n,INF);
    dist[0]=0;
    rep(i,n*2){
        bool update=false;
        for(auto x:E){
            if(dist[x.from] != INF && dist[x.from]+x.cost < dist[x.to]){
                update=true;
                dist[x.to] = dist[x.from]+x.cost;
                if(i>=n && x.to == n-1){
                    cout<<"inf"<<endl;
                    return 0;
                }
            }
        }
    }

    cout<<-dist[n-1]<<endl;
    
    return 0;
}

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

using namespace std;

#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)

using i64 = long long;
using pii = pair<i64, i64>;

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

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string s;
  cin >> s;

  int len = s.length();
  vector<int> a(len+5, 1);

  for (int i = 0; i < len - 1; ++i) {
    if (s.substr(i, 2) == "RR") {
      a[i+2] += a[i];
      a[i] = 0;
    }
  }

  for (int i = len - 1; i > 0; --i) {
    if (s[i] == 'L' && s[i-1] == 'L') {
      a[i-2] += a[i];
      a[i] = 0;
    }
  }

  for (int i = 0; i < len; ++i) {
    cout << a[i] << (i == len - 1)[" \n"];
  }

  return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s,t;
    cin>>s>>t;
    bool ok=true;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]!=t[i]) ok=false;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;


struct Macchi {
    ll number;
    ll count;
};


vector<Macchi> A;

map<ll,ll> dp_l;

ll dp(ll i){
    if(dp_l.find(i) != dp_l.end()){
        return dp_l[i];
    }

    //cout << "dp(i): " << i << endl;
    if(i == 0) {
        dp_l[i] = 0;
        return dp_l[i];
    }
    if(i == 1 || i < 0) {
        dp_l[i] = - 100000000;
        return dp_l[i];
    }


    int max = -100000000;
    for (int j = 0; j < A.size(); ++j) {
        ll x = dp(i - A[j].count) + 1;
        if(max < x){
            max = x;
        }
    }
    dp_l[i] = max;
    return dp_l[i];
}

int main() {

    ll N, M;
    map<ll, ll> X;
    X[1] = 2;
    X[7] = 3;
    X[4] = 4;
    X[5] = 5;
    X[3] = 5;
    X[2] = 5;
    X[9] = 6;
    X[6] = 6;
    X[8] = 7;

    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        ll a;
        cin >> a;
        Macchi m;
        m.number = a;
        m.count = X[a];
        bool flag = false;
        for (int j = 0; j < A.size(); ++j) {
            if(m.count == A[j].count){
                if(m.number> A[j].number){
                    A[j].number = m.number;
                    flag = true;
                    break;
                }
            }
        }
        if(!flag){
            A.push_back(m);
        }

    }
    sort(A.begin(), A.end(),
         [](const Macchi m1, const Macchi m2) {
             return (m1.number > m2.number);
         });


    vector<ll> rs;
    while(N != 0){
        for (int j = 0; j < A.size(); ++j) {
            if(dp(N - A[j].count) == dp(N) - 1){
                N -= A[j].count;
                rs.push_back(A[j].number);
                break;
            }
        }
    }

    sort(rs.begin(),rs.end(),greater<ll>());

    for (int i1 = 0; i1 < rs.size(); ++i1) {
        cout << rs[i1];
    }
    cout << endl;



    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  ll n,k,r,s,p;
  cin>>n>>k>>r>>s>>p;
  vector<char> vec(n);
  for(ll i=0;i<n ;i++) cin>>vec[i];
  vl score(n) ;
  
  for(ll i=0;i<n;i++){
    if(vec[i]=='r') score[i] =p;
    else if(vec[i]=='s') score[i] =r;
    else if(vec[i]=='p')score[i] =s;
  }
  ll ans =0;
  for(ll i=0;i<k; i++){
    bool plus = true;
    ans +=(ll)score[i];
    
    for(ll j=i+k; j<n; j =j+k){
      if(vec[j]==vec[j-k]&& plus ==true){
        plus =false;
      }
    
      else{
        ans+= (ll)score[j];
        plus =true;
      }
      
    }
  }
  cout<<ans<<endl;

}
  


Measured memory_bytes: 1152
N,X = (int(x) for x in input().split())
P = [1]
for i in range(N):
    P.append(1+2*(P[-1]))
PB = [1]
for i in range(N):
    PB.append(3+2*(PB[-1]))
ans = 0
for i in range(N+1):
    if X == PB[N-i]:
        if N - i > 0:
            ans += 1 + (2*P[N-1-i])
            break
        else:
            ans += 1
            break
    elif X == 2 + PB[N-1-i]:
        ans += 1 + P[N-1-i]
        break
    elif X == 1:
        break
    elif X < 2 + PB[N-1-i]:
        X -= 1
    else:
        X -= 2 + PB[N-1-i]
        ans += 1 + P[N-1-i]
print(ans)

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

int main() {
  ll N, D;
  cin >> N >> D;
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    ll x, y;
    cin >> x >> y;
    if (D * D >= (x * x + y * y)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

long long n, a, b, c, s;
int main() {
	cin >> n;
	while(n--) {
		cin >> a >> b;
		if(a > b) swap(a, b);
		c = sqrt(a*b);
		if(c*c < a*b) {
			s = 2*c - 1;
			if(a<=c) s--;
			if(c*(c+1) < a*b) s++;
		} else {
			s = 2*c - 2;
			if(a<c) s--;
		}
		cout << s << endl;
	}
	return 0;
}

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

lld cnt[256];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	string ss; cin>>ss;
	int n = ss.size();
	lld ans = (lld)n*(n+1)/2+1-n;
	for(int i=n-1;i>=0;i--){
		ans -= cnt[(int)ss[i]];
		cnt[(int)ss[i]]++;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define re register
#define ll long long
const int N=310;
struct node{
	int l,x;
};
vector<node>G[N];
const int Mod=1e9+7;
int f[N][N][N],n,m;
bool check(int a,int b,int c){
	int r=max(a,max(b,c));
	for(int i=0,t=G[r].size();i<t;i++){
		int l=G[r][i].l,x=G[r][i].x,s=0;
		s=(a>=l)+(b>=l)+(c>=l);
		if(s!=x)return false;
	}
	return true;	
}
int main(){
	scanf("%d%d",&n,&m);
	for(re int i=1;i<=m;i++){
		int x,l,r;scanf("%d%d%d",&l,&r,&x);
		G[r].push_back((node){l,x});
	}
	f[0][0][0]=1;ll ans=0;
	for(re int i=0;i<=n;i++)
		for(re int j=0;j<=n;j++)
			for(re int k=0;k<=n;k++)
				if(f[i][j][k]){
					if((i && j && i==j) || (j && k && j==k) || (i && k && i==k))continue;
					if(!check(i,j,k)){f[i][j][k]=0;continue;}
					int r=max(i,max(j,k));
					f[r+1][j][k]+=f[i][j][k];if(f[r+1][j][k]>=Mod)f[r+1][j][k]-=Mod;
					f[i][r+1][k]+=f[i][j][k];if(f[i][r+1][k]>=Mod)f[i][r+1][k]-=Mod;
					f[i][j][r+1]+=f[i][j][k];if(f[i][j][r+1]>=Mod)f[i][j][r+1]-=Mod;
					if(r==n){
						ans+=f[i][j][k];if(ans>=Mod)ans-=Mod;
					}
				}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 114944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");
		int h = Integer.parseInt(tmpArray[0]);
		int w = Integer.parseInt(tmpArray[1]);

		int[][] tile = new int[h][w];
		for(int i = 0; i < h; i++){
			Arrays.fill(tile[i], 0);
		}

		int n = Integer.parseInt(br.readLine());
		
		int[] color = new int[n];
		tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			color[i] = Integer.parseInt(tmpArray[i]);
		}
		
		final int RIGHT = 0;
		final int DOWN = 1;
		final int LEFT = 2;
		final int UP = 3;
		int[] vx = {1,0,-1,0};
		int[] vy = {0,1,0,-1};
		int mode = RIGHT;
		int currentX = 0;
		int currentY = 0;
		
		for(int i = 1; i <= n; i++){
			for(int j = 0 ; j < color[i - 1] ; j++){
				//coloring
				tile[currentY][currentX] = i;
				if(mode == RIGHT && (currentX + 1 == w || tile[currentY][currentX + 1] != 0)){
					mode = DOWN;
//					currentY++;
				}
				else if(mode == DOWN && (currentY + 1 == h || tile[currentY + 1][currentX ] != 0)){
					mode = LEFT;
//					currentX--;
				}

				else if(mode == LEFT && (currentX == 0 || tile[currentY][currentX - 1] != 0)){
					mode = UP;
//					currentY--;
				}

				else if(mode == UP && (currentY == 0 || tile[currentY - 1][currentX] != 0)){
					mode = RIGHT;
//					currentX++;
				}
				
				currentX += vx[mode];
				currentY += vy[mode];


			}
				
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(j == 0){
					System.out.print(tile[i][j]);
				}
				else {
					System.out.print(" "+tile[i][j]);
				}
			}
			System.out.println();
		}
		
	}

}


Measured memory_bytes: 24404
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050

ll n,m,k;
ll a[N];

main(){
    n=in();
    vec v;
    ll ans=0;
    rep(i,n){
        v.pb(in());
    }
    int now=1;
    ans=v[0]-1;
    rep2(i,1,n-1){
        if(v[i]==now+1)now+=1;
        else{
            ans+=(v[i]-1)/(now+1);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 892
s = list(map(str,input()))
t = list(map(str,input()))

ans = len(t)

for i in range(0,len(s)-len(t)+1):
    df = 0
    for j in range(0,len(t)):
        if s[i+j] != t[j]:
            df += 1
    ans = min(ans,df)

print(ans)

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	// int n;
	// cin>>n;
	
	int a, b, h, m;
	cin>>a>>b>>h>>m;
	double a1 = h*30 + m*0.5;
	double a2 = m*6;
	double ans = a*a+b*b-2*a*b*cos(abs(a1-a2)*PI/180.0);
	ans=sqrt(ans);
	cout<<fixed<<setprecision(15)<<ans<<endl;

	// cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        cout << "Possible";
    else
        cout << "Impossible";
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL =long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 9; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[20000], a[20000], b[20000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<Pll>vec[3100];
vector<edge>ed;
vector<LL>v;
map<string,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m >> s;
	if (n + m + 1 >= s)
		cout << s + m << endl;
	else
		cout << m + (m + n + 1) << endl;
	return 0;
}

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

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

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

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int n;
    int maxval = INT_MIN;
    int minval = INT_MAX;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        maxval = max(maxval, a);
        minval = min(minval, a);
    }
    cout << maxval - minval << endl;
    return 0;
}


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

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

	string S;
	cin >> S;

	vector<int> a( 128 );
	for( int i = 0; i < S.size(); ++i ) {
		a[ S[i] ] += 1;
	}

	string result = "None";
	for( char i = 'a'; i <= 'z'; ++i ) {
		if( a[i] == 0 ) {
			result = i;
			break;
		}
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define P pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main()
{
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

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

    bool flag = true;

    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < s.size(); j++)
        {
            flag = false;
            if (s[j] != t[j + i])
            {
                break;
            }
            flag = true;
        }

        if (flag)
        {
            break;
        }
    }

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

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

int main()
{
  int a[3],k;
  cin >> a[0] >> a[1] >> a[2] >> k;
  
  sort(a,a+3);
  while(k > 0){
    a[2] *= 2;
    k--;
  }
  
  cout << a[0] + a[1] + a[2] << endl;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define maxx 100010
#define mp make_pair
typedef pair<int,int> ii;
int dp[maxx],visitado[maxx];
vector <int> peso;

int solve(int k){
	// cout << visitado[k] << " k " << k << " dp[k] " << dp[k]  << endl;
	if(k == 0) return 0;
	if(k==1) return dp[1] = abs(peso[0] - peso[1]);
	if(visitado[k] == 1) return dp[k];
	
	visitado[k] = 1;
	dp[k] = min(solve(k-2) + abs(peso[k-2] - peso[k]),solve(k-1) + abs(peso[k-1] - peso[k]));
	// cout << visitado[k] << " k " << k << " dp[k] " << dp[k]  << endl;

	return dp[k];
}
int x;
int main() {
	cin >> x;
	int n;
	for(int i = 0; i < x; i++){
		cin >> n;
		peso.push_back(n);
	}
	int ans = solve(x-1);
	cout << ans << endl;
	return 0;
}

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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;

#define lowbit(x) (x&-x)
struct BIT {
    int *ary = nullptr, sz = 0;
    BIT(int sz = 5) { resize(sz); }
    BIT(const BIT& it) { resize(it.sz, it.ary); }
    void resize(int _sz, const int *_a = nullptr) {
        sz = _sz;
        if (ary != nullptr)
            delete [] ary;
        ary = new int[sz+1]();
        if (_a != nullptr)
            for(int i = 0; i != sz; ++i) ary[i] = _a[i];
    }
    void modify(int x, int v) {
        for(x++; x <= sz; x += lowbit(x)) ary[x] += v;
    }
    int query(int x) {
        int rt = 0;
        for(; x > 0; x -= lowbit(x)) rt += ary[x];
        return rt;
    }
    int query(int l, int r) {
        return query(r) - query(l-1);
    }
};

signed main() {
    FAST;

    int N, Q;
    string s;
    cin >> N >> s >> Q;
    vector<BIT> bit(26, BIT(N));
    Fr(i, 0, N) bit[s[i]-'a'].modify(i, 1);
    Fr(q, 0, Q) {
        int o; cin >> o;
        if (o == 1) {
            int i; char c;
            cin >> i >> c; i--;
            bit[s[i]-'a'].modify(i, -1);
            s[i] = c;
            bit[s[i]-'a'].modify(i, 1);
        } else {
            int l, r;
            cin >> l >> r;
            int res = 0;
            Fr(c, 0, 26) res += bit[c].query(l, r) > 0;
            cout << res << endl;
        }
    }

}


Measured memory_bytes: 53788
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

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

	ll a, b;
	while (q--) {
		scanf("%lld %lld", &a, &b);

		if (a == b) {
			printf("%lld\n", (a - 1) * 2);
			continue;
		}
		else {
			ll sum = a * b;
			ll sq = sqrt(sum);

			if (sq * sq == sum) printf("%lld\n", (sq - 1) * 2 - 1);
			else if (sq * (sq + 1) >= sum) printf("%lld\n", (sq - 1) * 2);
			else printf("%lld\n", sq * 2 - 1);
		}
	}
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())), dtype='int64')
am = a[np.where(a<=0)]

a2 = np.array(list(map(abs, a)), dtype='int64')
ans = sum(a2)
if len(am) % 2 == 1:
    m = np.amin(a2)
    ans -= 2 * m

print(ans)

Measured memory_bytes: 23288
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    string A(b, '0' + a);
    string B(a, '0' + b);

    cout << min(A, B) << "\n";

    return 0;
}

Measured memory_bytes: 256