akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
#define YesNo(b) (b ? "Yes" : "No")
#define YESNO(b) (b ? "YES" : "NO")
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }

// all_of
// partial_sum, adjacent_difference

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

//template<class T, class U>
//struct CompBySecond {
//	bool operator(const pair<T, U>& left, const pair<T, U>& right) {
//		return left.second < right.second || (left.second == right.second && left.first < right.first);
//	}
//};


int N;
string S;
vector<pair<PP, int>> PV;
int DP[500005];
int main() {
	cin >> N >> S;
	S = '.' + S + '.';
	REP(i, 1, N + 2) {
		if (S.substr(i - 1, 3) == "101") {
			int l = i - 1, r = i + 1;
			while (S[l] == '1') --l;
			REP(k, l + 1, i) PV.push_back(make_pair(PP(k, i + 1), i - k));
			while (S[r] == '1') ++r;
			REP(k, i + 2, r) PV.push_back(make_pair(PP(i - 1, k), k - i));
		}
	}
	sort(PV.begin(), PV.end(), [](pair<PP, int> l, pair<PP, int> r) {return l.first.second < r.first.second; });
	PV.push_back({ {INF,INF}, 0});
	int ptr = 0;
	REP(i, 1, N + 3) {
		DP[i] = DP[i - 1];
		while (PV[ptr].first.second == i) {
			auto pp = PV[ptr];
			DP[i] = max(DP[i], DP[pp.first.first - 1] + pp.second);
			++ptr;
		}
	}
	cout << DP[N + 2] << endl;
	return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 200010, M = 1010;

int n, m;
PII a[N];

bool cmp(PII a, PII b)
{
	if (a.S != b.S) return a.S < b.S;
	else return a.F > b.F;
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i ++ )
	{
		scanf("%d%d", &a[i].F, &a[i].S);
		a[i].F ++ ;
	}
	sort(a, a + m, cmp);
	
	int res = 0, pos = -0x3f3f3f3f;
	for (int i = 0; i < m; i ++ )
		if (a[i].F > pos)
		{
			res ++ ;
			pos = a[i].S;
		}
		
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll gcd(ll a,ll b){
  if(!b) return a;
  return gcd(b,a%b);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    cout<<360/gcd(360,x);
}

Measured memory_bytes: 3608
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
int main(){

int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
int sax=x2-x1;
int say=y2-y1;
int x3=x2-say;
int y3=y2+sax;
int x4=x3-sax;
int y4=y3-say;
cout <<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;








}

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

int N;

int main(){
    cin >> N;
    double x;
    string u;
    double ans=0.0;
    for(int i=0;i<N;i++){
        cin >> x >> u;
        if(u=="JPY") ans+=x/380000.0;
        else ans+=x;
    }
    cout << ans*380000.0;
}

Measured memory_bytes: 256
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n,k;

int main()
{
  LL risan = 0;
  scanf("%d %d",&n,&k);
  FORN(i,k+1,n)
  {
    int komplit = n / i;
    debug("%d %d\n",i,komplit);
    risan += (i - k) * komplit;
    risan += max(0, n % i - k + 1);
    // debug("%lld\n",risan);
  }
  if (k == 0) risan -= n;
  printf("%lld\n",risan);
  return 0;
}











Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int A, B, C, X, cnt = 0, tmp;
    cin >> A >> B >> C >> X;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if((500*i + 100*j + 50*k) == X){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

template <typename T>
T abs(T x) {return (x < 0) ? -x : x;}

cat pw(cat a, cat e, cat mod) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2, mod);
	x = x * x % mod;
	return (e&1) ? x * a % mod : x;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string S;
	int K;
	cin >> S >> K;
	S += '0';
	int L = S.length(), n1 = 0, N = 0;
	vector<int> A;
	for(int i = 0, cur = 0; i < L; i++) {
		if(S[i] == '0') {
			A.push_back(cur);
			N++;
			cur = 0;
		}
		else n1++, cur++;
	}
	K = min(K, n1);
	reverse(begin(A), end(A));
	cat mod = 998244353;
	vector< vector< vector<cat> > > cnt(N+1, vector< vector<cat> >(K+1, vector<cat>(K+1, 0)));
	cnt[0][0][0] = 1;
	for(int i = 0; i < N; i++) {
		// increase/keep A[i]
		for(int k = 0; k <= K; k++) {
			cnt[i+1][k][k] = cnt[i][k][k];
			for(int j = k-1; j >= 0; j--) cnt[i+1][j][k] = cnt[i+1][j+1][k] + cnt[i][j][k];
		}
		// decrease A[i]
		for(int j = 0; j <= K; j++)
			for(int l = 1; l <= A[i]; l++)
				for(int k = j; k <= K-l; k++) cnt[i+1][j+l][k+l] += cnt[i][j][k];
		for(int j = 0; j <= K; j++) for(int k = j; k <= K; k++) cnt[i+1][j][k] %= mod;
	}
	cat ans = 0;
	for(int i = 0; i <= K; i++) ans += cnt[N][0][i];
	ans %= mod;
	cout << ans << "\n";
}


