akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AUOIAUAI {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    char c;
	    in >> c;
	    set<char> s = {'a', 'e', 'i', 'o', 'u'};
	    if(s.find(c) != s.end()) out << "vowel" << endl;
	    else out << "consonant" << endl;
	}
};


int main() {
	AUOIAUAI solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import itertools
n,m=map(int,input().split())
xs=[list(map(int,input().split()))[1:] for i in range(m)]
p=tuple(map(int,input().split()))
ans=0
for switch in itertools.product(range(2),repeat=n):
  judge=True
  for i in range(m):
    cnt=0
    lst=xs[i]
    for j in lst:
      cnt+=switch[j-1]
    if cnt%2!=p[i]:
      judge=False
      break
  if judge:
    ans+=1

print(ans)


Measured memory_bytes: 9236
#include <stdio.h>

int main(void)
{
  int n;
  int hour, minutes, seconds;

  scanf("%d", &n);

  hour = n / 60 / 60;
  minutes = n / 60 % 60;
  seconds = n % 60;

  printf("%d:%d:%d\n", hour, minutes, seconds);

  return (0);
}



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

int s[305*305], px[305*305], py[305*305];

int main(){
    int h, w, d; cin >> h >> w >> d;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a; cin >> a;
            px[a] = i; py[a] = j;
        }
    }

    for(int i=d+1;i<=h*w;i++) s[i] = s[i-d] + abs(px[i]-px[i-d]) + abs(py[i]-py[i-d]);

    int q; cin >> q;
    for(int i=0;i<q;i++){
        int l, r; cin >> l >> r;
        printf("%d\n", s[r]-s[l]);
    }

    return 0;
}


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

#define MAX 100010

using namespace std;

typedef long long ll;

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

    int n; cin >>n;
    int H[n];

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

    int dp[n]; for(int i = 0; i < n; i++) dp[i] = 1000000100;
    dp[0] = 0;
    for(int i = 0; i < n-1; i++){

        int j = i+1;
        dp[j] = min(dp[j],dp[i] + abs(H[i]-H[j]));
        if(j + 1 < n){
            dp[j+1] = min(dp[j+1],dp[i] + abs(H[i]-H[j+1]));
        }
    }
    cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 1024
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    As = list(map(int, input().split()))

    total = 0 # 踏み台の高さ
    pre_a = As[0]
    for i in range(1, N):
        diff = pre_a - As[i]
        if diff > 0:
            # 前の人のほうが高い
            total += diff
            As[i] += diff
        else:
            # 後ろの人のほうが高い
            pass
        pre_a = As[i]

    print(total)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 32292
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

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


