akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,bill,i,j,sum=0;
    cin>>n>>bill;
    for(i=0;i<=n;i++)
    {
        for(j=i;j<=n;j++)
        {
            sum=i*10000+(j-i)*5000+(n-j)*1000;
            if(sum==bill)break;
        }
        if(sum==bill)break;
    }
    if(i>n)cout<<"-1 "<<"-1 "<<"-1"<<endl;
    else cout<<i<<" "<<j-i<<" "<<n-j<<endl;
    return 0;
}

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

using namespace std;

int N,M;
vector<vector<int>>v;
vector<bool>f;
int nummmmm;

void dfs(int p)
{
    bool end = true;
    for(int i = 0; i < N; i++)
    {
        if(!f[i] && i != p) end = false;
    }
    if(end) 
    {
        nummmmm++;
        return;
    }
    f[p] = true;
    for(auto np:v[p])
    {
        if(f[np]) continue;
        dfs(np);
    }
    f[p] = false;
}

int main()
{
    cin >> N >> M;
    v.resize(N);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        cin >> a >> b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    nummmmm = 0;
    f.assign(N,false);
    dfs(0);
    cout << nummmmm << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>

int main() {
	int a, b, c;
  	std::cin >> a;
  	std::cin >> b;
  	std::cin >> c;
  
  	if (a == b && b == c) {
    	std::cout << "Yes" << std::endl;
    } else {
    	std::cout << "No" << std::endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#include <utility>

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

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

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

ll n, a[200005], b[200005]{}, c[200005]{}, ans = 0;

int main() {
    cin >> n;
    REP(i, n) cin >> a[i];
    REP(i, n) {
        if (a[i] > i || (i > 0 && a[i] - 1 > a[i - 1])) {
            cout << -1 << endl;
            return 0;
        }
    }
    FOR(i, 1, n) {
        if (a[i] - a[i - 1] == 1) {
            ans++;
        } else {
            ans += a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

    vector<int64_t> a(N), b(N);
    for(int i = 0; i < N; ++i) cin >> a[i];
    for(int i = 0; i < N; ++i) cin >> b[i];

    int64_t ans = 0;
    for(int i = 0; i <= 29; ++i){
        vector<int64_t> a2(N);
        vector<int64_t> b2(N);
        int64_t T = 1 << i;
        for(int j = 0; j < N; ++j){
            a2[j] = a[j] % (2 * T);
            b2[j] = b[j] % (2 * T);
        }
        sort(b2.begin(), b2.end());
        bool res = false;
        for(int j = 0; j < N; ++j){
            auto l = lower_bound(b2.begin(), b2.end(), T * 2 - a2[j]);
            auto r = lower_bound(b2.begin(), b2.end(), T - a2[j]);
            res ^= (l - r) & 1;
            auto l2 = lower_bound(b2.begin(), b2.end(), T * 4 - a2[j]);
            auto r2 = lower_bound(b2.begin(), b2.end(), T * 3 - a2[j]);
            res ^= (l2 - r2) & 1;
        }
        ans |= res << i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6552
class Area:
    def __init__(self,m,x,y):
        self.m = m
        self.f_W = False
        self.f_B = False
        self.side = 0
        self.count = 0
        self.standardx = x
        self.standardy = y
        self.check(x,y)
        self.getSide()

    def check(self,x,y):
        if(y<0 or y >= len(m) or x<0 or x>=len(m[0])):
            return
        c = self.m[y][x]
        if(c!=0):
            if(c==1):
                self.f_B=True
            if(c==2):
                self.f_W=True
            return
        else:
            if(c==0):
                self.m[y][x]=3
                self.count += 1
                self.check(x-1,y)
                self.check(x+1,y)
                self.check(x,y-1)
                self.check(x,y+1)

    def getSide(self):
        if(self.f_B and self.f_W):
            self.side = 0
        elif(self.f_B):
            self.side = 1
        elif(self.f_W):
            self.side = 2
        else:
            self.side = 0
        return self.side
            
import sys
limit = 100000
sys.setrecursionlimit(limit)


while True:
    w,h = map(int,raw_input().split())
    if(not w) :
        break
    m = []
    for i in range(h):
        m.append([])
        l = raw_input()
        for ii in range(w):
            dic = {".":0,"B":1,"W":2}
            m[i].append(dic[l[ii]])
    B = 0
    W = 0
    for i,l in enumerate(m):
        for ii,c in enumerate(l):
            if(c==0):
                a = Area(m,ii,i)
                if(a.getSide() == 1):
                    B += a.count
                elif(a.getSide() == 2):
                    W += a.count
    print B,W

Measured memory_bytes: 6156
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	map <long long int, int> M;
	long long int curr = 0, ans = 0;
	M[0] = 1;
	for (int i = 0; i < n; ++i)
	{
		int x;
		scanf("%d", &x);
		curr+=x;
		ans+=M[curr];
		M[curr]++;
		//cout<<" curr = "<<curr<<"  "<<" M[curr] = "<<M[curr]<<endl;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 12800
MOD = 10**9+7
N = int(input())
A = [int(i) for i in input().split()]
max_length = len(bin(max(A)))-2
ans = 0
for n in range(max_length):
    c0 = 0
    c1 = 0
    for i, a in enumerate(A):
        if a & 1:
            c1 += 1
        else:
            c0 += 1
        A[i] >>= 1
    ans += c0*c1*(2**n)
    ans %= MOD
print(ans)


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

int main() {
  int x, n, p;
  vector<int> b(201);
  cin >> x >> n;
  for (int i = 0; i < n; i++) {
    cin >> p;
    b.at(100 - x + p) = 1;
  }
  for (int i = 0; i < 100; i++){
    if (b.at(100 - i) == 0) {
      cout << x - i << endl;
      break;
    }
    else if (b.at(100 + i) == 0){
      cout << x + i << endl;
      break;
    }
  }
}


Measured memory_bytes: 3644
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  string S;

  cin >> S;

  if (S[1] == 'R') cout << "ABC" << endl;
  if (S[1] == 'B') cout << "ARC" << endl;

  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

int c[101][101];

void solve()
{
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    REP0 (i, N)
    {
        cin >> a[i];
    }

    int curr_col = 1;
    int curr_cnt = 0;

    REP0 (h, H)
    {
        if (h % 2)
        {
            for (int w = 0; w < W; w++)
            {
                c[h][w] = curr_col;
                curr_cnt++;
                if (curr_cnt == a[curr_col - 1])
                {
                    curr_col++;
                    curr_cnt = 0;
                }
            }
        }
        else
        {
            for (int w = W - 1; w >= 0; w--)
            {
                c[h][w] = curr_col;
                curr_cnt++;
                if (curr_cnt == a[curr_col - 1])
                {
                    curr_col++;
                    curr_cnt = 0;
                }
            }
        }
    }

    REP0 (h, H)
    {
        REP0 (w, W)
        {
            cout << c[h][w];
            if (w != W - 1)
            {
                cout << ' ';
            }
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}



int main()
{
    double A,B,H,M,Ltheta,Stheta,theta,ans;
    cin >> A >> B >> H >> M;

    double pi = 3.141592653589793;

    Stheta = H * 30 + M * 0.5;
    Ltheta = M * 6;
 
    theta =abs(Stheta-Ltheta);

    if(theta>180) theta= 360-theta;

    ans = sqrt(A*A + B*B - 2*A*B*cos(theta/180*pi));

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


    return 0;

}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

int a[100001];
int dp[100001];
int n;

int fun(int ind)
{
    if(ind==(n-1))
    return 0;
    else if(dp[ind]!=-1)
    return dp[ind];
    int left=abs(a[ind]-a[ind+1])+fun(ind+1);
    int right=INT_MAX;
    if(ind+2<n)
    {
        right=abs(a[ind]-a[ind+2])+fun(ind+2);
    }
    return dp[ind]=min(left,right);
}
void solve()
{
    //int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int res=fun(0);
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9048
import sys
#input = sys.stdin.buffer.readline

def main():
    N = int(input())
    S = input()
    col = [[0 for _ in range(N+1)] for _ in range(3)]
    
    for i,st in enumerate(S):
        if st == "R":
            col[0][i+1] += 1
        elif st == "G":
            col[1][i+1] += 1
        else:
            col[2][i+1] += 1

    for i in range(3):
        for j in range(N):
            col[i][j+1] += col[i][j]
    
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            if S[i] == S[j]:
                continue
            elif (S[i] == "R" and S[j] == "G") or (S[j] == "R" and S[i] == "G"):
                ans += col[2][-1]-col[2][j]
                if N>j+(j-i) and S[j+(j-i)] == "B":
                    ans -= 1
            elif (S[i] == "G" and S[j] == "B") or (S[j] == "G" and S[i] == "B"):
                ans += col[0][-1]-col[0][j]
                if N>j+(j-i) and S[j+(j-i)] == "R":
                    ans -= 1
            else:
                ans += col[1][-1]-col[1][j]
                if N>j+(j-i) and S[j+(j-i)] == "G":
                    ans -= 1
    
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 69544
#include <iostream>
#include<string>
using namespace std;
int main(){
    string N;
    cin>>N;
    for(int i=0; i<2; i++){
        if(N[i]==N[i+1]&&N[i]==N[i+2]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }   
        cout<<"No"<<endl;
        return 0;
        
       
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

int main(){

    double A,B;
    int A_min, A_max, B_min, B_max;
    int ans = -1;

    std::cin >> A >> B;

    A_min = (int)round(ceil(A/0.08)); 
    A_max = (int)round(ceil((A+1.0)/0.08))-1;
    B_min = (int)round(ceil(B/0.10)); 
    B_max = (int)round(ceil((B+1.0)/0.10))-1;

    if(A_min <= B_min){
        if(A_max >= B_min){
            ans = B_min;
        }
    }else if(A_min >= B_min){
        if(B_max >= A_min){
            ans = A_min;
        }
    }

    std::cout << ans;

}

Measured memory_bytes: 3868
/* ALDS1_9_B: Maximum Heap */

#include <iostream>

void max_heapify(int H, int A[], int i) {
    int il = i * 2;
    int ir = i * 2 + 1;

    int max_i = i;
    if (il <= H && A[i] < A[il])
        max_i = il;
    if (ir <= H && A[max_i] < A[ir])
        max_i = ir;

    if (max_i != i) {
        std::swap(A[i], A[max_i]);
        max_heapify(H, A, max_i);
    }
}

void build_max_heap(int H, int A[]) {
    for (int i = H / 2; i >= 1; i--)
        max_heapify(H, A, i);
}

int main() {
    std::ios::sync_with_stdio(false);

    int H;
    std::cin >> H;

    int heap[H + 1];
    for (int i = 1; i <= H; i++)
        std::cin >> heap[i];

    build_max_heap(H, heap);

    for (int i = 1; i <= H; i++)
        std::cout << " " << heap[i];
    std::cout << std::endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int n,x[200],k,ans;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>x[i];
    for(int i=1;i<=n;i++){
        ans += min(x[i],k-x[i]);
    }
    ans*=2;
    cout<<ans<<newl;
}


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

static const int MAX_B = 4;
static const int MAX_F = 3;
static const int MAX_R = 10;

int main()
{

	int n, b, f, r, v;
	int OH[MAX_B][MAX_F][MAX_R];

	memset( OH, 0, sizeof( OH ) );

	cin >> n;
	for( int i = 0; i < n; i++ ) {

		cin >> b >> f >> r >> v;
		OH[b - 1][f - 1][r - 1] += v;

	}

	for( int i = 0; i < MAX_B; i++ ) {
		for( int j = 0; j < MAX_F; j++ ) {
			for( int k = 0; k < MAX_R; k++ ) cout << " " << OH[i][j][k];
			cout << endl;
		}
		if( i < MAX_B - 1 ) {
			for( int k = 0; k < MAX_R * 2; k++ ) cout << "#";
			cout << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 1160
// ABC081B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int ans = 0;

	while (1) {
		bool t = true;
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 == 1) {
				t = false;
				break;
			}
		}
		if (t) {
			++ans;
			for (int i = 0; i < N; i++) {
				A[i] /= 2;
			}
		} else {
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	string s;
	cin >> s;
	int len = (int)(s.size());
	
	if (len == 1){
		cout << 0 << endl;
		return 0;
	}
	
	int ans = 0;
	if (s[0] == '1') ans++;
	FOR(i,1,len){
		if (i%2 == 1){
			if (s[i] == '0') ans++;
		}else{
			if (s[i] == '1') ans++;
		}
	}
	
	
	int ans_ = 0;
	if (s[0] == '0') ans_++;
	FOR(i,1,len){
		if (i%2 == 1){
			if (s[i] == '1') ans_++;
		}else{
			if (s[i] == '0') ans_++;
		}
	}
	
	cout << min(ans,ans_) << endl;
return 0;
}


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

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

    std::vector<int> A(N);
    std::vector<int> B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    std::sort(A.begin(), A.end());
    B = A;

    int left = A[0];
    int right = A[0];
    long long smallAns = 0;
    int diff;
    A.erase(A.begin() + 0);
    for (int i = 1; i < N; i++)
    {
        diff = max({abs(left - A[0]), abs(right - A[0]), abs(left - A[A.size() - 1]), abs(right - A[A.size() - 1])});
        smallAns += diff;
        if (diff == abs(left - A[0]))
        {
            left = A[0];
            A.erase(A.begin() + 0);
        }
        else if (diff == abs(right - A[0]))
        {
            right = A[0];
            A.erase(A.begin() + 0);
        }
        else if (diff == abs(left - A[A.size() - 1]))
        {
            left = A[A.size() - 1];
            A.erase(A.begin() + A.size() - 1);
        }
        else if (diff == abs(right - A[A.size() - 1]))
        {
            right = A[A.size() - 1];
            A.erase(A.begin() + A.size() - 1);
        }
    }

    left = B[B.size() - 1];
    right = B[B.size() - 1];
    long long largeAns = 0;
    B.erase(B.begin() + B.size() - 1);
    for (int i = 1; i < N; i++)
    {
        diff = max({abs(left - B[0]), abs(right - B[0]), abs(left - B[B.size() - 1]), abs(right - B[B.size() - 1])});
        largeAns += diff;
        if (diff == abs(left - B[0]))
        {
            left = B[0];
            B.erase(B.begin() + 0);
        }
        else if (diff == abs(right - B[0]))
        {
            right = B[0];
            B.erase(B.begin() + 0);
        }
        else if (diff == abs(left - B[B.size() - 1]))
        {
            left = B[B.size() - 1];
            B.erase(B.begin() + B.size() - 1);
        }
        else if (diff == abs(right - B[B.size() - 1]))
        {
            right = B[B.size() - 1];
            B.erase(B.begin() + B.size() - 1);
        }
    }

    if (smallAns > largeAns)
    {
        cout << smallAns << endl;
    }
    else
    {
        cout << largeAns << endl;
    }
}

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

ll yaku[10000005];

int main() {
  for(int i=1;i<10000005;++i){
    for(int j=1;i*j<10000005;++j){
      yaku[i*j]++;
    }
  }
  int N;
  cin>>N;
  ll ans = 0;
  for(int i=1;i<=N;++i){
    ans += i*yaku[i];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 81728
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    int slen = s.size();
    int tlen = t.size();


    string ans(slen, 'z');


    bool ansok = false;
    for (int shift = 0; shift <= slen-tlen; shift++)
    {
        string tans(slen, 0);
        bool isok = true;
        for (int si = 0; si < slen; si++)
        {

            char x = '?';
            if (si >= shift && si < shift+tlen){
                x = t[si-shift];
            }

            if(s[si] == '?' && x == '?'){
                tans[si] = 'a';
            } else if (s[si] != '?' && x != '?') {
                if (s[si] != x) {isok = false; break;}
                else tans[si] = x;
            } else {
                if (s[si] == '?') tans[si] = x;
                else tans[si] = s[si];
            }
        }
        if (isok){
            //cout << tans << endl;
            ansok = true;
            if (ans > tans){
                ans = tans;
            }
        }
    }
    if (ansok) cout << ans << endl;
    else cout << "UNRESTORABLE" << endl;
    

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();

		int cnt = 0;
		for (int i = 1; i <= 100; i++) {
			if (A % (101-i) == 0 && B % (101-i) == 0) {
				cnt++;
				if (cnt == K) {
					System.out.println(101-i);
					return;
				}
			}
		}

	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
    string s;
    cin>>s;
    lli ans = 0;
    lli n = s.length();
    const lli N = 1000005;
    vll cnt(N, 0);
    lli carry = 0;
    loopb(i, n-1, 0){
        lli num = (s[i]-'0') + carry;
        if(num < 5){
            cnt[n-i-1] += num;
            carry = 0;
        }
        else{
            // cnt[n-i]++;
            cnt[n-i-1] += (10-num);
            if(num == 5){
                if(s[i-1] < '5')
                    carry = 0;
                else
                    carry = 1;
            }
            else
                carry = 1;
        }
    }
    if(carry == 1)
        ans++;
    loop(i, 0, N)
        ans += abs(cnt[i]);
    cout<<ans<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll n;
	cin>>n;
	vll A(n);
	for(int i=0;i<n;i++)
		cin>>A[i];
	ll m;
	cin>>m;
	for(int i=0;i<m;i++){
		ll a,b; 
		cin>>a>>b;
		a--;
		cout<<accumulate(all(A),0)-A[a]+b<<"\n";
	}

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
    int n;
    cin >> n;
    int hour = n/(60*60);
    int minute = (n-hour*(60*60))/60;
    int second = n-hour*(60*60)-minute*60;
    cout << hour << ":" << minute << ":" << second << endl;
    return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<deque>
#include<unordered_map>
using namespace std;




long long int getMin(long long int a, long long int b){
    if(a<b)
        return a;
    return b;
}

int main(){
    int n;
    int k;
    cin>>n;
    cin>>k;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    long long int ans[n+1];
    ans[0]=100;
    ans[1]=0;
    ans[2]=abs(h[0]-h[1]);
    for(int i=3;i<=n;i++){
        ans[i] = INT_MAX;
        for(int j=1;j<=k;j++){
            if(i-j>=1){
                ans[i] = getMin(ans[i],ans[i-j]+abs(h[i-j-1]-h[i-1]));
            }
            
        }
    }
    cout<<ans[n];
}






















Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	int n;
	cin>>n;
	int a[n];
	in(a,n);
	int all=0;
	rep(i,n)all=all^a[i];
	rep(i,n){
		cout<<(all^a[i])<<" ";
	}
	return 0;
}

Measured memory_bytes: 4220
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#define ll long long
using namespace std;

int n, m, ans = 0;
bool a[8][8] = {}, b[8] = {};


int dfs(int x, int t) {
	if (t == n - 1) {
		for (int i = 0; i < n; i++) {
			if (!b[i]) {
				return ans;
			}
		}
		return ans += 1;
	}
	for (int i = 0; i < n; i++) {
		if (a[x][i] && !b[i]) {
			b[i] = true;
			ans = dfs(i, t + 1);
			b[i] = false;
		}
	}
	return ans;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		tmp1--; tmp2--;
		a[tmp1][tmp2] = a[tmp2][tmp1] = true;
	}
	b[0] = true;
	cout << dfs(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}


void solve(){
    ll n,W;
    cin>>n>>W;
    Vec<1,ll> w(n),v(n);
    f(i,0,n){
        cin>>w[i]>>v[i];
    }
    Vec<2,ll> dp(n+1,W+1,0);
    dp[0][w[0]] = v[0];
    f(i,1,n){
        fo(j,0,W){
            dp[i][j] = dp[i-1][j];
            if(j-w[i]>=0)
            dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]]+v[i]);
        }
    }
    ll mx = 0;
    fo(j,0,W){
        mx = max(mx, dp[n-1][j]);
    }
    cout<<mx<<endl;
    return ;
}
int main()

{
    IO;
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase


Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
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; }

// MOD
const int MOD = 1000000007;

// 入力
int H, W;
vector<string> a;

// DP テーブル
int dp[1100][1100] = {0};

// add
void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

int main() {
    cin >> H >> W;
    a.resize(H);
    for (int i = 0; i < H; ++i) cin >> a[i];

    // DP 初期化: すでに配列全体が 0 に初期化されているので OK

    // DP 初期条件
    dp[0][0] = 1;

    // DP ループ
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (i+1 < H && a[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
            if (j+1 < W && a[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1000005

//Suffix_Array
//O(|T|log|S|) S??????????????????T????????????????????????????´¢
#define rank A
int n,Len;
int rank[MAX_N+1];
int tmp[MAX_N+1];

//(rank[i],rank[i+k])??¨(rank[j],rank[j+k])?????????
bool compare_sa(int i,int j){
  if(rank[i]!=rank[j])return rank[i]<rank[j];
  int ri=i+Len<=n?rank[i+Len]:-1;
  int rj=j+Len<=n?rank[j+Len]:-1;
  return ri<rj;
}

//?????????S?????\?°??????????????§????
void construct_sa(string S,int *sa){
  n=S.length();
  //?????????????????????????????????????????????????????????
  for(int i=0;i<=n;i++){
    sa[i]=i;
    rank[i]=i<n?S[i]:-1;
  }
  //k????????????????????????????????????????????¨???????????????2k????????§?????????
  for(Len=1;Len<=n;Len*=2){
    sort(sa,sa+n+1,compare_sa);
    //?????£??????tmp????¬?????????????????¨?????????????rank?????£??\
    tmp[sa[0]]=0;
    for(int i=1;i<=n;i++)
      tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
    for(int i=0;i<=n;i++)rank[i]=tmp[i];
  }
}

//S??????????????????T????????????????????????????´¢??????
bool contain(string S,int *sa,string T){
  int left=0,right=S.length();
  while(right-left>1){
    int mid=(left+right)/2;
    if(S.compare(sa[mid],T.length(),T)<0)left=mid;
    else right=mid;
  }
  return S.compare(sa[right],T.length(),T)==0;
}

string t,p;
int q,sa[MAX_N];
int main(){
  cin>>t;
  construct_sa(t,sa);
  cin>>q;
  while(q--){
    cin>>p;
    if(contain(t,sa,p))cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 16612
#include<iostream>

using namespace std;

int main(void)
{

	int A,B,m=1,i=0;
	 
	cin >> A >> B;
	
	if(B==1)
		i=0;

	else if(B!=1)
	{
		
		while(m<B)
		{
			
			m=m+(A-1);
			i++;
		}

	}


	cout << i << endl; 

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {

	long long n, x;
	cin >> n;

	long long mini = 1e16;
	for (int i = 0; i < 5; i++) {
		cin >> x;
		mini = min(mini, x);
	}

	long long ans = (n + mini - 1) / mini + 4;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt()
  var a = Array.fill(n)(sc.nextInt)
  var ans = 0
  for (i <- 0 until n if (i+1) % 2 == 1){
    if (a(i) % 2 == 1) ans+=1
  }
  println(ans)
}


Measured memory_bytes: 55540
#include <iostream>
#include <string>

int count[26];

int main() {
	std::string s;
	std::cin >> s;
	
	if (s.size() <= 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	int ans = 0;
	int l = 0, r = s.size() - 1;
	while (true) {
		if (r - l == 0)
			break;
		if (r - l == 1) {
			if (s[l] != s[r]) {
				if (s[l] != 'x' && s[r] != 'x') {
					std::cout << -1 << std::endl;
					return 0;
				}

				++ans;
			}

			break;
		}

		if (s[l] == 'x' && s[r] != 'x')
			++l, ++ans;
		else if (s[l] == 'x' && s[r] == 'x')
			++l, --r;
		else if (s[l] != 'x' && s[r] == 'x')
			--r, ++ans;
		else if (s[l] != s[r]) {
			std::cout << -1 << std::endl;
			return 0;
		}
		else
			++l, --r;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <ctime>
#include <cstring>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#define Pr pair<int,int>
#define fread(ch) freopen(ch,"r",stdin)
#define fwrite(ch) freopen(ch,"w",stdout)

using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
const int mod = 1e4+7;

Pr pr[112345];
map <Pr,bool> mp;

int dir[][9] = {{ 0, 0, 0,-1,-1,-1,-2,-2,-2},
                { 0,-1,-2, 0,-1,-2, 0,-1,-2}};

LL h,w;

bool in(int x,int y)
{
    return x >= 3 && y >= 3 && x <= h && y <= w;
}

int main()
{
    int n;

    scanf("%lld%lld%d",&h,&w,&n);

    for(int i = 0; i < n; ++i)
    {
        scanf("%d%d",&pr[i].first,&pr[i].second);
        mp[Pr(pr[i].first,pr[i].second)] = 1;
    }

    LL cnt[10];

    memset(cnt,0,sizeof(cnt));
    for(int i = 0; i < n; ++i)
    {
        for(int k = 0; k < 9; ++k)
        {
            int x = pr[i].first-dir[0][k];
            int y = pr[i].second-dir[1][k];

            if(!in(x,y)) continue;

            //printf("%d %d:\n",x,y);

            int tmp = 0;
            bool f = 1;
            bool ft = 1;
            for(int j = 0; j < 9; ++j)
            {
                int xx = x + dir[0][j];
                int yy = y + dir[1][j];

                if(mp.count(Pr(xx,yy)))
                {
                    if(ft && (xx != pr[i].first || yy != pr[i].second))
                    {
                        f = 0;
                        break;
                    }
                    ft = 0;
                    tmp++;
                }
                //printf("%d %d %d\n",xx,yy,mp[Pr(xx,yy)]);
            }

            //printf("%d\n",tmp);
            if(f)
            cnt[tmp]++;
        }
    }

    LL ans = h*w;

    if(w >= 4 && h >= 4) ans -= 2*h+2*w-4;
    else if(w >= 4) ans = w-2;
    else if(h >= 4) ans = h-2;
    else ans = 1;

    for(int i = 1; i <= 9; ++i)
        ans -= cnt[i];

    printf("%lld\n",ans);
    for(int i = 1; i <= 9; ++i)
    {
        printf("%lld\n",cnt[i]);
    }

    return 0;
}


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

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

    if (t.size() > s.size()) {
        std::cout << "UNRESTORABLE" << std::endl;
        return 0;
    }

    for (int i = s.size() - t.size(); i >= 0; i--) {
        // std::cout << i << std::endl;
        if (std::equal(s.begin() + i, s.begin() + i + t.size(), t.begin(), [](auto a, auto b) {
            return a == '?' || a == b;
        })) {
            for (int j = 0; j < t.size(); j++) s[i + j] = t[j];
            for (int j = 0; j < s.size(); j++) if (s[j] == '?') s[j] = 'a';
            std::cout << s << std::endl;
            return 0;
        }
    }

    std::cout << "UNRESTORABLE" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N;
ll a[401];
ll rui[402]={};
ll dp[401][401];
int main(){
	scan(N);
	rep(i,N){
		scan(a[i]);
		rui[i+1]=rui[i]+a[i];
	}
	fill(dp[0],dp[401],INFl);
	rep(i,N) dp[i][i+1]=0;
	rep(i,N-1) dp[i][i+2]=rui[i+2]-rui[i];
	for(int k=3;k<=N;k++){
		for(int i=0;i<=N-k;i++){
			for(int j=1;j<k;j++){
				dp[i][i+k]=min(dp[i][i+k],dp[i][i+j]+dp[i+j][i+k]+rui[i+k]-rui[i]);
			}
		}
	}
	/*for(int k=1;k<=N;k++){
		for(int i=0;i<=N-k;i++){
			printf("dp[%d][%d]:%lld\n",i,i+k,dp[i][i+k]);
		}
	}*/
	prin(dp[0][N]);
	return 0;
}


Measured memory_bytes: 1536
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

string S;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> S;
    solve();
}

// |S| = 3
// S の各文字は S または R である

// string S
// 天気が雨である日が連続していた最大の日数を出力せよ。
void solve(){
    ll ans=0;
    ll cnt=0;
    rep(i,3){
        if(S[i]=='R')cnt++;
        else cnt=0;
        chmax(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef unsigned long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


int main(){

    ll R, G , B, N;
    cin >> R >> G >> B >> N;

    ll ans = 0;
    for(ll r = 0; r <= N/R; r++){
        for(ll g = 0; g <= N/G; g++){
            if(r*R + g*G <= N){
                if( (N - r*R - g*G)%B == 0) ans++;
            } 
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

const int MAXN = 1e5 + 10;
int n, m, first[MAXN], tot, d[MAXN], s, t;

struct edge { int from, v, w; } e[20 * MAXN];
struct Node
{
    int x, d;
    bool operator <(const Node &b)const
    {
        return d > b.d;
    }
}cyc;
priority_queue<Node> q;
inline void insert(int u, int v, int w)
{
    tot++; e[tot].v = v; e[tot].w = w; e[tot].from = first[u]; first[u] = tot;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (register int i = 1; i <= n; i++)
        for (register int j = 0; j <= 9; j++)insert(i, ((i - 1) * 10 + j) % n + 1, j);
    for (register int j = 1; j <= 9; j++) insert(0, j + 1, j);
    s = 0; t = 1;
    memset(d, 0x3f, sizeof d);
    d[s] = 0; q.push((Node) { s, d[s] });
    while (!q.empty())
    {
        cyc = q.top(); q.pop();
        if (cyc.d != d[cyc.x])continue;
        register int x = cyc.x;
        for (register int i = first[x]; i; i = e[i].from)
            if (d[e[i].v] > d[x] + e[i].w)
            {
                d[e[i].v] = d[x] + e[i].w;
                q.push((Node) { e[i].v, d[e[i].v] });
            }
    }
    return cout << d[t], 0;
}

Measured memory_bytes: 15476
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, l, r, k, ans = 1e9;
ll a[200009];
void inp()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        r = max(r, a[i]);
    }
}
bool check(ll m)
{
    ll t = 0;
    for (int i = 1; i <= n; i++)
    {
        t += a[i]/m;
        if (a[i] % m == 0) t--;
        if (t > k) return false;
    }
    return (t <= k);
}
void process()
{
    sort(a+1, a+1+n);
    l = 1;
    while (l <= r)
    {
        ll m = (l+r)/2;
        if (check(m))
        {
            ans = min(ans, m);
            r = m-1;
        } else l = m+1;
    }
    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("test.inp","r", stdin);
    inp();
    process();
    return 0;
}


Measured memory_bytes: 5116
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

const int INF = 1 << 30;
const int MAX_HW = 32;
int h, w, s;
int cost[MAX_HW][MAX_HW][MAX_HW][MAX_HW];
pair<int, int> dp[MAX_HW][MAX_HW][MAX_HW][MAX_HW];

pair<int, int> solve(int x1, int y1, int x2, int y2, const int sum)
{
  if (dp[y1][x1][y2][x2].first != -1)
    return dp[y1][x1][y2][x2];

  pair<int, int> res(1, s-sum+cost[y1][x1][y2][x2]);
  for (int x = x1; x < x2; ++x) {
    if (cost[y1][x1][y2][x] < sum-s || cost[y1][x+1][y2][x2] < sum-s)
      continue;
    pair<int, int> g1 = solve(x1, y1, x, y2, sum);
    pair<int, int> g2 = solve(x+1, y1, x2, y2, sum);
    if (res.first < g1.first+g2.first) {
      res.first = g1.first+g2.first;
      res.second = min(g1.second, g2.second);
    } else if (res.first == g1.first+g2.first) {
      res.second = max(res.second, min(g1.second, g2.second));
    }
  }

  for (int y = y1; y < y2; ++y) {
    if (cost[y1][x1][y][x2] < sum-s || cost[y+1][x1][y2][x2] < sum-s)
      continue;
    pair<int, int> g1 = solve(x1, y1, x2, y, sum);
    pair<int, int> g2 = solve(x1, y+1, x2, y2, sum);
    if (res.first < g1.first+g2.first) {
      res.first = g1.first+g2.first;
      res.second = min(g1.second, g2.second);
    } else if (res.first == g1.first+g2.first) {
      res.second = max(res.second, min(g1.second, g2.second));
    }
  }
  return dp[y1][x1][y2][x2] = res;
}

int main()
{
  while (scanf("%d %d %d", &h, &w, &s)) {
    if ((h|w|s) == 0)
      break;

    int sum = 0;
    vector<vector<int> > u(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
	scanf("%d", &u[i][j]);
	sum += u[i][j];
      }
    }

    memset(cost, 0, sizeof(cost));
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
	for (int y = i; y < h; ++y) {
	  for (int x = j; x < w; ++x)
	    cost[i][j][y][x] = u[y][x];
	}
      }
    }
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
	// hor
	for (int y = i; y < h; ++y) {
	  for (int x = j+1; x < w; ++x)
	    cost[i][j][y][x] += cost[i][j][y][x-1];
	}
	// ver
	for (int x = j; x < w; ++x) {
	  for (int y = i+1; y < h; ++y)
	    cost[i][j][y][x] += cost[i][j][y-1][x];
	}
      }
    }

    memset(dp, -1, sizeof(dp));
    pair<int, int> ans = solve(0, 0, w-1, h-1, sum);
    printf("%d %d\n", ans.first, ans.second);
  }
  return 0;
}

Measured memory_bytes: 12000