Measured memory_bytes: 31044
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
int main(void){
    ll N, ANS=0, A;
    scanf("%lld", &N);
    rep(i, 0, N){
        scanf("%lld", &A);
        while(A%2==0){
            ANS++;
            A /= 2;
        }
    }
    printf("%lld\n", ANS);
    return 0;
}
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<ve>      vve;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************

int main(void) {

	vi A(3);
	cin >> A;

	sortall(A);

	cout << A[2] - A[0] << endl;



	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)

	cl := make([]int, n)
	al := make([][]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&cl[i])
		al[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&al[i][j])
		}
	}

	min := int(1e9)
	for k := 0; k < 1<<uint(n); k++ {
		cost := 0
		tmpl := make([]int, m)
		for l := 0; l < n; l++ {
			if 1<<uint(l)&k > 0 {
				// フラグの立っている参考書
				//tmpl[l] += al[k][l]
				cost += cl[l]
				for q := 0; q < m; q++ {
					tmpl[q] += al[l][q]
				}
				// 論理積は順番で結果変わる
				//fmt.Println(1 << uint(l) & k)
				//fmt.Println(k & 1 << uint(l))
			}
		}

		ok := true
		for i := 0; i < m; i++ {
			if tmpl[i] < x {
				ok = false
			}
		}
		if ok {
			if cost < min {
				min = cost
			}
		}
	}

	if min == int(1e9) {
		fmt.Println(-1)
	} else {
		fmt.Println(min)
	}
}


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

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


n = int(input())
str_list = []
for _ in range(n):
    s = str(input())
    str_list.append(s)
# print(str_list)

res = [0] * 4

for s in str_list:
    if s == 'AC':
        res[0] += 1
    if s == 'WA':
        res[1] += 1
    if s == 'TLE':
        res[2] += 1
    if s == 'RE':
        res[3] += 1

print(f'AC x {res[0]}')
print(f'WA x {res[1]}')
print(f'TLE x {res[2]}')
print(f'RE x {res[3]}')


Measured memory_bytes: 17040
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n;
  double a, f = 0;
  cin >> n;
  REP(i, n) {
    cin >> a;
    f += 1 / a;
  }
  cout << fixed << 1 / f << endl;
  return 0;
}

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

int main(){
  int a,b,z=0;
  int num[2500];
  cin>>a>>b;
  char s[a][b];
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin>>s[i][j];
    }
  }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      if(s[i][j]=='.'){
        int count=0;
        if(i-1>-1){
          if(j-1>-1){
		    if(s[i-1][j-1]=='#') count++;
          }if(s[i-1][j]=='#') count++;
          if(j+1<b){
            if(s[i-1][j+1]=='#') count++;
          }
        }if(j-1>-1){
          if(s[i][j-1]=='#') count++;
        }if(j+1<b){
          if(s[i][j+1]=='#') count++;
        }if(i+1<a){
          if(j-1>-1){
		    if(s[i+1][j-1]=='#') count++;
          }if(s[i+1][j]=='#') count++;
          if(j+1<b){
          if(s[i+1][j+1]=='#') count++;
        }
      }
        num[z]=count;
        z++;
      }
    }
  }
  z=0;
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      if(s[i][j]=='.'){
        cout<<num[z];
        z++;
        continue;
      }cout<<s[i][j];
    }
    cout<<endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 200000;
