akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
  ll x;
  cin >> x;
  ll d = x/500;
  ll r = x%500;
  if(r > 0){
    r = r/5;
  }
  ll total = (d*1000) + r*5;
  cout << total << endl;
}     

Measured memory_bytes: 256
d, g = gets.to_s.split.map{|i|i.to_i}
s, c = Array.new(d){ gets.to_s.split.map{|i|i.to_i} }.transpose

ans = 1000
(2**d).times do |b|
  
  tot = 0
  n   = 0
  d.times do |i|
    next if 0 == b[i]
    tot += c[i] + s[i] * 100 * (i+1)
    n += s[i]
  end
  
  (0...d).reverse_each do |i|
    break if tot >= g
    next if 1 == b[i]
    score = 100 * (i+1)
    r = ( g - tot + score - 1 ) / score
    r = s[i] - 1 if r > s[i] - 1
    tot += score * r
    n   += r
  end
  
  ans = n if ans > n && tot >= g
end

puts ans


Measured memory_bytes: 1916
/*input
1000000
*/
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define T int t;cin>>t;while(t--)
using namespace std;

int sum(int n){
    return (n*(n+1))/2;
}

signed main(){
    int n;
    cin >> n;
    int ans = sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15;
    cout << ans;
}


Measured memory_bytes: 3612
#include"bits/stdc++.h"
using namespace std;

struct st {
    int L, R, D;
};