int main()
{
	FAST;
	string str;
	cin >> str;
    str.pop_back();
	while(str.size()&1 || str.substr(0 , str.size()/2) != str.substr(str.size()/2 , str.size()/2))
	{
		str.pop_back();
	}

	cout << str.size();

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    
    int m; cin >> m;
    vector<string> t(m);
    rep(i,m) cin >> t[i];

    int ans = 0;
    rep(i,n){
        int cnt = 1;
        for(int j = i+1; j < n; j++){
            if(s[i] == s[j]) cnt++;
        }
        rep(j,m){
            if(s[i] == t[j]) cnt--;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

queue = [[]]
lst = []

while queue:
  e = queue.pop(-1)
  if len(e) == n:
    lst.append(tuple(e))
    continue
  for i in range(1,n+1):
    if i not in e:
      queue.append(e+[i])

lst.sort()
print(abs(lst.index(P) - lst.index(Q)))




Measured memory_bytes: 13884
//-fexec-charset=CP932
#include<iostream>
#include <bits/stdc++.h>
using namespace std;

 
 
int main(){
 cin.tie(0);
 ios::sync_with_stdio(false);
 
 int d,t,s;
 cin>>d>>t>>s;
 if(d%s!=0){
     if(((d/s)+1)<=t)cout<<"Yes";
     else cout<<"No";
 }
 else if(d%s==0){
     if(d/s<=t)cout<<"Yes";
     else cout<<"No";
 }

return 0;
}
 



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		W = in.readLine();
		String[] Ws = W.split(" ");
		int[] B = new int[Ws.length];
		for(int i=0;i<Ws.length;i++){
			B[i]=Integer.parseInt(Ws[i]);
		}

		int[] A = new int[N];
		A[0]=B[0];
		for(int i=1;i<N-1;i++){
			A[i] = Math.min(B[i-1], B[i]);
		}

		A[N-1]=B[N-2];

		long ans =0;
		for(int i=0;i<N;i++){
			ans+=A[i];
//			System.out.print(A[i]+" ");
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list(int(input()) for i in range(n))

a.sort()
if n%2==0:
    start = n//2-1
    left = 0
    right = n-1
    ans0 = abs(a[right]- a[start])
    while start != left:
        ans0+=abs(a[left]-a[right])
        right -= 1
        ans0+=abs(a[right]-a[left])
        left += 1

    start = n//2
    left = 0
    right = n-1
    ans1 = abs(a[left]- a[start])
    while start != right:
        ans1+=abs(a[right]-a[left])
        left += 1
        ans1+=abs(a[left]-a[right])
        right -= 1

    ans = max(ans0,ans1)
    print(ans)

if n%2==1:
    start = n//2
    left = 0
    right = n-1
    ans0 = abs(a[right]- a[start])
    while True:
        ans0+=abs(a[left]-a[right])
        right -= 1
        if start == right: break
        ans0+=abs(a[right]-a[left])
        left += 1


    left = 0
    right = n-1
    ans1 = abs(a[left]- a[start])
    while True:
        ans1+=abs(a[right]-a[left])
        left += 1
        if start == left: break
        ans1+=abs(a[left]-a[right])
        right -= 1

    ans = max(ans0,ans1)
    print(ans)



Measured memory_bytes: 7420
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    bool isPrime[110000];
    for(int i = 2; i <= 110000; i++){
        isPrime[i] = true;
    }
    for(int i = 2; i <= 110000; i++){
        if(isPrime[i]){
            for(int j = 2*i; j <= 110000; j += i){
                isPrime[j] = false;
            }
        }
    }
    for(int i = n; i <= 110000; i++){
        if(isPrime[i]){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 384
n=int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

m=0
# 0で初期化すると最初が1の時にだめ
at=-1
for ai in a:
    m+=b[ai-1]
    if ai == at+1:
        m+=c[at-1]
    at=ai
print(m)


Measured memory_bytes: 3060
// Copyright 2017 Parallelc
#include <bits/stdc++.h>

#include <ext/numeric>
#include <ext/rope>
using namespace __gnu_cxx;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace __gnu_pbds;
template<typename T>
using pbq = priority_queue<T>;
template<typename T>
using rbt = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using namespace std;

#include <tr2/dynamic_bitset>
using namespace tr2;
using db = dynamic_bitset<>;

template <typename T> 
bool in(T& x){
    x = 0; T f = 1; char ch = cin.get();
    while (!isdigit(ch)) {
        if (ch == -1) return false;
        if (ch == '-') f = -1; 
        ch = cin.get();
    }
    while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = cin.get();}
    x *= f; return true;
}
template <typename T, typename... S>
bool in(T& t, S&... s) {if(!in(t)) return false; return in(s...);}

using LL = int64_t;
const int INF = 0x3f3f3f3f;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> lj(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        lj[u].push_back(v);
        lj[v].push_back(u);
    }
    for (int i = 0; i < n; i++) cout << lj[i].size() << endl;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9



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

  if(s[0] == s[2]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
  const ll mod=998244353;
  vector<mint> dp(500010,0);
  int i,j,n,k;
  cin >> n >> k;
  int l[15],r[15];
  for(i=0;i<k;i++){
    cin >> l[i] >> r[i];
  }
  dp[1]=1;
  for(i=1;i<=n;i++){
    dp[i]=dp[i]+dp[i-1];
    for(j=0;j<k;j++){
      dp[i+l[j]]+=dp[i];
      dp[i+r[j]+1]-=dp[i];
    }
    dp[1]=0;
  }
  printf("%lld\n",dp[n]);
}

Measured memory_bytes: 7028
#include<iostream>
#include<vector>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
vector<ll> a,p;
ll dfs(ll n,ll x){
    if(n == 0){
        if(x <= 0) return 0;
        else return 1;
    }
    else if(x <= 1 + a[n - 1]) return dfs(n - 1, x - 1);
    else return p[n - 1] + 1 + dfs(n - 1, x - 2 - a[n - 1]);
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,m;
cin >> n >> m;
a.assign(1,1);
p.assign(1,1);
rep(i,n){
    a.emplace_back(a[i] * 2 + 3);
    p.emplace_back(p[i] * 2 + 1);
}
cout << dfs(n,m) << endl;
}

Measured memory_bytes: 3192
# x=a_i * (p+0.5)
# 前提としてaが偶数
# x= (a_i//2)*(2*p+1)
from fractions import gcd

n, m = map(int, input().split())
A = list(map(int, input().split()))
koubai = A[0] // 2
temp = koubai & -koubai
for i in range(1, n):
    a = A[i]
    if a % 2 == 1:
        print(0)
        exit()
    a //= 2
    if a & -a != temp:
        print(0)
        exit()
    g = gcd(koubai, a)
    koubai *= a // g


ans = m // koubai
if ans == 0:
    ans = 0
elif ans % 2 == 0:
    ans //= 2
else:
    ans //= 2
    ans += 1
print(ans)


Measured memory_bytes: 16320
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
void solve(){
    string s;
    cin>>s;
    bool f=false;
    for(ll i=0;i<3;++i){
        if(s[i]=='7'){
            f=true;
        }
    }
    if(f) cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    fastio;
//    ll t=0;
//    cin>>t;
//    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3640
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
C = Counter(s)
L = C.most_common()
x = 0
ans = []
for i, l in enumerate(L):
    if i == 0:
        x = l[1]
        ans.append(l[0])
    elif x == l[1]:
        ans.append(l[0])
    else:
        break
ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 47636
x, y, a, b, c = list(map(int, input().split(' ')))
pa = list(map(int, input().split(' ')))
qb = list(map(int, input().split(' ')))
rc = list(map(int, input().split(' ')))

pa = sorted(pa)[len(pa) - x:]
qb = sorted(qb)[len(qb) - y:]
rc = sorted(rc, reverse=True)

ai = 0
bi = 0
result = sum(pa) + sum(qb)

for r in rc:
    if bi >= len(qb) and ai >= len(pa):
        break
    
    elif bi >= len(qb) or pa[ai] <= qb[bi]:
        if r > pa[ai]:
            result = result - pa[ai] + r
            ai += 1
            
    elif ai >= len(pa) or pa[ai] >= qb[bi]:
        if r > qb[bi]:
            result = result - qb[bi] + r
            bi += 1
print(result)



Measured memory_bytes: 107356
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

ll n, a[200005], m, ans;

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

  m = a[0];
  for (int i = 1; i < n; i++) {
    if (m < a[i]) {
      m = a[i];
    } else {
      ans += m - a[i];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

int main() 
{
    FAST;
    ll n,ans;
    cin>>n;
    ans=power(2,n+n-2,A);
    ll a[n];
    ve<pair<ll,ll>> v;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        v.pb({a[i],i});
    }
    sort(v.begin(),v.end());
    ll k=0;
    for(int i=0;i<n;i++)
        k=(k+(v[i].first*(n-i+1)))%A;
    ans=(ans*k)%A;
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 7152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	 	Scanner scanner = new Scanner(System.in);
	 	String S = scanner.next();
		String[] splitArray = S.split("");
		String x = splitArray[2];
		String y = splitArray[3];
		String z = splitArray[4];
		String w = splitArray[5];
		if (x.equals(y) && z.equals(w)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <stdio.h>
int pm(int n,int *l){
    int i,j,p=0,c=n-1,target[n-1];
    for(i=0;i<n-1;i++){target[i]=i+2;}
    for(i=0;i<n-1;i++){
        if (!target[i]){continue;}
        for(j=i;j<n-1;j=j+i+2){
            if (!target[j]){continue;}
            if (j!=i && target[j]%target[i]==0){target[j]=0;c--;}
        }
    }
    for(i=0;i<n-1;i++){
        if(target[i]){l[p]=target[i];p++;}
    } 
    return p;
} 

int main(void){
    int i,p,n,idx=0,l[55000],ds[50000][2];
    p=pm(55000,l);

    while(scanf("%d",&n)!=EOF){
        for(i=0;i<p-1;i++){
	    if(n>l[i] && n<l[i+1]){ds[idx][0]=l[i];ds[idx][1]=l[i+1];break;}
            else if(n==l[i]){ds[idx][0]=l[i-1];ds[idx][1]=l[i+1];break;}
            else if(n==l[i+1]){ds[idx][0]=l[i];ds[idx][1]=l[i+2];break;}
        }
        idx++;
    }
    for(i=0;i<idx;i++){printf("%d %d\n",ds[i][0],ds[i][1]);}
    return 0;
}

    



Measured memory_bytes: 1976
fun main(args: Array<String>) {
    val a = readInputLine().toInt()
    readInputLine()
    readInputLine()
    readInputLine()
    val e = readInputLine().toInt()
    val k = readInputLine().toInt()
    
    if (e - a > k) {
        println(":(")
    } else {
        println("Yay!")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

public class Main{
    static PrintWriter out;
    static Scanner in;
    public static void main(String args[]){
	in = new Scanner(System.in);
	out = new PrintWriter(System.out);
	solve();
	in.close();
	out.close();
    }

    public static void solve(){
        int r = in.nextInt();
	int g = in.nextInt();
	int b = in.nextInt();
	int rgb = 100*r+10*g+b;
	if(rgb%4==0){
	    out.println("YES");
	}else{
	    out.println("NO");
	}

    }
}


Measured memory_bytes: 21716
n = gets.to_i
a = gets.split.map(&:to_i)
puts a.join(' ')

(1..n-1).each do |i|
  v = a[i]
  j = i - 1
  while j >= 0 and a[j] > v do
    a[j+1] = a[j]
    j -= 1
  end
  a[j+1] = v
  puts a.join(' ')
end



Measured memory_bytes: 6888
//インクルード(GCC only)
#include <bits/stdc++.h>

//長い型名
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

//省略記法
#define INF 1e9
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i##_len=(n), i=(i##_len-1); i>=0; ++i)
#define FOR(i,m,n) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sizei(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
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; }

//デバッグ用
#ifdef LOCAL
    #define print(...) fprintf(stderr, __VA_ARGS__)
    #define printarray(x) rep(i,sizei(x)){cout << x[i] << endl;}
#else
    #define print(...) 42
    #define printarray(x) 42
#endif

#define SIZE 1000

int main(void)
{
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;

  vector<LL> A(X), B(Y), C(Z);
  rep(i, X) cin >> A[i];
  rep(i, Y) cin >> B[i];
  rep(i, Z) cin >> C[i];

  //method 1
  vector<LL> E;
  rep(i, X) {
    rep(j, Y) {
      E.push_back(A[i] + B[j]);
    }
  }
  sort(all(E), greater<LL>());
  sort(all(C), greater<LL>());

  vector<LL> ANS;
  rep(i, min(X*Y, K)) {
    rep(j, min(Z, K)) {
      ANS.push_back(E[i] + C[j]);
    }
  }
  sort(all(ANS), greater<LL>());
  printarray(ANS);

  rep(i, min(X*Y*Z, K)) {
    cout << ANS[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 43368
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define int long long
#define F first
#define S second
#define endl "\n"
using namespace std;

const int nax = 3e3+5;
const int inf = 1e18+7;
const int mod = 1e9+7;

int n,m;
int a[nax], b[nax];
vector<int>adj[nax];

/*
 * DO SOMETHING RATHER THAN DOING NOTHING
 * */

int dp[nax][nax];

signed main(){
    fast;
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m=t.size();
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = 1+dp[i-1][j-1];
            }else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    string ans = "";

    int i = n, j = m;

    while(i>=1&&j>=1){
        if(s[i-1] == t[j-1]){
            ans+=(s[i - 1]);
            i--;
            j--;
        }
        else if(dp[i][j] == dp[i-1][j]){
            i--;
        }else{
            j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 74100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    string s;
    cin >> s;
    map<char, int> m;
    for(auto x : s){
        m[x]++;
        if(m[x] > 2 || m.size() > 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
int a[26];
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
    
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x;
	cin>>x;
	if(x==0)
		cout<<1<<endl;
	else
		cout<<0<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

int main(void)
{
	fast;
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
	
	int n, a, b; cin >> n >> a >> b;
	cout << min(a, b) << ' ' << max(0, a+b-n);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
long long f[100008];
int x[100008];
inline bool cmp(const int &a, const int &b){
	return f[a] == f[b] ? a > b : f[a] > f[b];
}
struct Heap{
	int h[100008], siz;
	Heap(){ 
		siz = 0;
	}
	void Push(const int &x) {
		h[++siz] = x;
		push_heap(h + 1, h + siz + 1, cmp);
		return ;
	}
	void Pop() {
		pop_heap(h + 1, h + siz + 1, cmp);
		--siz;
		return ;
	}
	int Top() {
		return h[1];
	}
}c;
int main(){
	register int n, e, t, i, j;
	register long long fmin = 3000000000ll;
	scanf("%d %d %d", &n, &e, &t);
	for (i = 1; i <= n; ++i) scanf("%d", &x[i]);
	f[0] = 0;
	c.Push(0);
	for (j = 0, i = 1; i <= n; ++i) {
		while (2 * (x[i] - x[j + 1]) > t) {
			cmin(fmin, f[j] - x[j + 1] * 2);
			++j;
		}
		while (c.Top() < j) c.Pop();
		f[i] = dmin(fmin + 2 * x[i], f[c.Top()] + t);
		c.Push(i);
	}
	printf("%lld\n", f[n] + e);
	return 0;
}

Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    A, B, H, M = Scanner.map_int()
    S = 30 * H + 30 / 60 * M
    S = S / 180 * math.pi
    sx, sy = math.cos(S) * A, math.sin(S) * A

    T = 6 * M
    T = T / 180 * math.pi
    tx, ty = math.cos(T) * B, math.sin(T) * B
    x, y = tx - sx, ty - sy
    l = (x ** 2 + y ** 2) ** 0.5
    print(l)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


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

using namespace std;
int main()
{
    int n,c[100],v[100];
    cin>>n;
    for(int i=0;i<n;i++)	cin>>v[i];
    for(int i=0;i<n;i++)   cin>>c[i];
    vector<int>r;
    for(int i=0;i<n;i++){r.push_back(v[i]-c[i]); }
    sort(r.begin(),r.end());
    int sum=0;
    for(int i=0;i<n;i++){ if(r[i]>0){   sum+=r[i]; }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3632
import collections
def counter_list(A):
  counter = collections.Counter(A)
  counter =  [list(e) for e in counter.items()]
  #counter.sort() #sortしたい場合はつける
  return counter

S = list(input())
A = counter_list(S)
judge = 0

if(len(A) == 2):
  if((A[0][1]==2)and(A[1][1]==2)):
    judge = 1
    
if(judge == 1): print('Yes')
else: print('No')

Measured memory_bytes: 3316
import Data.Array

main = do
  li <- getLine
  let n = read li
  let ans = compute n
  putStrLn $ unlines ans

compute :: Int -> [String]
compute n = pla ! (n,'a')
  where
    xs = take n ['a'..]
    xx = last xs
-- 長さnで、xsの辞書順リスト。ただし新たな要素を使うなら必ずk
-- kを使った場合、それ以降はk+1まで使ってよい。
-- DPしなくても余裕だったがやってみる。
    pla = array ((0,'a'),(n,xx)) [ ((n,k),permlim n k) | n <- [0..n], k <- xs ]
    permlim 0 _ = [ [] ]
    permlim n k =
      [ x:ys
      | x <- takeWhile (k >=) xs
      , ys <- pla ! (pred n,if x == k then min xx $ succ k else k) ]


Measured memory_bytes: 48636
kn=input("").split(" ")
k=int(kn[0])
n=int(kn[1])
aa=input("").split(" ")
lista=[]
for i in aa:
    lista+=[int(i)]
for i in range(n):
    lista[i]%=k
lista.sort()

s=k-lista[n-1]+lista[0]
t=lista[n-1]-k
for i in range(n):
    ss=lista[i]-t
    
    if(ss>s):
        s=ss
        
    t=lista[i]
print(k-s)
    
    


Measured memory_bytes: 30908
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct UnionFind {
	//自身が親であれば、その集合に属する頂点数に-1を掛けたもの
	//そうでなければ親のid
	vector<int> r;

	UnionFind(int N) {
		r = vector<int>(N, -1);
	}

	int root(int x) {
		if (r[x] < 0) return x;
		return r[x] = root(r[x]);
	}

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (r[x] > r[y]) swap(x, y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}

	int size(int x) {
		return -r[root(x)];
	}
};


int main() {
	int N, M;
	cin >> N >> M;
	
	//友達集合を作る
	UnionFind UF(N);
	for (int i = 0; i < M; i++)
	{
		int A, B;
		cin >> A >> B;
		A -= 1; B -= 1;
		UF.unite(A, B);
	}

	//最大の友達集合を求める
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans = max(ans, UF.size(i));
	}

	cout << ans << endl;
}



Measured memory_bytes: 3968
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1


n = int(input())
A = list(map(int, input().split()))
index = partition(A, 0, n-1)
A[index] = '[' + str(A[index]) + ']'
print(*A)



Measured memory_bytes: 16388
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
l = make_divisors(N)
#print('try to:',len(l))
g = 0
for c in l:
    rc = N//c - 1
    if (rc != 0):
        if (N % rc) == (N//rc):
            g+=rc
            #print(rc)
print(g)

Measured memory_bytes: 3268
n,x,y=map(int,input().split())
d=[0]*(n-1)

for i in range(n-1):
	for j in range(i+1,n):
		d[min(j-i-1,abs(x-1-i)+abs(y-1-j))]+=1
		
for i in range(n-1):
	print(d[i])

Measured memory_bytes: 9340
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<math.h>
const int MAX=110;
const double PI=acos(-1.0);
using namespace std;
typedef pair<int,int> pii;
typedef long long lld;
lld n,x[MAX],y[MAX];
double l[MAX],r[MAX],fin[MAX];
lld rdist(int a,int b){
    return (lld)(x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]);
}
double angle(int a,int b){
    //printf("%f %f\n",(double)y[a]-y[b],(double)x[a]-x[b]);
    return atan2((double)y[a]-y[b],(double)x[a]-x[b])+PI;
}
int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;i++) scanf("%lld%lld",&x[i],&y[i]);
    if(n==1){
        printf("%f\n",1.0f);
        return 0;
    }
    for(int i=0;i<n;i++){
        l[i]=-PI;
        for(int j=0;j<n;j++) if(i!=j){
            if(l[i]<0) l[i]=angle(i,j),r[i]=angle(i,j)+PI;
            else{
                double tmpl=angle(i,j),tmpr=tmpl+PI;
                //printf("%f %f %f %f\n",l[i],r[i],tmpl,tmpr);
                if(!(tmpr<l[i]||r[i]<tmpl)) l[i]=max(tmpl,l[i]),r[i]=min(tmpr,r[i]);
                else if(!(tmpr<l[i]+2*PI||r[i]+2*PI<tmpl)) l[i]=max(tmpl,l[i]+2*PI),r[i]=min(tmpr,r[i]+2*PI);
                else if(!(tmpr+2*PI<l[i]||r[i]<tmpl+2*PI)) l[i]=max(tmpl+2*PI,l[i]),r[i]=min(tmpr+2*PI,r[i]);
                else l[i]=0,r[i]=0;
                //printf("%f %f\n",l[i],r[i]);
            }
        }
        fin[i]=(r[i]-l[i])/(2*PI);
    }
    for(int i=0;i<n;i++) printf("%.10f\n",fin[i]);
    return 0;
}


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

p = 10 ** 9 + 7

suma = 0
dsum = 0
for i in a:
  suma = (suma + i) % p
  dsum = (dsum + i ** 2) % p

sa2 = (suma ** 2) % p
ans2 = (sa2 - dsum) % p
if ans2 % 2  == 0:
  ans = ans2 // 2
else:
  ans = (ans2+p) // 2
print(ans)

Measured memory_bytes: 94140
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, WM = map(int, input().split())
V = [0] * N
W = [0] * N

for i in range(N):
    V[i], W[i] = map(int, input().split())
dp = [0] * (WM + 1)

for i in range(N):
    for w in range(WM + 1):
        if w - W[i] >= 0:
            dp[w] = max(dp[w - W[i]] + V[i], dp[w])
print(dp[-1])


Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  ll a;
  double b;
  cin >> a >> b;
  b += 0.001;
  ll nb = b * 100;
  cout << a * nb / 100 << endl;
  return 0;
}


Measured memory_bytes: 3748
n = gets.split(//).map(&:to_i)

count = 0
flg = 0
last  = "s"
n.each do |s|
    if s == last
        count = count + 1
        flg = 1 if count >= 2
    else
        count = 0
    end
    last = s.to_i
end

result = "No"
result = "Yes" if flg == 1
puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;
int dy[2] = {0, 0};
int dx[2] = {-1, 1};

struct DJset {
	vi parent, rank, size;

	DJset(int n) : parent(n), rank(n, 1), size(n, 1) {
		rep(i,0,n) {
			parent[i] = i;
		}
	}

	int find(int i) {
		if(i == parent[i]) return i;
		return parent[i] = find(parent[i]);
	}

	void merge(int u, int v) {
		u = find(u); v = find(v);
		if(u == v) return;
		if(rank[u] > rank[v]) swap(u, v);
		parent[u] = v;
		if(rank[u] == rank[v]) ++rank[v];
		size[v] += size[u];
	}
};

int n, m;
vector<pii> edge;

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	cin >> n >> m;
	rep(i,0,m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge.pb(mp(a,b));
	}

	DJset myset(n);
	vl ret = vl(m+1);
	ll cnt = 0;
	per(i,0,m) {
		int a = edge[i].F;
		int b = edge[i].S;
		a = myset.find(a);
		b = myset.find(b);
		if(a == b) {
			ret[i] = ret[i+1];
			continue;
		}
		int x = myset.size[a];
		int y = myset.size[b];
		cnt -= (ll)x*(x-1) / 2;
		cnt -= (ll)y*(y-1) / 2;
		myset.merge(a,b);
		a = myset.find(a);
		x = myset.size[a];
		cnt += (ll)x*(x-1) / 2;
		ret[i] = cnt;
	}

	rep(i,1,sz(ret)) {
		cout << ret[0] - ret[i] << endl;
	}
	return 0;
}

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

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

    static class TaskA_147 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println(a + b + c >= 22 ? "bust" : "win");
        }

    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string str;
    cin>>str;
    vll right,left;
    ll len=str.size();
    ll count=1;
    char ch=str[0];
    for(ll i=1;i<len;i++)
    {
        if(ch==str[i])
        {
            count++;
        }
        else 
        {
            if(ch=='R')
            {
                right.push_back(count);
            }
            else
            {
                left.push_back(count);
                
            }
            count=1;
            ch=str[i];
        }
    }
    left.push_back(count);
    
    ll result[len];
    for(ll i=0;i<len;i++)
    {
        result[i]=0;
    }
    ll size=left.size();
    ll store,pos=0;
    for(ll i=0;i<size;i++)
    {
        pos+=right[i];
        store=(right[i])/2;
        result[pos]+=store;
        store=(left[i]+1)/2;
        result[pos]+=store;
        store=(right[i]+1)/2;
        result[pos-1]+=store;
        store=(left[i])/2;
        result[pos-1]+=store;
        pos+=left[i];
    }
    for(ll i=0;i<len;i++)
    {
        cout<<result[i]<<" ";
    }
    return 0;
}

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

int main(){
    int A,B,C,D;

    cin >> A >> B >> C >> D;
    
    int left = A +B ;
    int right = C + D ;

    if(left > right){
        cout << "Left" <<endl;
    }else if(left == right) {
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;
    }
}

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

const long long MOD = 1000000007;



void solve(long long H, long long W, vector<string> a){
    ll dp[H][W] ={};
    dp[0][0] = 1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i+1<H && a[i+1][j] == '.'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            if(j+1<W && a[i][j+1] == '.'){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= MOD;
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    vector<string> a(H);
    for(int i = 0 ; i < H ; i++){
        cin >> a[i];
    }
    solve(H, W, std::move(a));
    return 0;
}


Measured memory_bytes: 9088
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main()
{
	stack<int> S;
	stack<pair<int,int>> T;
	vector<int> V;
	int t;
	char s[20010];int sum=0;
	for(int i=0;cin>>s[i];i++)
	{
		if(s[i]=='\\')
		{
			S.push(i);
		}
		else if(s[i]=='/')
		{
			if(!S.empty())
			{
				int j=S.top();S.pop();
				sum+=i-j;
				int a=i-j;
				for(;!T.empty()&&T.top().first>j;)
				{
					a+=T.top().second;T.pop();
				}
				T.push(make_pair(j,a));
			}
		}
	}
	cout<<sum<<endl;
	cout<<T.size();
	for(;!T.empty();V.push_back(T.top().second),T.pop());
	reverse(V.begin(),V.end());
	for(int i=0;i<V.size();i++)
	{
		cout<<" "<<V[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3200
let () =
    let main () =
        let n, k, s = Scanf.scanf "%d %d %d" (fun n k s -> n, k ,s) in
        if s > n - k then (
            for i = 1 to k do Printf.printf "%d " s done;
            for i = k + 1 to n do Printf.printf "1 " done;
        ) else (
            for i = 1 to k do Printf.printf "%d " s done;
            for i = k + 1 to n do Printf.printf "100000000 " done;
        );
        print_newline ()
    in
    main ()

Measured memory_bytes: 3712
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CLower {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> H(N);
        REP(i, N) in>>H[i];
        vc<int> dp(N, 0);
        for(int i=N-2;0<=i;--i){
            if(H[i]>=H[i+1]) dp[i] = dp[i+1] + 1;
            else dp[i] = 0;
        }
        out<<*max_element(ALL(dp))<<'\n';
    }
};


int main() {
	CLower solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;
double dp[100+1][100+1]={-1};
int main(){
	double a,b,c;
	int n;
	int ans=0;
	cin >> n >> a >> b >> c;
	double s;
	cin >> s;
	dp[1][0]=c/a;
	dp[1][1]=(s+c)/(1*b+a);
	for(int i=2; i<=n; ++i){
		double tmp;
		cin >> tmp;
		for(int j=0; j<=i; ++j){
			if(j==i) {
				dp[i][j]=(dp[i-1][j-1]*((j-1)*b+a)+tmp)/(j*b+a);
			} else if(j==0) {
				dp[i][j]=dp[i-1][j];
			} else {
				dp[i][j]=max(dp[i-1][j],(dp[i-1][j-1]*((j-1)*b+a)+tmp)/(j*b+a));
			}
		}
	}
	for(int i=0; i<=n; ++i)
		if(ans<dp[n][i])
			ans=dp[n][i];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mod 1000000007
int fun(int x,int n)
{
    int ans=1;
    while(n>0)
    {
        if(1&n)
        ans=(ans*x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return ans;
}
signed main()
{
   int n;
   cin>>n;
   if(n==1)
   {
       cout<<0<<endl;
       return 0;
   }
int  ans=fun(10,n);
 ans=(ans-(2*fun(9,n))%mod+mod)%mod;
 ans=(ans+fun(8,n))%mod;
 cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3604
s=input()
q=int(input())
cn=0
l1=""
l2=""
for i in range(q):
    p=input()
    if p=="1":
        cn+=1
    else:
        _,f,c=p.split()
        if f=="1":
            if cn%2==0:
                l1+=c
            else:
                l2+=c
        else:
            if cn%2==1:
                l1+=c
            else:
                l2+=c
if cn%2==1:
    s=s[::-1]
    l1,l2=l2,l1
print(l1[::-1]+s+l2)

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353

vector<int> tree;

int solve(int a,int b,int i,int left,int right){
  if(right<=a||b<=left){
    return 0;
  }
  if(a<=left&&right<=b){
    return tree.at(i);
  }
  int x=solve(a,b,2*i+1,left,(left+right)/2);
  int y=solve(a,b,2*i+2,(left+right)/2,right);
  return max(x,y);
}

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> XD(N);
  for(int i=0;i<N;i++){
    cin>>XD.at(i).first>>XD.at(i).second;
  }
  sort(XD.begin(),XD.end());

  int n=1;
  while(n<N){
    n<<=1;
  }

  tree.resize(2*n-1,N-1);
  for(int i=0;i<N;i++){
    int k=upper_bound(XD.begin(),XD.end(),make_pair(XD.at(i).first+XD.at(i).second,0))-XD.begin();
    tree.at(n-1+i)=k-1;
  }
  for(int i=n-2;i>=0;i--){
    tree.at(i)=max(tree.at(2*i+1),tree.at(2*i+2));
  }

  vector<int> finish(N);
  for(int i=N-1;i>=0;i--){
    int k=tree.at(n-1+i);
    finish.at(i)=solve(i,k+1,0,0,n);
    tree.at(n-1+i)=finish.at(i);
    int m=n-1+i;
    while(m>0){
      m=(m-1)/2;
      tree.at(m)=max(tree.at(2*m+1),tree.at(2*m+2));
    }
  }

  vector<long long> dp(N+1);
  dp.at(N)=1;
  for(int i=N-1;i>=0;i--){
    dp.at(i)=dp.at(i+1)+dp.at(finish.at(i)+1);
    dp.at(i)%=MOD;
  }
  cout<<dp.at(0)<<endl;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;

string str[2];

int main()
{
  ios::sync_with_stdio(0);
  string s;
  cin >> s;

  bool rev = 0;

  int q;
  cin >> q;
  while(q--)
  {
    int t;
    cin >> t;
    if(t == 1)
    {
      rev ^= 1;
    }
    else
    {
      int f;
      string c;
      cin >> f >> c;
      f--;
      str[rev ^ f] += c;
    }
  }
  reverse(str[rev].begin(), str[rev].end());
  if(rev)
    reverse(s.begin(), s.end());
  cout << str[rev] << s << str[rev^1] << endl;

  return 0;
}

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

using namespace std;

int main(){

    vector<int> road(4, 0);
    int city = 0;

    for(int i = 0; i < 6;i++){
        cin >> city;
        road[city - 1]++;
    }

    //std::sort(road.begin(),road.end());

    for(int i = 0; i < 4;i++){
        //cout << road[i];
        if(road[i] == 0){
            cout << "NO";
            return 0;
        }else if(road[i] > 2){
            cout << "NO";
            return 0;
        }
    }

    cout << "YES";

}

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

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), X = sc.nextInt(), no = N, i = 0, t = 0;
		int[] a = new int[N];
		while (no-->0) {
			a[i++] = sc.nextInt();
			t+=a[i-1];
		}
		Arrays.sort(a);
		System.out.println(((X-t)/a[0])+N);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

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

int main(){
  int n;
  cin >> n;
  
  int a;
  int ans = 1000000009;
  int key = 0;
  for (int i = 0; i < n; i++){
    key = 0;
    cin >> a;
    while (a%2 == 0){
      a /= 2;
      key++;
    }
    if (key < ans){
      ans = key;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
left = 0
right = len(s)
mid = (left + right) // 2
cnt = 0

for i in t:
    while left < right:
        if i == s[mid]:
            cnt += 1
            break
        elif i < s[mid]:
            right = mid
        else:
            left = mid + 1
        mid = (left + right) // 2
    left = 0
    right = len(s)
    mid = (left + right) // 2
print(cnt)


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


int main(){
  int h,w;cin>>h>>w;
  char s[h][w];

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

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
	if(i-1>0&&j-1>0&&i+1<h&&j+1<w){
	  char a=s[i][j];
	  if(a==s[i+1][j]||a==s[i][j+1]||a==s[i-1][j]||a==s[i][j-1]){
	    
	  }else{cout<<"No"<<endl;return 0;}
	}
      }
    }
  }
  cout<<"Yes"<<endl;

  
  return 0;
}


Measured memory_bytes: 256