const int MOD = 1000000007;
const int INF = 1e8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
//

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

    int zero = 0, um = 0;
    for(auto c : s) {
        if(c == '1')
            um++;
        else
            zero++;
    }

    cout << min(2*zero, 2*um) << endl;


    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

char s[114514];

int main(void) {
	int i;
	int score = 0;
	if (scanf("%114513s", s) != 1) return 1;
	for (i = 0; s[i] != '\0'; i++) {
		if (i % 2 == 0) {
			/* g */
			if (s[i] == 'p') score--;
		} else {
			/* p */
			if (s[i] == 'g') score++;
		}
	}
	printf("%d\n", score);
	return 0;
}

/*

パーのストックがあるとき パーを出す or とっておく
基本的にパーを出せるだけ出した方が有利

gp 0 + 0 = 0
gp

pg 1 + (-1) = 0
gp

gp (-1) + 1 = 0
pg

pg 0 + 0 = 0
pg

どっちでもいい → gpgpgp...を出せばよい

*/


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    s = input().rstrip()
    a = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
    print(7-a.index(s))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
#include <algorithm>
#include <iostream>
#include <deque>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    deque<char> deq;
    for (int i = 0; i < (int) S.size(); i++) {
        deq.push_back(S[i]);
    }

    int direction = 1;

    for (int i = 0; i < Q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            direction *= -1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (direction == 1) {
                if (f == 1) {
                    // add top
                    deq.push_front(c);
                } else {
                    // add back
                    deq.push_back(c);
                }
            } else {
                if (f == 1) {
                    // add top
                    deq.push_back(c);
                } else {
                    // add back
                    deq.push_front(c);
                }
            }
        }
    }

    ll siz = (ll) deq.size();
    for (ll i = 0; i < siz; i++) {
        char c;
        if (direction > 0) {
            c = deq.front();
            deq.pop_front();
        } else {
            c = deq.back();
            deq.pop_back();
        }
        printf("%c", c);
    }
    printf("\n");

    // if (direction < 0) {
    //     reverse(deq.begin(), deq.end());
    // }
    // for (int i = 0; i < (int) deq.size(); i++) {
    //     char c = deq.push_front();
    //     deq.pop_front();
    //     printf("%c", deq[i]);
    // }
    // for (ll i = 0; i < (ll) deq.size(); i++) {
    //     printf("%c", deq[i]);
    // }
    // printf("\n");

    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void){
	int a,b,c,d;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	
	printf("%d\n",(a+b+c+d)/60);
	printf("%d\n",(a+b+c+d)-60*((a+b+c+d)/60));
	return 0;
}

Measured memory_bytes: 596
n,t=map(int,input().split())
dish=[list(map(int,input().split())) for i in range(n)]
dish.sort()
dp=[0]*6001
for i in range(n):
    a,b=dish[i]
    for j in range(t-1,-1,-1):
        dp[j+a]=max(dp[j+a],dp[j]+b)
print(max(dp))