int main() {
    int N, M;
    cin >> N >> M;
    if (M == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    vector<st> S(M);
    vector<vector<pair<int, int>>> mp(N + 1);
    for (int i = 0; i < M; i++) {
        cin >> S[i].L >> S[i].R >> S[i].D;
        mp[S[i].L].push_back({ S[i].R, S[i].D });
        mp[S[i].R].push_back({ S[i].L, -S[i].D });

        if (S[i].L > S[i].R) {
            swap(S[i].L, S[i].R);
            S[i].D *= -1;
        }
    }

    sort(S.begin(), S.end(), [&](const st& lsh, const st& rhs) {
        return (lsh.L < rhs.L);
    });

    vector<long long> pos(N + 1, INT_MIN);
    vector<bool> maped(N + 1, false);

    for (int i = 1; i <= N; i++) {
        if (mp[i].size() == 0) {
            maped[i] = true;
        }
        if (maped[i]) {
            continue;
        }
        maped[i] = true;
        stack<int> sta;
        sta.push(i);
        pos[i] = 0;
        while (!sta.empty()) {
            int target = sta.top();
            sta.pop();

            for (auto p : mp[target]) {
                if (pos[p.first] != INT_MIN) {
                    if (pos[p.first] - pos[target] != p.second) {
                        cout << "No" << endl;
                        return 0;
                    }
                } else {
                    pos[p.first] = pos[target] + p.second;
                    maped[p.first] = true;
                    sta.push(p.first);
                }
            }
        }
    }

    //stack<int> sta;
    //sta.push(S[0].L);
    //pos[S[0].L] = 0;
    //while (!sta.empty()) {
    //    int target = sta.top();
    //    sta.pop();

    //    for (auto p : mp[target]) {
    //        if (pos[p.first] != INT_MIN) {
    //            if (pos[p.first] - pos[target] != p.second) {
    //                cout << "No" << endl;
    //                return 0;
    //            }
    //        } else {
    //            pos[p.first] = pos[target] + p.second;
    //            sta.push(p.first);
    //        }
    //    }
    //}

    cout << "Yes" << endl;
}

Measured memory_bytes: 12160
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let S = scan.word::<String>();
    let next = if S == "ABC" { "ARC" } else { "ABC" };

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


Measured memory_bytes: 2108
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
constexpr uint64_t mod = 1e9 + 7;

template <int N> struct Factors {
  uint64_t fcts[N + 1];
  uint64_t invs[N + 1];
 public:
  constexpr static uint64_t mod_pow(uint64_t num, uint64_t p) {
    uint64_t ans = 1;
    num %= mod;
    while (0 < p) {
      if (p & 1) {
        ans = (ans * num) % mod;
      }
      num = (num * num) % mod;
      p >>= 1;
    }
    return ans;
  }

  constexpr Factors() : fcts(), invs(){
    fcts[0] = 1;
    for (uint64_t i = 1; i <= N; i++)
      fcts[i] = i;
    for (uint64_t i = 2; i <= N; i++) {
      fcts[i] = (fcts[i] * fcts[i - 1]) % mod;
    }

    invs[N] = mod_pow(fcts[N], mod - 2);
    for (int i = N - 1; 0 <= i; i--)
      invs[i] = ((uint64_t)invs[i + 1] * (i + 1)) % mod;
  }

  uint64_t comb(uint64_t m, uint64_t n) const {
    if (m == 0 || n == 0)
      return 1;
    return (((uint64_t)fcts[m] * invs[n]) % mod) * invs[m - n] % mod;
  }

  uint64_t comb_h(uint64_t m, uint64_t n) const {
    if (m == 0 || n == 0)
      return 1;
    return (((uint64_t)fcts[n + m - 1] * invs[n]) % mod) * invs[m - 1] % mod;
  }
  void dump() const {
    for (int i = 0; i < 20; ++i) {
      cout << fcts[i] << " " << flush;
    }
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  constexpr Factors<200000> cfactors;

  size_t n, m;
  cin >> n >> m;
  vector<pair<int, int>> factors;
  int sq = sqrt(m);
  for (int i = 2; m != 1 && i <= sq; ++i) {
    int num = 0;
    while (m % i == 0) {
      num++;
      m /= i;
    }
    if (0 < num) {
      factors.push_back(make_pair(i, num));
    }
  }
  if (m != 1) {
    factors.push_back(make_pair(m, 1));
  }
  int ans = 1;
  for (size_t i = 0; i < factors.size(); ++i) {
    int count = factors[i].second;
    ans = (ans * cfactors.comb_h(n, count)) % mod;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
X,N=map(int,input().split())
p=list(map(int,input().split()))
s = set(p)
i=0
ans = X
found=False
while not found:
    if X+i not in s:
        ans = X+i
        found = True
    if X-i not in s:
        ans=X-i
        found = True
    i+=1
print(ans)

Measured memory_bytes: 61688
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,i;
    cin>>n;
    vector<long> a1(n),a2(n),sum(n);
    for(i = 0; i < n; i++)
        cin>>a1[i];
    a2 = a1;
    long c1 = 0;
    for(i = 0; i < n; i++){
        if(i!=0){
            long t = a1[i]+sum[i-1];
            if(i%2==0){
                if(t <= 0){
                    c1+=abs(t)+1;
                    a1[i]+=abs(t)+1;
                }
            }
            else{
                if(t >= 0){
                    c1+=abs(t)+1;
                    a1[i]-=abs(t)+1;
                }
            }
            sum[i]=a1[i]+sum[i-1];
        }
        else{
            if(a1[0]<=0){
                c1+=abs(a1[0])+1;
                a1[0]=1;
            }
            sum[0]=a1[0];
        }
    }
    long c2 = 0;
    for(i = 0; i < n; i++){
        if(i!=0){
            long t = a2[i]+sum[i-1];
            if(i%2!=0){
                if(t <= 0){
                    c2+=abs(t)+1;
                    a2[i]+=abs(t)+1;
                }
            }
            else{
                if(t >= 0){
                    c2+=abs(t)+1;
                    a2[i]-=abs(t)+1;
                }
            }
            sum[i]=a2[i]+sum[i-1];
        }
        else{
            if(a2[0]>=0){
                c2+=abs(a2[0])+1;
                a2[0]=-1;
            }
            sum[0]=a2[0];
        }
    }
    cout<<min(c1,c2);
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

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

    const ll MOD = 1e9+7;
    Vvec<ll> dp(N, vector<ll>(N));
    dp[0][0] = 1;
    // dp[i][j] = dp[i-1][0] + ... + dp[i-1][j-1] <
    // dp[i][j] = dp[i-1][j] + ... + dp[i-1][i-1] >
    for(int i=1; i<N; i++){
        if(s[i-1]=='<'){
            dp[i][0] = 0;
            for(int j=1; j<=i; j++){
                dp[i][j] = dp[i][j-1] + dp[i-1][j-1];
                dp[i][j] %= MOD;
            }
        }
        else{
            dp[i][i] = 0;
            for(int j=i-1; j>=0; j--){
                dp[i][j] = dp[i][j+1] + dp[i-1][j];
                dp[i][j] %= MOD; 
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<N; i++){
        ans += dp[N-1][i];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 70656
void main() {
	auto arr = rs.split('/').to!(int[]);
	if(arr[1] <= 4 && arr[2] <= 30) {
		writeln("Heisei");
	} else writeln("TBD");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
bool check(string str)
{
	return str.substr(0, str.length() / 2) == str.substr(str.length() / 2);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	int ans = 0;
	for (int i = 2; i + 2 <= str.length(); i += 2)
	{
		if (check(str.substr(0, i)))
			ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int dx[5] = {-1, 0, 0, 0, 1};
const int dy[5] = {0, -1, 0, 1, 0};
 
int arr[10][10];
int ans[10][10], flip[10][10];
 
int get(int x, int y)
{
    int c = arr[x][y];
    for (int d = 0; d < 5; d++) {
	int x2 = x + dx[d], y2 = y + dy[d];
	if (0 <= x2 && x2 < 10 && 0 <= y2 && y2 < 10) {
	    c += flip[x2][y2];
	}
    }
    return c % 2;
}
 
int calc()
{
    for (int i = 1; i < 10; i++) {
	for(int j = 0; j < 10; j++) {
	    if (get(i-1, j) != 0) {
		flip[i][j] = 1;
	    }
	}
    }
 
    for (int j = 0; j < 10; j++) {
	if (get(9, j) != 0) {
	    return -1;
	}
    }
 
    int res = 0;
    for (int i = 0; i < 10; i++) {
	for (int j = 0; j < 10; j++) {
	    res += flip[i][j];
	}
    }
    return res;
}
 
void solve()
{
    int res = -1;
 
    for (int i = 0; i < (1<<10); i++) { 
	memset(flip, 0, sizeof(flip));
	for (int j = 0; j < 10; j++) {
	    flip[0][10-j-1] = i >> j & 1;
	}
	int num = calc();
	if (num >= 0 && (res < 0 || res > num)) {
	    res = num;
	    memcpy(ans, flip, sizeof(ans));   
	}
    }
 
    for (int i = 0; i < 10; i++) {
	for (int j = 0; j < 10; j++) {
	    printf("%d%c", ans[i][j], j+1 == 10 ? '\n' : ' ');
	}
    }
}
 
int main()
{
    int Tc;
    cin >> Tc;
    while (Tc--) {
	for (int i = 0; i < 10; i++) {
	    for (int j = 0; j < 10; j++) {
		cin >> arr[i][j];
	    }
	}
	solve();
    }
    return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  int ans;
  ans=N*N*N;
  cout<<ans<<endl;
}



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

int main() {
    int h,w;
    cin >> h >> w;
    int x=0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            char c;
            cin >> c;
            if(c=='#') x++;
        }
    }
    if(x==h+w-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n,k;
    cin>>n>>k;
    cout << com(k,n) <<endl;
    return 0;
}



Measured memory_bytes: 7904
#include<bits/stdc++.h>
using namespace std;
#define   FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define   vi vector<long long>
#define   vvi vector<vector<long long>>
#define   all(a) (a).begin(), (a).end()
#define   rep(i,a,b)  for(int  i=a;i<b;i++)
#define   tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define   pb push_back
#define   endl "\n"
#define   dbg(x,y) cout<<(x)<<" -->  "<<(y)<<endl
#define   dbg2(k)   cout<<(k)<<" * "<<endl;
#define   F first
#define   S second
#define   int long long
#define   ll long long

const int  inf=1e6+2;
const int  ninf=-1e9 ;
const int  mod=1e9+7;
int cost[200005],h[200005];
int BIT[200005];
int n;
void update(int idx,int val)
{
	while(idx<n)
	{
	   BIT[idx]=max(BIT[idx],val);
	   idx+=((idx)&(-idx));
	}
}

int fun(int idx)
{
	int ans=0;
	
	while(idx>0)
	{
	  ans=max(ans,BIT[idx]);
	  idx-=(idx&(-idx));	
	}
	return ans;
}


void solve()
{
  	int m,i,j,x,d,bt,y,p,g,k,low,high,res,mid,q;
  	cin>>n;
  	for(i=0;i<n;i++)
  	{
  		cin>>h[i];
	}
	for(i=0;i<n;i++)
  	{
  		cin>>cost[i];
	}
	int ans=0;
	for(i=0;i<n;i++)
  	{
  	  mid=fun(h[i]-1);
  	  res=mid+cost[i];
//  	  cout<<i<<" "<<mid<<" "<<res<<" "<<h[i]<<endl;
  	  ans=max(ans,res);
  	  update(h[i],res);
  	}
	   
	cout<<ans<<endl;	
}
signed main()
{
//   FASTIO;
   int T;
   T=1;
//   cin>>T;
   while(T--)
   {
    solve();
   }
   return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll unsigned long long
//#define mod 1000000007
#define NCONS 200001

using namespace std;
int N, M;
vector<int> adj[NCONS];
bool visited[NCONS];

bool can_i_go(int cur, int times)
{
	if (times > 2)
		return false;
	if (cur == N)
		return true;
	visited[cur] = true;
	for (int i = 0; i < adj[cur].size(); i++)
	{
		auto next = adj[cur][i];
		if (visited[next]) continue;
		if (can_i_go(next, times + 1))
			return true;
	}

	visited[cur] = false;
	return false;
}

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		int a, b; cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	if (can_i_go(1, 0))
	{
		cout << "POSSIBLE";
	}
	else
	{
		cout << "IMPOSSIBLE";
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define INF 1000000000000
typedef long long ll;

int main() {
	int n, one, ten, hundred;
	cin >> n;
	ten = n % 100;
	one = ten % 10;
	if ((n - ten) / 100 == 7 || (ten - one) / 10 == 7 || one == 7) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 3572
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 21:57:46 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
#A = list(map(int,input().split()))

ans = (N // 500)*1000 + ((N % 500) // 5 )* 5

print(ans)




Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    string yama;

    while (cin >> N, N) {
        cin >> yama;

        vector<int> player(N);
        int ba = 0, turn = 0;

        for (int i = 0; i < yama.size(); ++i) {
            if (yama[i] == 'M') { // 男
                player[turn]++;
            }
            else if (yama[i] == 'S') { // 坊主
                ba += player[turn] + 1;
                player[turn] = 0;
            }
            else if (yama[i] == 'L') { // 姫
                player[turn] += ba + 1;
                ba = 0;
            }
            turn = (turn + 1) % N;
        }

        sort(player.begin(), player.end());
        for (int i = 0; i < player.size(); ++i)
            cout << player[i] << " ";
        cout << ba << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
//#include<unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
//#define mid (l + r >> 1)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define foR( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))using namespace std;
typedef long long ll;
using namespace std;
const ll N = 200011;
const ll Inf = 0x3f3f3f3f3f3f;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar ( x % 10 | 48 );
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {
	
	ll Fmax, Smax, n, a[N], Vis[N];
	
	int main() {
		n = read();
		For ( i, 1, n ) a[i] = read();
		For ( i, 1, n ) 
			if (Fmax <= a[i]) Smax = Fmax, Fmax = a[i];
			else if (Smax <= a[i]) Smax = a[i];
		For ( i, 1, n ) wln((a[i] == Fmax)? Smax: Fmax);
		return 0;
	}
	
}

int main()
{
	return Cesare::main();
}

/*

*/



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  vector<ll> a(5);
  cin >> n;
  REP(i,5) cin >> a[i];
  sort(ALL(a));
  cout << (n+a[0]-1)/a[0] + 4 << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var a, b, c, d = nextInt(), nextInt(), nextInt(), nextInt()
	x := a + b - c - d
	if x < 0 {
		fmt.Println("Right")
	} else if x > 0 {
		fmt.Println("Left")
	} else {
		fmt.Println("Balanced")
	}

}


Measured memory_bytes: 640
#include <iostream>
#include <atcoder/mincostflow>

using namespace std;
using namespace atcoder;

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

    vector<string> board(n);
    for (int i = 0; i < n; i++) {
        cin >> board[i];
    }

    mcf_graph<int, int> g(n * m + 2);
    int sv = n * m, tv = sv + 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (board[i][j] == '#') continue;
            g.add_edge(i * m + j, tv, 1, 10000 - i - j);
            if (board[i][j] == 'o') {
                g.add_edge(sv, i * m + j, 1, i + j);
            }
            if (i) {
                g.add_edge((i - 1) * m + j, i * m + j, 10000, 0);
            }
            if (j) {
                g.add_edge(i * m + (j - 1), i * m + j, 10000, 0);
            }
        }
    }

    auto answer = g.flow(sv, tv);

    cout << answer.first * 10000 - answer.second << endl;
    return 0;
}

Measured memory_bytes: 4196
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N);
  vector<ll> A_sum(N+1);
  vector<ll> B(M);
  vector<ll> B_sum(M+1);
  A_sum[0] = 0;
  B_sum[0] = 0;
  rep(i, N) {
    cin >> A[i];
    A_sum[i+1] = A[i] + A_sum[i];
  }
  rep(i, M){
    cin >> B[i];
    B_sum[i+1] = B[i] + B_sum[i];
  }

  ll ans = 0;
  ll j = M;
  rep(i, N+1){
    if (K >= A_sum[i]){
      ll nokori = K - A_sum[i];
      while(B_sum[j] > nokori){
        j--;
      }
      ans = max(ans, i+j);
    }
    else break;
  }

  cout << ans << endl;

}


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

int main(){
	int a,b,c;
	cin >> a >> b;
	c = b - a;
	
	int x = 0;
	
	for(int i = c;i > 0;--i){
		x += i;
	}
	
	cout << x - b << endl;
	
	return 0;
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int a[300000];
int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&a[i]);
	int now=0;
	rep(i,n){
		if(a[i]==now+1){
			now++;
		}
	}
	if(now==0)puts("-1");
	else cout<<n-now<<endl;
}

Measured memory_bytes: 1152
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    A = list(map(int, input().split()))
    ret = 0
    for k in range(M):
        ret += A[k] * B[k]
    ret += C
    if ret > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
	int n, m, a[1010], s = 0, c = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
	}
	for (int i = 0; i < n; i++)
		if (a[i]*4*m >=s)
			c++;
	if (c >= m) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> a(3*N);
    for(int i=0;i<3*N;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll max=0;
    for(int i=0;i<N;i++){
        max += a[3*N-1-(2*i+1)];
    }
    cout << max << endl;
}

Measured memory_bytes: 4556
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int S = sc.nextInt();
		for(int i = 0; i < N; i++) {
			if(i < K)
				System.out.print(S + " ");
			else {
				if(S < 1000000000)
					System.out.print(S+1 + " ");
				else
					System.out.print(1 + " ");
			}
		}
		System.out.println();

	}

}

Measured memory_bytes: 43204
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${5PL2kn!5WHLRAEt*Sc1xnT$EfZ{QXc?Aiev-A^w7S(i%nyvdjV!=XLlAI+=#&ld75G{_6BK2??S|=#!1Dp(1{?w<EOJH&jTL@HQY%)aC=jklvR4;?)gb_s~ORZjk+vkuQcd-eLbh>;LBp^Q+bAC!>}aqjLG~crz;}Y^;(EQ@m_@lgV(U`W`;{yfWm0_EAQ}z^94c0uVBHK)Qq=(wdqwaiA+n#riW!1890MrFbt7Fmc{I(I_&yge_+@XXFrmPb^(T}@+K-OoQG<gI?wg5kYx8Fx996n97i-67Aq_^Fd5`{Y9X@l*7Q3aqT3`=MAG4pQ0gciq0}v|&@A`T&U#x^bc@>E@Z#6j>-vxWYSJk30!ifgSr*IRrv-diT7V=sza4$2?E")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 9792
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t,n,i,j;
  double a,b,l,k;
  cin>>n>>k;
  j=0;
  
  for(i=1;i<=n;i++)
  {   
    cin>>a>>b;
    l=sqrt(a*a+b*b);
    if(l<=k)
      j++;
  }
  
  cout<<j<<endl;
  


}

Measured memory_bytes: 3752
#include <stdio.h>

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

  if(a < b){
    printf("a < b\n");
  }else if(a > b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
}



Measured memory_bytes: 2572
S=input()
K=int(input())

i=0
l=''
while i<len(S)-1:
    if S[i]=='a':
        l+='a'
    elif 123-ord(S[i])<=K:
        l+='a'
        K-=123-ord(S[i])
    else:
        l+=S[i]
    i+=1

if K>0:
    K%=26
    n=ord(S[-1])+K
    if n>122:
        n-=26
    l+=chr(n)
else:
    l+=S[-1]


print(l)

Measured memory_bytes: 3572
import java.util.*;

class Main {
	public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int num3 = sc.nextInt();
        int count = 0;

        for(int i = num1;i <= num2;i++){
            if(num3 % i == 0)   count++;
        }

        System.out.println(count);
    }
}


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

using namespace std;

int main() {
   
   int n;
   cin >> n;
   
   double s = 0.;
   for (int i = 0; i < n; ++i) {
      int a;
      cin >> a;
      
      s += 1. / a;
   }
   
   cout << 1. / s << endl;
   return 0;
}


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

constexpr ll MOD = (ll)1e9 + 7;

ll POW(ll n, ll m) {
    ll result = 1;
    while (m) {
        if (m & 1) {
            result *= n;
            result %= MOD;
        }

        n *= n;
        n %= MOD;
        m /= 2;
    }
    return result;
}

int main() {
    string S;
    cin >> S;
    const ll N = S.size();

    ll Q = 0;
    for (ll i = 0; i < N; i++) {
        if (S[i] == '?') {
            Q++;
        }
    }

    //?をDで代用
    enum {
        A, AB, AD, D, DB, DD, NUM
    };

    vector<ll> num(NUM, 0);
    //A
    //AB
    //A?
    //?
    //?B
    //??
    //の数を数えればいいのか

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        if (S[i] == '?') {
            ans += num[AB] * POW(3, Q - 1) % MOD;
            ans += num[AD] * POW(3, Q - 2) % MOD;
            ans += num[DB] * POW(3, Q - 2) % MOD;
            ans += num[DD] * POW(3, Q - 3) % MOD;
            ans %= MOD;
            num[DD] += num[D];
            num[DD] %= MOD;
            num[AD] += num[A];
            num[AD] %= MOD;
            num[D]++;
            num[D] %= MOD;
        } else if (S[i] == 'C') {
            ans += num[AB] * POW(3, Q ) % MOD;
            ans += num[AD] * POW(3, Q - 1) % MOD;
            ans += num[DB] * POW(3, Q - 1) % MOD;
            ans += num[DD] * POW(3, Q - 2) % MOD;
            ans %= MOD;
        } else if (S[i] == 'B') {
            num[AB] += num[A];
            num[AB] %= MOD;
            num[DB] += num[D];
            num[DB] %= MOD;
        } else {
            num[A]++;
            num[A] %= MOD;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n, x, y, z;
  scanf("%d %d %d %d", &n, &x, &y, &z); 
  int sz = 1 << (x + y + z);
  auto on_bit = [](int mask, int i) {
    return mask >> i & 1;
  };
  vector<vector<int>> f(2, vector<int>(sz));
  f[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    f[(i + 1) & 1].assign(sz, 0);
    for (int mask = 0; mask < sz; ++mask) {
      if (on_bit(mask, x + y + z - 1) && on_bit(mask, y + z - 1) && on_bit(mask, z - 1)) {
        continue;
      }
      for (int j = 1; j <= 10; ++j) { 
        int n_mask = ((mask << j) | (1 << (j - 1))) & (sz - 1);
        f[(i + 1) & 1][n_mask] += f[i & 1][mask]; 
        f[(i + 1) & 1][n_mask] %= md; 
      }
    }
  }
  int ans = 0;
  for (int mask = 0; mask < sz; ++mask) {
    if (on_bit(mask, x + y + z - 1) && on_bit(mask, y + z - 1) && on_bit(mask, z - 1)) {
      continue;
    }
    ans = (ans + f[n & 1][mask]) % md;
  }
  int all = 1;
  for (int i = 0; i < n; ++i) {
    all = (all * 10LL) % md;
  }
  printf("%d\n", (all - ans + md) % md);
  return 0;
}

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

using namespace std;

int main(){
	int n,a,cnt=0;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i){
		scanf("%d", &a);
		if(a==cnt+1) cnt++;
	}
	(cnt!=0)? printf("%d", n-cnt) : printf("-1");;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

int sums[10][2010];
int dp[11][2010];

void solve() {
  int n, k;
  cin >> n >> k;
  vector<vi32> books(10);
  rep(i, n) {
    int c, g;
    cin >> c >> g;
    g--;
    books[g].push_back(c);
  }
  rep(i, 10) sort(all(books[i])), reverse(all(books[i]));
  rep(i, 10) {
    rep(j, books[i].size()) {
      sums[i][j + 1] = books[i][j];
      sums[i][j + 1] += sums[i][j] + j * 2;
    }
    repic(j, books[i].size() + 1, k) sums[i][j] = -1;
  }
  rep(i, 10) {
    repc(j, k) {
      int ma = 0;
      repc(l, j) {
        if (sums[i][l] == -1) break;
        amax(ma, sums[i][l] + dp[i][j - l]);
      }
      dp[i + 1][j] = ma;
    }
  }
  cout << dp[10][k] << endl;
}



Measured memory_bytes: 3348
#include <iostream>
#include <vector>
#include <map>
#define ll long long
using namespace std;

/*
	a[i] + b[j] + c[k] + d[l] = V
		???	a[i] = V - b[j] - c[k] - d[l]	(	O(N) + O(N^3) ?? )
		???	a[i] + b[j] = V - c[k] - d[l]	(	O(N^2) + O(N^2)	???)

*/

int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	ll N, V, ans = 0; cin >> N >> V;
	vector<ll> a(N), b(N), c(N), d(N);
	map<ll, ll> sum_cnt;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) cin >> b[i];
	for (int i = 0; i < N; i++) cin >> c[i];
	for (int i = 0; i < N; i++) cin >> d[i];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			sum_cnt[a[i] + b[j]]++;
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans += sum_cnt[V - c[i] - d[j]];
		}
	}
	cout << ans << endl;
}

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

int main()
{
  int n,k;
  cin >> n >> k;
  
  int p[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  
  sort(p,p+n);
  int sum = 0;
  for(int i = 0; i < k; i++){
    sum += p[i];
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    int d,g;
    int ans=100000;
    cin>>d>>g;
    vector<int>p(d),c(d);
    for(int i=0;i<d;i++)cin>>p[i]>>c[i];
    for(int i=0;i<(1<<d)-1;i++){
        int num=0,cnt=0;
        for(int j=0;j<d;j++){
            int x=i>>j;
            x=x&1;
            if(x){
                num+=100*(j+1)*p[j]+c[j];
                cnt+=p[j];
            }
        }
        if(num>=g)ans=min(ans,cnt);
        else{
            for(int j=d-1;j>=0;j--){
                int x=i>>j;
                x=x&1;
                int k=0;
                if(x==0){
                   for(k=0;k<p[j];k++){
                       num+=100*(j+1);
                       cnt++;
                       if(k==p[j]-1)num+=c[j];
                       if(num>=g){
                           ans=min(ans,cnt);
                           break;
                       }
                   }
                   break;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
template<class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int M=1e9;
int main() {
	ll S; rd(S);
	int x=S%M,y=S/M; // S = y*M + x
	// S = (y+1)*M - (M-x)
	if(y==M) {
		printf("0 0 %d %d %d %d\n",M,0,0,M);
	}
	else printf("0 0 %d %d %d %d\n",y+1,1,M-x,M);
	return 0;
}

Measured memory_bytes: 256
a = gets.to_i
b = gets.split.map(&:to_i)
h = Hash.new(0)
for i in 0..(a - 1) do
    h[b[i]] += 1
end
k = h.to_a
j = 0
for i in 0..(k.size() - 1) do
    if(k[i][1] > 1)
        j += 1
    end
end
puts j == 0 ? 'YES' : 'NO'


Measured memory_bytes: 38532
S = input()
S_len = len(S)
#print(S_len)
S_left = S[0:int(S_len/2)]
S_right = S[int(S_len/2)+1:]
def palindrome(string): return 0 if string==string[::-1] else 1

if(palindrome(S)== 0 and palindrome(S_left) == 0 and palindrome(S_right) == 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
from itertools import chain

def process(l, ans):
  if not l:
    return ans
  elif len(l) == 1:
    ans += l[0]
    return ans
  elif all(l):
    ans += min(l)
    l = list(map(lambda x: x - min(l), l))
    ans = process(l, ans)
  else:
    d = [i for i in range(len(l)) if not l[i]]
    tmp = []
    td = 0
    for i, dd in enumerate(d):
      tmp.append(l[td:dd])
      td = dd + 1
      if i == len(d) - 1 and dd != len(l) -1:
        tmp.append(l[td:])
    for t in tmp:
      ans = process(t, ans)
  return ans

N = int(input())
h = list(map(int, input().split()))

ans = 0
ans = process(h, ans)
  
print(ans)

Measured memory_bytes: 9248
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

void swap(int &a, int &b){
	int dum = a;
	a = b;
	b = dum;
	return;
}

int cnt;

void insertionSort(vector<int> &a, int g){
	int n = a.size();
	for (int i = g; i != n; i++){
		int v = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > v){
			a[j + g] = a[j];
			j = j - g;
			cnt++;
		}
		a[j + g] = v;
	}
}

void shellSort(vector<int> &a){
	cnt = 0;
	int n = a.size();
	int m = (n == 1 ? 1 : (int)log2(n));
	vector<int> G(m);
	cout << m << endl;
	for (int i = 0; i != m; i++){
		G[i] = (int)pow(2, m - i - 1);
		cout << (i == 0 ? "" : " ") << G[i];
		insertionSort(a, G[i]);
	}
	cout << endl;
	return;
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i != n; i++) cin >> a[i];

	shellSort(a);

	cout << cnt << endl;
	for (int i = 0; i != n; i++) cout << a[i] << endl;
}


Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;
int num,h[100100],dp[100100];
int main(){
	cin>>num;
	for(int i=1;i<=num;i++)cin>>h[i];
	for(int i=2;i<=num;i++){
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		if(i>2)dp[i]=min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
	}
	cout<<dp[num]<<endl;
	return 0;
}

Measured memory_bytes: 1024
<?php
  $n=+fgets(STDIN);
$p=explode(" ",fgets(STDIN));
$c=$n-2;
for($i=1;$i+1<$n;$i++)$c-=+$p[$i-1]<+$p[$i]&&+$p[$i+1]<+$p[$i]||+$p[$i-1]>+$p[$i]&&+$p[$i+1]>+$p[$i];
echo $c;

Measured memory_bytes: 3956
n=int(input())
s=input()
cnt=[0]*26
cnt2=[]
ans=1
check='abcdefghijklmnopqrstuvwxyz'
for i in range(n):
  for j in range(26):
    if s[i]==check[j]:
      cnt[j]+=1
      break
for i in range(26):
  if cnt[i]!=0:
    cnt2.append(cnt[i])
for i in range(len(cnt2)):
  ans*=(cnt2[i]+1)
  ans=ans%(10**9+7)
print(ans-1)

Measured memory_bytes: 3188
N,M = map(int,input().split())

li = [[0, 99999999999]]
L_max   = 0
R_min  = 999999999999
for i in range(M):
    li.append(list(map(int, input().split())))
    if (L_max  < li[i+1][0] ):
        L_max = li[i+1][0]
        if (R_min  > li[i+1][1]):
            R_min = li[i+1][1]
    elif (R_min > li[i+1][1]):
            R_min = li[i+1][1]

if (L_max  < li[M][0] ):
       L_max = li[M][0]
       if (R_min  > li[M][1]):
          R_min = li[M][1]
elif (R_min  > li[M][1]):
            R_min = li[M][1]

if (L_max > N) or (L_max > R_min):
    print("0")
else:
    print(R_min - L_max + 1)


Measured memory_bytes: 60060
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

int a,b,c;cin>>a>>b>>c;
if(a+b+c>=22) cout<<"bust";
else cout<<"win";


return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int A, N;
	cin >> N >> A;
	if(N % 500 <= A){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s;
    cin>>s;
    ll ans=700;
    if(s[0]=='o')
    {
        ans+=100;
    }
    if(s[1]=='o')
        ans+=100;
    if(s[2]=='o')
        ans+=100;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
long long a[51],n;
int main(){
	cin>>n;
	for(long long i=1;i<=50;i++)
		a[i]=(n/50)+i-1;
	n%=50;
	for(long long i=1;i<=n;i++){
		for(int j=1;j<=50;j++)
			a[j]--;
		a[i]+=51;
	}
	cout<<50<<endl;
	for(int i=1;i<50;i++)
		cout<<a[i]<<" ";
	cout<<a[50];
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func toInt(value string) int {
	num, _ := strconv.Atoi(value)
	return num
}

func splitWithInt(value string) []int {
	vals := strings.Split(value, " ")
	nums := make([]int, len(vals))
	for index, elem := range vals {
		nums[index] = toInt(elem)
	}
	return nums
}

func transpose(data [][]string, w int, h int) [][]string {
	res := make([][]string, w)
	for i := 0; i < w; i++ {
		res[i] = make([]string, h)
		for j := 0; j < h; j++ {
			res[i][j] = data[j][i]
		}
	}
	return res
}

func main() {
	nums := splitWithInt(gets())
	h, w := nums[0], nums[1]
	m := make([][]string, h)
	temp := [][]string{}
	ttemp := [][]string{}
	for i := 0; i < h; i++ {
		m[i] = strings.Split(gets(), "")
	}

	for _, e := range m {
		for _, c := range e {
			if c == "#" {
				temp = append(temp, e)
				break
			}
		}
	}

	// for _, e := range temp {
	// 	fmt.Println(strings.Join(e, ""))
	// }

	temp = transpose(temp, w, len(temp))

	// for _, e := range temp {
	// 	fmt.Println(e)
	// }

	for _, e := range temp {
		for _, c := range e {
			if c == "#" {
				ttemp = append(ttemp, e)
				break
			}
		}
	}

	// for _, e := range ttemp {
	// 	fmt.Println(e)
	// }

	ans := transpose(ttemp, len(ttemp[0]), len(ttemp))
	for _, e := range ans {
		fmt.Println(strings.Join(e, ""))
	}

}

Measured memory_bytes: 1280
mod=10**9+7
n=int(input())
H=list(map(int,input().split()))

def solve(h):
    if not h:
        return 1
    elif len(h)==1:
        return pow(2,h[0],mod)
    N=len(h)
    a=[h[i] for i in range(N)]
    a=list(set(a))
    a.sort()
    comp={i:e+1 for e,i in enumerate(a)}
    data={comp[e]:e for e in comp.keys()}
    data[0]=0
    data[0]=1
    #print(comp)

    dp=[[0 for i in range(len(a)+1)] for j in range(N)]

    i=0
    if h[i+1]>=h[i]:
        id=comp[h[i]]
        id2=comp[h[i+1]]
        for j in range(id,id2+1):
            dp[i][j]=2
        for j in range(0,id):
            dp[i][j]=1
    else:
        id=comp[h[i+1]]
        for j in range(0,id):
            dp[i][j]=pow(2,h[i]-h[i+1],mod)
        dp[i][id]=2*(pow(2,h[i]-h[i+1],mod)-1)
        dp[i][id]%=mod
        id2=comp[h[i]]
        dp[i][id]+=2
        dp[i][id]%=mod

    for i in range(1,N-1):
        if h[i+1]>=h[i]:
            id=comp[h[i]]
            id2=comp[h[i+1]]
            for j in range(id,id2+1):
                dp[i][j]=(2*dp[i-1][id])%mod
            for j in range(0,id):
                dp[i][j]=dp[i-1][j]
        else:
            id=comp[h[i+1]]
            id2=comp[h[i]]
            for j in range(0,id):
                dp[i][j]=(pow(2,h[i]-h[i+1],mod)*dp[i-1][j])%mod
            for j in range(id,id2):
                low=data[j]
                up=data[j+1]-1
                dp[i][id]+=dp[i-1][j]*pow(2,h[i]-up,mod)*(pow(2,up-low+1,mod)-1)
            dp[i][id]%=mod
            dp[i][id]+=2*dp[i-1][id2]
            dp[i][id]%=mod

    ans=0
    id=comp[h[-1]]
    for i in range(0,id):
        low=data[i]
        up=data[i+1]-1
        ans+=dp[N-2][i]*pow(2,h[-1]-up,mod)*(pow(2,up-low+1,mod)-1)
        ans%=mod
    ans+=2*dp[N-2][id]
    ans%=mod
    return ans

ans=pow(2,H.count(1),mod)
check=[i for i in range(n) if H[i]==1]
check=[-1]+check+[n]
for i in range(len(check)-1):
    l,r=check[i],check[i+1]
    ans*=solve(H[l+1:r])
    ans%=mod

print(ans)

Measured memory_bytes: 71944
#include <stdio.h>
int main(){
	int x, y, tmp;
	for (;;)
	{
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0)
		{
			break;
		}
		else if (x > y)
		{
			tmp = x;
			x = y;
			y = tmp;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 600