Measured memory_bytes: 75144
#include<stdio.h>
int main()
{
        char c11,c12,c13,c21,c22,c23,c31,c32,c33;
        scanf("%c%c%c\n%c%c%c\n%c%c%c",&c11,&c12,&c13,&c21,&c22,&c23,&c31,&c32,&c33);
        printf("%c%c%c",c11,c22,c33);
        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    string S;
    cin >> N >> S;
    bool flag = true;
    if(N%2==1){
        cout << "No" << endl;
        return 0;
    }
    rep(i,N/2){
        if(S[i]!=S[N/2+i])flag = false;
    }
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include <cmath>
#include <string.h>
#include<ctype.h>

using namespace std;


int main()

{
   int a,b,t;
   scanf("%d%d%d",&a,&b,&t);

   printf("%d\n",(t/a)*b);
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int64_t ans = 0;
    rep(i, N)
    {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.root = [-1]*(n+1)
		self.rank = [0]*(n+1)
		self.cycle = [False]*(n+1)

	def find(self, x):
		if(self.root[x] < 0):
			return x
		else:
			self.root[x] = self.find(self.root[x])
			return self.root[x]
			
	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if(x == y):
			self.cycle[x] = True
		elif(self.rank[x] > self.rank[y]):
			self.root[x] += self.root[y]
			self.cycle[x] |= self.cycle[y]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			self.cycle[y] |= self.cycle[x]
			self.root[x] = y
			if(self.rank[x] == self.rank[y]):
				self.rank[y] += 1

	def isSame(self, x, y):
		return self.find(x) == self.find(y)
		
	def isCycle(self, x, y):
		cx = self.cycle[self.find(x)]
		cy = self.cycle[self.find(y)]
		if cx == cy == False:
			return False
		elif cx ^ cy:
			return True
		else:
			return 2

	def size(self, x):
		return -self.root[self.find(x)]

n,h,w,*l = map(int,open(0).read().split())
cards = sorted([(a,r,c) for r,c,a in zip(*[iter(l)]*3)])[::-1]

uf = UnionFind(h+w)
ans = 0

for a,r,c in cards:
	c += h
	if not ( (uf.isSame(r,c) and uf.isCycle(r,c)) or uf.isCycle(r,c)==2 ):
		uf.unite(r,c)
		ans += a
print(ans)

Measured memory_bytes: 129732
n,k=map(int,input().split())
h=[int(x) for x in input().split()]
dp=[float('inf')]*n
dp[0]=0
for i in range(1,n):
    for j in range(1,1+k):
        if i>=j:
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))

#print(dp)          
print(dp[n-1])


Measured memory_bytes: 55392
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#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>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll a;
    ll b;
    cin >> a >> b;
    if( b%a == 0){
        cout << a+b << endl;
    }else{
        cout << b-a << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3204
#include <iomanip>
#include <utility>
#include <algorithm>
#include <type_traits>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
#include <memory>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <queue>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <forward_list>
#include <iomanip>
#include <functional>
using namespace std;
#define MFOR(i,end) for(size_t i = 0, end_i = (end); i < end_i; ++ i)


int main()
{
	int a, b;
	std::cin >> a >> b;
	if (0 < b) {
		if (0 < a) {
			std::cout << "Positive\n";
		}
		else {
			std::cout << "Zero\n";
		}
	}
	else
	{
		 if(b == 0){
			 std::cout << "Zero\n";
		 }
		 else
		 {
			 //a,b負数
			 bool is_ne = (b-a+1) % 2;
			 //for (a; a <= b; ++a)
			 //{
				// is_po = !is_po;
			 //}
			 if (is_ne) {
				 std::cout << "Negative\n";
			 }
			 else {
				 std::cout << "Positive\n";
			 }
		 }
	}
}

Measured memory_bytes: 888
#include <stdio.h>
int main ()
{
  int num,i,j,key;
  scanf("%d",&num);
  int arr[num];
  for(i = 0; i < num;i++){
  scanf("%d",&arr[i]);
  }
  for(j = 1; j <= num; j++){
    for(int k = 0; k < num - 1; k++){
      printf("%d ",arr[k]);
    }
    printf("%d\n",arr[num - 1]);
    key = arr[j];
    i = j - 1;
    while((i >= 0) && (arr[i] > key)){
      arr[i+1] = arr[i];
      i = i - 1;
    }
    arr[i + 1] = key;
  }
  return 0;
}




Measured memory_bytes: 2128
#include <iostream>
using namespace std;
int main() {
 int ans = 0, n;
 cin >> n;
 int mx = n;
 for (int i = 0; i < n; i++) {
   int x; cin >> x;
   if (mx >= x) ans++;
   mx = min(x,mx);
 }
 cout << ans;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using uli = unsigned long long;
using ld = long double;

void solve(bool);

//#define YA

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cerr << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

const int maxn = (int)2e5 + 5;

int n;
uli ans = (uli)1e18;
uli X, x[maxn];

li calc(uli k) {
    uli k1 = 0; 
    uli cnt = 1;
    uli cur_ans = (n + k) * X;
    for (int i = n - 1; i >= 0; --i) {
        uli len = x[i] - (i > 0 ? x[i - 1] : 0);
        if (k1 < k) {
            ++k1;
        } else {
            k1 = 1;
            ++cnt;
        }
        if (cnt == 1)
            cur_ans += x[i];
        cur_ans += k1 * (cnt + 1) * (cnt + 1) * len;
        if (cnt > 1)
            cur_ans += (k - k1) * cnt * cnt * len;
    }
//    cout << (ld)cur_ans / 1e18 << endl;
//    cout << k << " " << cur_ans << endl;
    ans = min(ans, cur_ans);
    return cur_ans;
}

void solve(bool __attribute__((unused)) read) {
	cin >> n >> X;
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
//        x[i] = (uli)1e9 - n + i;
//        x[i] = (li)rand() * 10000;
    }
    int l = 1, r = n;
    while (l < r) {
        int m = (l + r) / 2;
        uli ans1 = calc(m);
        uli ans2 = calc(m + 1);
        if (ans1 > ans2)
            l = m + 1;
        else
            r = m;
    }
    calc(l);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int x,k,d;
	cin>>x>>k>>d;
	// int now=x;
	// rep(i,k){
	// 	if(now>0) now-=d;
	// 	else now+=d;
	// }
	// cout<<"answer="<<abs(now)<<endl;


	if(x==0){
		if(k%2==0)cout<<0<<endl;
		else cout<<d<<endl;
		return 0;
	}

	int dist=abs(x);
	int g=(x/dist)*(dist%d);

	int cnt=abs(x-g)/d;


	if(cnt>k){
		if(x>0) g+=(cnt-k)*d;
		else g-=(cnt-k)*d;
		cout<<abs(g)<<endl;
		return 0;
	}else if(cnt==k){
		cout<<abs(g)<<endl;
		return 0;
	}else{
		// assert(0);
		// printf("k=%lld\n",k);
		// printf("cnt=%lld\n",cnt);
		// printf("g=%lld\n",g);
		k-=cnt;
		k%=2;
		if(k==0){
			cout<<abs(g)<<endl;
		}else{
			if(x>0) g-=d;
			else g+=d;
			cout<<abs(g)<<endl;

		}



	}
	return 0;
}



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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0(i, n) for (i = 0; i < (n); i++)
#define f1(i, n) for (i = 1; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
template< typename T>
T modpow(T number, T power, T mod_value);
//*/

//int row, column;
//int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
//int dx[4] = {1,  0, -1, 0};
//int dy[4] = {0, -1,  0, 1};
//ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        ll n, i, ans = 0;
        string s;

        cin >> n >> s;
        string a;a.PB('A');

        while(s.length() > 0)
        {
            if (a.back() != s.back())
            {
                a.PB(s.back());
            }
            s.pop_back();
        }
        cout << a.length() -1 << endl;
    	//cout << "Test #" << test_case << ": ";
    	//cout << "Case " << test_case << ": ";
    }
    return 0;
}


template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
template< typename T>
T modpow(T number, T power, T mod_value)
{
    if (power == 0)
        return 1%mod_value;
    ll u = modpow(number,power/2,mod_value);
    u = (u*u)%mod_value;
    if (power%2 == 1)
        u = (u*number)%mod_value;
    return u;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    cout << d.size() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    
    vector<int> v(n);
    for(int i=0;i<n;i++)
    cin>>v[i];
    
    sort(v.begin(),v.end());
    int temp=(v[n-1]-v[0]);
    cout<<temp;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int ABS(int a){
	return a >= 0 ? a : -a;
}

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

int main(){
	int A, B, C, D, H, W, g;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	H = ABS(A - C);
	W = ABS(B - D);
	g = GCD(H, W);
	H /= g;
	W /= g;
	printf("%d\n", g * (H + W - 1));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

long long n, ans, r, g, b;
char s[4010];

int main() {
    read(n);    std::cin >> s + 1;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'R')    ++r;
        if (s[i] == 'B')    ++b;
        if (s[i] == 'G')    ++g;
    }
    ans = r * b * g;
    for (int len = 1; len <= n; ++len) {
        for (int i = 1; i <= n; ++i) {
            int j = i + len, k = i + len + len;
            if (k > n)  break;
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k])   --ans;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
string s;
int n;
unordered_set<string>st;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		st.insert(s);
	}
	cout << (int)st.size() << endl;
	return 0;
}

Measured memory_bytes: 17704
#include <stdio.h>
#define NUM 250

struct kk {
  int key;
  int parent;
  int right;
  int left;
};

struct kk A[NUM];

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

  for(i = 1;i <= H;i++){
    scanf("%d",&A[i].key);
    A[i].parent = A[i/2].key;
    if(i%2 == 0) A[i/2].left = A[i].key;
    if(i%2 == 1) A[i/2].right = A[i].key;
  }


  for(i = 1;i <= H;i++){
    printf("node %d: key = %d, ",i,A[i].key);
    if(A[i].parent != NULL) printf("parent key = %d, ",A[i].parent);
    if(A[i].left != NULL) printf("left key = %d, ",A[i].left);
    if(A[i].right != NULL) printf("right key = %d, ",A[i].right);
    printf("\n");
  }

  return 0;
}
  



Measured memory_bytes: 2044
#include <iostream>

using namespace std;
const int MAXW = 210;
const int MAXH = 210;

int h, w;
int c[10][10];
int a[MAXH][MAXW];

int dist[10][10];

void solve() {
  for (int i=0;i<10;i++) {
    for (int j=0;j<10;j++) {
      dist[i][j] = c[i][j];
    }
  }

  for (int k=0;k<10;k++) {
    for (int i=0;i<10;i++) {
      for (int j=0;j<10;j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int sum = 0;
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      if (a[i][j] != -1) {
        sum += dist[a[i][j]][1];
      }
    }
  }
  cout << sum << endl;
}

int main() {
  cin >> h >> w;
  for (int i=0;i<10;i++) {
    for (int j=0;j<10;j++) {
      cin >> c[i][j];
    }
  }
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      cin >> a[i][j];
    }
  }
  solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define pb push_back
#define in(a) int a;cin>>a;
#define in2(a,b)in(a)in(b)
#define out(x) cout<<x<<endl;
#define out2(x,y) cout<<x<<" "<<y<<endl;

int32_t main()
{
    in2(n,k);
    int a[n+1];
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    }
    int dp[n+1]={0};
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++){
    	int num=i-k;
    	if(num<=0){
    		num=1;
    	}
    	int temp=INT_MAX;
    	for(int j=i-1;j>=num;j--){
    		int dist=dp[j]+abs(a[j]-a[i]);
    		if(dist<temp){
    			temp=dist;
    		}
    	}
    	dp[i]=temp;
    }
    out(dp[n]);
}

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

int main() {
    int n, m, i, sum = 0;
    cin >> n >> m;
    int lst[m];
    for(i = 0; i < m; i++){
        cin >> lst[i];
        sum += lst[i];
    }
    if(sum <= n) cout << n - sum << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define F first
#define S second
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define N 1000005
#define BB(V) V[V.size()-2]
#define ex(V) return printf(V),0
using namespace std;
ll sum[200005];
ll calc(int gs,int ge,int x){
	return abs(sum[x-1]-sum[gs-1]-sum[ge]+sum[x-1]);
}
pii TS(int s,int e,int gs,int ge){
	if(s==e)return {sum[s-1]-sum[gs-1],sum[ge]-sum[s-1]};
	if(s+1==e){
		if(calc(gs,ge,s)<calc(gs,ge,e))return {sum[s-1]-sum[gs-1],sum[ge]-sum[s-1]};
		return {sum[e-1]-sum[gs-1],sum[ge]-sum[e-1]};
	}
	int m1=(2*s+e)/3,m2=(s+2*e)/3;
	if(calc(gs,ge,m1)<calc(gs,ge,m2))return TS(s,m2-1,gs,ge);
	return TS(m1+1,e,gs,ge);
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		sum[i]=sum[i-1]+t;
	}
	ll mn=INF;
	for(int i=2;i<n-1;i++){
		pii t1=TS(2,i,1,i),t2=TS(i+2,n,i+1,n);
		mn=min(mn,max(max(t1.F,t1.S),max(t2.F,t2.S))-min(min(t1.F,t1.S),min(t2.F,t2.S)));
	}
	printf("%lld",mn);
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	string s;
	cin >> s;
	array<int, 4> arr;
	for (int i = 0; i < 4; i++) {
		arr[i] = stoi(s.substr(i, 1));
	}

	for (int i = 0; i < 8; i++) {
		bitset<3> ope(i);
		int total = arr[0];
		for (int j = 0; j < 3; j++) {
			if (ope[j]) {
				total -= arr[j + 1];
			}
			else {
				total += arr[j + 1];
			}
		}
		if (total == 7) {
			cout << s.substr(0,1) + (ope[0] ? "-" : "+") + s.substr(1, 1) + (ope[1] ? "-" : "+") + s.substr(2, 1) + (ope[2] ? "-" : "+") + s.substr(3, 1) + "=7" << endl;
			return 0;
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )

int RT[24][6] = {
    {1,2,3,4,5,6}, {1,3,5,2,4,6}, {1,5,4,3,2,6}, {1,4,2,5,3,6},
    {4,2,1,6,5,3}, {4,1,5,2,6,3}, {4,5,6,1,2,3}, {4,6,2,5,1,3},
    {6,2,4,3,5,1}, {6,4,5,2,3,1}, {6,5,3,4,2,1}, {6,3,2,5,4,1},
    {3,2,6,1,5,4}, {3,6,5,2,1,4}, {3,5,1,6,2,4}, {3,1,2,5,6,4},
    {5,1,3,4,6,2}, {5,3,6,1,4,2}, {5,6,4,3,1,2}, {5,4,1,6,3,2},
    {2,1,4,3,6,5}, {2,4,6,1,3,5}, {2,6,3,4,1,5}, {2,3,1,6,4,5}
};

int T[3][3], F[3][3], puzzle[27];
set<int> solved;

int getRight(){
    int sum = 0;
    for ( int i = 2; i < 27; i += 3 ) sum += RT[puzzle[i]][2];
    return sum;
}

void recursive( int pos ){
    if ( pos == 27 ){ solved.insert(getRight()); return; }
    int i = (pos%9)/3;
    int j = (pos%9)%3;
    int k = pos/9;

    rep(r, 24){
        if ( i == 0 && T[3-k-1][j] && T[3-k-1][j] != RT[r][0] ) continue;
        if ( k == 0 && F[i][j] && F[i][j] != RT[r][1] ) continue;
        if ( i && RT[r][0] + RT[puzzle[k*9+(i-1)*3+j]][5] != 7 ) continue;
        if ( k && RT[r][1] + RT[puzzle[(k-1)*9+i*3+j]][4] != 7 ) continue;
        if ( j && RT[r][3] + RT[puzzle[k*9+i*3+(j-1)]][2] != 7 ) continue;
        puzzle[pos] = r;
        recursive( pos+1 );
    }
}

void compute(){
    solved.clear();
    recursive(0);
    if ( solved.size() == 0 ) {	cout << 0 << endl; return; }
    set<int>::iterator p = solved.begin();
    cout << *p;
    for ( p++; p != solved.end(); p++ ) cout << " " << *p;
    cout << endl;
}

main(){
    int tcase; cin >> tcase;
    rep(t, tcase){
      rep(i, 3) rep(j, 3) cin >> T[i][j];
      rep(i, 3) rep(j, 3) cin >> F[i][j];
      compute();
    }
}

Measured memory_bytes: 0
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <tuple>
using namespace std;

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

  if (N == 0 || N == 1) {
    cout << N << endl;
    return 0;
  }

  stack<int> items;
  while (N != 0) {
    if (N % 2 == 1 || N % 2 == -1) {
      items.push(1);
      --N;
    } else {
      items.push(0);
    }

    N /= -2;
  }

  while (!items.empty()) {
    cout << items.top();
    items.pop();
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
//import javafx.util.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
	public static void main (String[] args)  {
//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		int t = Integer.parseInt(br.readLine());
//		while(t-->0)
//		{
//		  int totItems = Integer.parseInt(br.readLine()); //no.of items.
//		  int n = Integer.parseInt(br.readLine()); //capacity of knapsack.
//		  int val[] = new int[totItems]; //values of items.
//		  int wt[] = new int[totItems]; //weights of items.
//		  
//		  
//		  for(int i=0;i<totItems;i++){
//            String s1[]= br.readLine().split(" ");
//		    val[i] = Integer.parseInt(s1[i]);
//            wt[i] = Integer.parseInt(s1[i]);
//          }
		    
		   // String s2[]= br.readLine().split(" ");
		//  for(int i=0;i<;i++)
		  //  wt[i] = Integer.parseInt(s2[i]);
		Scanner sc =new Scanner(System.in);
		int totItems=sc.nextInt();
		int n=sc.nextInt();
		int val[]=new int [totItems];
		int wt[]=new int [totItems];
		for(int i=0;i<totItems;i++) {
		 wt[i]=sc.nextInt();
		val[i]=sc.nextInt();
		}
		    findMaxProfit(totItems,n,val,wt);
		  
		
	}
	
	static void findMaxProfit(int totItems,int n,int val[],int wt[])
	{
	    long dp[][] = new long[n+1][totItems+1];
	   //IMP:-Top X-axis - > Capacity from 0....to n.    Draw graph to visualise.
	    //    Y-axis - > Items from 0...to totItems.
	    
	    //First row and first column is filled with 0's.
	    
	    for(int i=1;i<=n;i++)
	    {
	        for(int j=1;j<=totItems;j++)
	        {
	           //If the weight of the item is less than or equal to the capacity.
	            if(wt[j-1]<=i) {
	   /*IMP:-  Take the max of(val of cur_item + (DP answer -> [cur_capacity 
	            -weight of cur_item][above item/cell]) 
	                                AND 
	            (DP answer -> dp[same capacity][above item/cell] */
 
	            dp[i][j] = Math.max(val[j-1]+dp[i-wt[j-1]][j-1] , dp[i][j-1]);   }
	            
	            else
	            dp[i][j] = dp[i][j-1];
	        }
	    }
	    //Gives the max value obtained for the capacity n considering all the items.
	    System.out.println(dp[n][totItems]) ;  
	}
}

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

int main() {
  int  a , b , c , d ; 
  cin >> a >> b >> c >> d ; 
  
  if(max(abs(b - a) , abs(c - b)  ) <= d){
    cout << "Yes" << endl ; 
  }
  else if( abs(c - a) <= d){
    cout << "Yes" << endl ; 
  }
  
  else{
    cout << "No" << endl ; 
  }
  
}

Measured memory_bytes: 3608
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    if(a <= b){
        if(n >= 2)
            cout << (n - 2) * (b - a) + 1;
        else if(a == b){
            cout << 1;
        }else{
            cout << 0;
        }
    }else{
        cout << 0;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

const int MAXN = 1.1e5;
int N;
int V[3][MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int z = 0; z < 3; z++) {
		for (int i = 0; i < N; i++) {
			cin >> V[z][i];
		}
		sort(V[z], V[z] + N);
	}

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		int a = int(lower_bound(V[0], V[0] + N, V[1][i]) - V[0]);
		int c = N - int(upper_bound(V[2], V[2] + N, V[1][i]) - V[2]);
		ans += 1ll * a * c;
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1408