akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize, k: usize,
        a: [usize1; n],
    }
    let mut pre = vec![None; n];
    let mut cur = 0;
    let mut step = 0;
    while step < k {
        if pre[cur].is_some() && step - pre[cur].unwrap() <= k - step {
            let x = step - pre[cur].unwrap();
            // println!("{}", x);
            step = k - (k - step) % x;
        } else {
            if cur < n {
                pre[cur] = Some(step);
            }
            cur = a[cur];
            step += 1;
            // println!("hoge");
        }
        // println!("{} {}", cur, step);
    }
    println!("{}", cur + 1);
}


Measured memory_bytes: 6812
// Created by ...Saikat
#include <bits/stdc++.h>
using namespace std;
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define fr(i,n) for(int i=0;i<(n);++i)
#define frI(i,a,n) for(int i=a;i<=(n);++i)
#define frD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;
using ld = long double;
#define len(x) ((int)x.length())
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
const int MOD = 1e9+7,inf = 1e9 , N = 2e5 + 1;
const ll INF = 1e18; ld tic,tac;
#define endl '\n'
ll dp[101][100001];
ll ans(ll w[],ll v[], int i, ll remsum,ll n)
{
	if(dp[i][remsum]!=-1)
	{
		return dp[i][remsum];
	}
	if(i>=n)
	{
		return dp[i][remsum]=0;
	}
	ll ans1,ans2;
	if(w[i]>remsum)
	ans1=0;
	else
	ans1=v[i]+ans(w,v,i+1,remsum-w[i],n);
	ans2=ans(w,v,i+1,remsum,n);
	return dp[i][remsum]=max(ans1,ans2);
}
void solve()
{
    ll n,totw;
    cin>>n>>totw;
	ll w[n],v[n];
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=totw;j++)
			dp[i][j]=-1;
	}
	ll a=ans(w,v,0,totw,n);
	cout<<a<<endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 82516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;

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

	ll H, W;
	int N;
	cin >> H >> W >> N;

	map<P,ll> mp;
	rep(i,N){
		ll a,b;
		cin >> a >> b;
		a--;
		b--;

		FOR(i,-2,1){
			FOR(j,-2,1){
				if(0 <= a+i && a+i < H-2 && 0 <= b+j && b+j < W-2){
					P p = make_pair(a+i,b+j);
					mp[p]++;
				}
			}
		}
	}

	ll ans[10] = {};
	ll sum = 0;
	for(auto x : mp) {
		ans[x.second]++;
		sum++;
	}
	ans[0] = (H-2)*(W-2) - sum;
	rep(i,10) cout << ans[i] << endl;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    pq<P> q;
    int t, d;
    rep (i, n) {
        cin >> t >> d;
        q.push({d, t});
    }

    set<int> st;
    int pt = 0;
    int kind = 0;
    pqr<P> dbl;

    rep (i, k) {
        auto p = q.top();
        q.pop();

        if (st.find(p.second) != st.end())
            dbl.push(p);
        else
            kind++;
        st.insert(p.second);
        pt += p.first;
    }
    int ans = 0;
    ans = max(ans, pt + kind * kind);

    while (!q.empty()) {
        auto p = q.top();
        q.pop();

        if (st.find(p.second) == st.end()) {  // if new kind
            if (!dbl.empty()) {
                auto ne = dbl.top();
                dbl.pop();
                pt = pt - ne.first + p.first;
                kind++;
            }
        }
        ans = max(ans, pt + kind * kind);

        st.insert(p.second);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	double R;
	cin >> R;
	cout <<2* R * 3.141592 << endl;
}



Measured memory_bytes: 3744
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a;
    cin >> a;
    int r = 0;
    if(a%2 == 0){
        cout << a;
    }
    else
    {
        cout << a*2;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	char c;
	cin>>c;
	if(c>='a'&&c<='z')cout<<'a';
	else cout<<'A';
	//fixed<<setprecision(3)
	return 0;
}


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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

ll calculateMod(ll n, ll expo, ll modSeed){
  ll ret = 1;
  rep(i, expo){
    ret *= n;
    ret = ret%modSeed;
  }
  return ret;
}

int main(){
    ll K;
    cin >> K;
    vector<ll> mods(K+1);
    mods.at(1) = 7%K;
    for(int i=2;i<=K;i++){
      mods.at(i) = (mods.at(i-1) * 10 + 7)%K;
    }
    for(int i=1;i<=K;i++){
      if(mods.at(i)==0){
        printl(i);
        return 0;
      }
    }
    printl(-1);
}


Measured memory_bytes: 11068
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
    lld n;
    lld a[100] = {};

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

    lld sol = pow(3,n);
    lld x = 1;
    
    for(int i = 0; i < n; i++)
    {
        if (a[i] % 2 == 0)
        {
            x *= 2;
        }
    }

    sol -= x;

    cout << sol << endl;

    return 0;
}

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

using P = pair<int, int>;

constexpr int MAX_N = 1e5 + 7;

int N;
vector<vector<int>> edges(MAX_N+1), costs(MAX_N+1);
int colors[MAX_N+1];

void dfs(int cur) {
  queue<int> que;
  que.push(cur);

  while (!que.empty()) {
    int u = que.front();
    que.pop();

    for (int i{}; i < edges[u].size(); ++i) {
      int v = edges[u][i];
      int w = costs[u][i];
      if (colors[v] >= 0)
        continue;
      colors[v] = w % 2 == 0 ? colors[u] : !colors[u];
      que.push(v);
    }
  }
}

int main() {
  fill_n(colors, MAX_N+1, -1);

  cin >> N;

  int u, v, w;
  for (int i{}; i < N - 1; ++i) {
    cin >> u >> v >> w;
    edges[u].push_back(v);
    costs[u].push_back(w);
    edges[v].push_back(u);
    costs[v].push_back(w);
  }

  colors[u] = 0;
  dfs(u);
  for (int i{1}; i <= N; ++i) {
    cout << colors[i] << endl;
  }
}


Measured memory_bytes: 11904
package main

import "fmt"

var (
	N, A, B, C int
	l          []int
)

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func min(nums ...int) int {
	ans := nums[0]
	for _, v := range nums {
		if v < ans {
			ans = v
		}
	}
	return ans
}

func dfs(cur, a, b, c int) int {
	if cur == N {
		if min(a, b, c) > 0 {
			return abs(a-A) + abs(b-B) + abs(c-C) - 30
		}
		return 1000000000
	}
	ret0 := dfs(cur+1, a, b, c)
	ret1 := dfs(cur+1, a+l[cur], b, c) + 10
	ret2 := dfs(cur+1, a, b+l[cur], c) + 10
	ret3 := dfs(cur+1, a, b, c+l[cur]) + 10
	return min(ret0, ret1, ret2, ret3)
}

func main() {
	fmt.Scan(&N, &A, &B, &C)
	l = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&l[i])
	}
	fmt.Println(dfs(0, 0, 0, 0))
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
    long long n,p,temp,ans=1;
    int count=0;
    cin >> n >> p;
    if(n>=40){
        cout << 1 << endl;
        return 0;
    }
    if(n==1){
        cout << p << endl;
        return 0;
    }
    for(long long i=2; i<=p; i++){
        temp=1;
        for(int j=0; j<n; j++)temp*=i;
        while(p%temp==0){
            ans*=i;
            p/=temp;
        }
        while(p%i==0)p/=i;
        if(temp>=p)break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
using namespace std;
#define mop2 998244353

ll numn[100001];

bool cond1(ll maxd){
    if(numn[0] != 1){
        return false;
    }
    for(ll i=0;i<=maxd;i++){
        if(numn[i] == 0){
            return false;
        }
    }
    return true;
}

long long fastPow(long long a, long long b, long long mod=0){
    if(a == 0 and b == 0){
        return -1;
    }
    if(a == 0){
        return 0;
    }
    if(b == 0){
        return 1;
    }
    long long tmp = fastPow(a,b/2,mod);
    if(mod != 0) {
        if (b % 2 == 0) {
            return (tmp * tmp) % mod;
        } else {
            return ((tmp*tmp) % mod * (a % mod)) % mod;
        }
    }else{
        if (b % 2 == 0) {
            return (tmp*tmp);
        } else {
            return tmp * tmp * a;
        }
    }
}

ll calc_ans(ll n, ll mod){
    ll ans = 1;
    for(ll i=1;i<=n;i++){
        ans *= fastPow(numn[i-1], numn[i], mod);
        ans %= mod;
    }
    return ans;
}
int main() {
    

    ll n;
    cin >> n;
    ll maxD = 0;
    bool flag = true;
    for(ll i=0;i<n;i++){
        ll d;
        cin >> d;
        if(i==0 and d != 0){
            flag = false;
        }
        if(maxD < d){
            maxD = d;
        }
        numn[d]++;
    }
    
    if(cond1(maxD) and flag){
        cout << calc_ans(maxD, mop2) << endl;
    }else{
        cout << 0 << endl;
    }



}

Measured memory_bytes: 1024
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    return buf
}

fn main() {
  let line = gets();
  let mut it = line.split_whitespace().map(|n| n.parse::<i64>().unwrap());
  let x = it.next().unwrap();
  let a = it.next().unwrap();
  let b = it.next().unwrap();
  if (x - a).abs() < (x - b).abs() {
    println!("A");
  } else {
    println!("B");
  }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>

char sl[3][128];

int main(){
  int N;
  scanf("%d %s %s %s", &N, sl[0], sl[1], sl[2]);
  int count = 0;
  for(int i = 0; i < N; i++){
    char a = sl[0][i], b = sl[1][i], c = sl[2][i];
  	if(a == b && b == c){
      continue;
    }
    if(a == b || b == c || c == a){
    	count++;
    	continue;
    }
    count += 2;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  string s;
  cin>>s;
  bool a=0,b=0;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='A')
      a=1;
    if(s[i]=='B')
      b=1;
  }

  if(a && b)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N;
int A[200000],F[200000];
int func(int X){
  int ret=0;
  rep(i,0,N)
    ret+=max(0ll,A[i]-X/F[i]);
  return ret;
}
signed main(){
  int K; cin>>N>>K;
  vi a(N),f(N);
  rep(i,0,N) cin>>a[i];
  rep(i,0,N) cin>>f[i];
  sort(ALL(a));
  sort(ALL(f),greater<int>());
  rep(i,0,N) A[i]=a[i];
  rep(i,0,N) F[i]=f[i];
  int left=0,right=1000000000000;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)>K)
      left=mid;
    else
      right=mid;
  }
  int ans=right;
  if(func(left)<=K)
    ans=left;
  cout<<ans<<endl;
  }




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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int dp[100][100][200*80+1000];

int main(){
    int H,W; cin >> H >> W;
    int a[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    int b[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> b[i][j];
        }
    }
    memset(dp,sizeof(dp),0);
    dp[0][0][abs(a[0][0]-b[0][0])]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            for(int k=200*80;k>=0;k--){
                if(dp[i][j][k]){
                    if(i+1<H){
                        dp[i+1][j][k+abs(a[i+1][j]-b[i+1][j])]=1;
                        dp[i+1][j][abs(k-abs(a[i+1][j]-b[i+1][j]))]=1;
                    }
                    if(j+1<W){
                        dp[i][j+1][k+abs(a[i][j+1]-b[i][j+1])]=1;
                        dp[i][j+1][abs(k-abs(a[i][j+1]-b[i][j+1]))]=1;
                    }
                }
            }
        }
    }
    int ans=INF;
    for(int k=0;k<=200*80;k++){
        if(dp[H-1][W-1][k]){
            ans=min(ans,k);
        }
    }
    cout << ans << endl;
}


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

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

  vector<int> h(N);

  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }

  int ans = 0;
  
  for (int height : h) {
    if (K <= height) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
package main

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

func isSecond(n []int) bool {
	if n[0] < n[1] && n[0] < n[2] && n[1] < n[2] {
		return true
	}
	if n[2] < n[0] && n[2] < n[1] && n[1] < n[0] {
		return true
	}
	if n[1] == n[2] && n[0] < n[1] {
		return true
	}
	if n[0] == n[1] && n[2] < n[1] {
		return true
	}
	return false
}

func main() {
	scanner := makeScanner(1024)
	eGetInt(scanner)
	ps := eGetInts(scanner)
	count := 0
	for i := 1; i < len(ps)-1; i++ {
		if isSecond(ps[i-1 : i+2]) {
			count++
		}
	}
	fmt.Println(count)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

ll N,K;
int main(){
    cin>>N>>K;
    ll knjo=1;
    ll syo=1;
    ll ans=1;
    while(syo>0){
        knjo*=K;
        syo=N/knjo;
        if(syo>0)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        Arrays.sort(a);
        long ans = a[n - 1];
        long count = 2;
        for (int i = n - 2; i >= 0; i--) {
            if (count == n) {
                break;
            }
            ans += a[i];
            count++;
            if (count == n) {
                break;
            }
            ans += a[i];
            count++;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 60320
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s;
    cin >> s;
    int a = (s[0] - '0') * 10 + (s[1] - '0'), b = (s[2] - '0') * 10 + (s[3] - '0');
    bool yymm = false, mmyy = false;
    if (1 <= a && a <= 12)
        mmyy = true;
    if (1 <= b && b <= 12)
        yymm = true;
    if (yymm && mmyy)
        cout << "AMBIGUOUS" << endl;
    else if (yymm)
        cout << "YYMM" << endl;
    else if (mmyy)
        cout << "MMYY" << endl;
    else
        cout << "NA" << endl;
}


Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
    [n, m] <- map read . words <$> getLine :: IO [Int]
    let ns = drop 1 $ scanl (+) 0 [1..999]
    let towers_diff = map (\(a,b,c)->(c, a-b)) $ zip3 (drop 1 ns) ns [0..]
    let [(i,_)] = filter (\(i, d)->d == m-n) towers_diff
    print $ (ns !! i) - n

Measured memory_bytes: 764
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
n = Ii()
a = n%1000
if a == 0:
  print(0)
else:
  print(1000-a)

Measured memory_bytes: 9168
#include<stdio.h>
int main(){
int a,b,c,d,e,f;
while(1){
scanf("%d %d",&a,&b);
if(a==0&&b==0)break;
for(c=0;c<a;c++){
	for(d=0;d<b;d++){
        if(c==0||c==a-1||d==0||d==b-1){
	printf("#");
	}else{
	printf(".");

	}
	}
	printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2036
#include<set>  
#include<map> 
#include<stack>
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<climits>  
#include<cstring>  
#include<iostream>  
#include<algorithm>  
using namespace std;
#define eps 1
#define MAXN 100
#define INF 0x3f3f3f3f  
int read(){  
    int f=1,x=0;  
    char c=getchar();  
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}  
    while('0'<=c&&c<='9') x=x*10+c-'0',c=getchar();  
    return f*x;  
}
map<string,int>Map;
string s[MAXN+5],t[MAXN+5];
int main()  
{
	int n,m,earn=0;
	n=read();
	for(int i=1;i<=n;i++)
		cin>>s[i],Map[s[i]]=1;
	m=read();
	for(int i=1;i<=m;i++)
		cin>>t[i];
	for(map<string,int>::iterator i=Map.begin();i!=Map.end();i++)  
	{
		int tmp=0;
		for(int j=1;j<=n;j++)
			if(i->first==s[j])tmp++;
		for(int j=1;j<=m;j++)
			if(i->first==t[j])tmp--;	
		earn=max(earn,tmp);
	}
	printf("%d\n",earn);
    return 0;  
}
/**/

Measured memory_bytes: 256
// ------- PBDS ------ //
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// ------- PBDS ------ //

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define pi 3.1415926535
#define endl "\n"
#define vll vector<ll>
#define MULTI int T; cin >> T; while(T--)
#define all(a)      (a).begin(),(a).end()
#define here cout<<"I'm here\n";
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele<<" "; cout<<endl;
}
vector<ll> adj[200001];
bool vis[200001];

// ------- PBDS ------ //
typedef tree<
// change this for any data-type
string,
null_type,
// change this for any data-type
less<string>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*
    to get the position of an element in set , do
    s.order_of_key(ele);
    this returns the number of elements strictly lesser than ele in set s
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    s.order_of_key(6) : Count of elements strictly smaller than 6 is 2.
    s.order_of_key(25) : Count of elements strictly smaller than 25 is 4.

    to get the element at position k
    s.find_by_order(k);
    returns an iterator to the ele counting from 0
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    *(s.find_by_order(2)) : 3rd element in the set i.e. 6
    *(s.find_by_order(4)) : 5th element in the set i.e. 88
*/

// ------- PBDS ------ //

clock_t time_p=clock();
void purvansh11()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

//BINARY EXPONENTIATION  -- O(log2(b))
ll power(ll a, ll b) {
    /*
        for 3^11 :
        as 11 -> 1011, we mean 3^8 * 3^2 * 3^1
        so multiply for all ones in binary rep of b
    */

    ll ans = 1;
    ll num = a;
    while (b > 0) {
        if (b & 1) ans = ((ans % MOD) * (num % MOD)) % MOD;
        num = ((num % MOD) * (num % MOD)) % MOD;
        b /= 2;
    }
    return ans;
}
ll n;
ll dp[200005];
vector<ll> v;
ll k;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    SPEED;
    cout.precision(8);
    cout << fixed;
    cin>>n>>k;
    for(ll i=0;i<n;i++){ll temp; cin>>temp; v.pb(temp);}
    for(ll i=0;i<=n;i++) dp[i] = 1e9;
    dp[0] = 0;
    dp[1] = 0;
    for(ll i=1;i<=n;i++){
        for(ll j=i-2;j>=max((i-k-1),0LL);j--){
            dp[i] = min(dp[i] , abs(v[j]-v[i-1]) + dp[j+1]);
        }
    }
    // for(ll i=1;i<=n;i++) cout<<dp[i]<<" "; nn;
    cout<<dp[n];
    
    purvansh11();
    return 0;
}

Measured memory_bytes: 9880
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M, X = map(int, input().split())
costs = []
effects = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    effects.append(tmp[1:])

ans = INF
for i in range(1<<N):
    total_costs = 0
    algo = [0] * M
    for k in range(N):
        if 1&i>>k:
            total_costs += costs[k]
            for j, effect in enumerate(effects[k]):
                algo[j] += effect
    is_ok = True
    for a in algo:
        if a < X:
            is_ok = False
            break
    if is_ok:
        ans = min(ans, total_costs)

if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

string S;cin>>S;
  int ans=0;
  for(int i=0;i<4;i++){
    if(S[i]=='+'){ans++;}
    if(S[i]=='-'){ans--;}
  }
  cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

int main() {
    ll R, G, B, N;
    cin >> R >> G >> B >> N;

    ll ans = 0;
    for (int i = 0; i <= 3000; ++i) {
        for (int j = 0; j <= 3000; ++j) {
            if (ceil((double)(N - (i * R + j * G)) / B) == floor((double)(N - (i * R + j * G)) / B) and (1.0 * N - (i * R + j * G)) / B >= 0)
                ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, c=0;
	cin>>n;
	for(int i=0; i<n; i++){
		int d1, d2;
		cin>>d1>>d2;
		if(d1==d2 && c==0)
			c=1;
		else if(c==1 && d1==d2)
			c=2;
		else if(c==2 && d1==d2)
			c=3;
		if(d1!=d2 && c!=3)
			c=0;
	}
	if(c==3)
		cout<<"Yes\n";
	else 
		cout<<"No\n";
	return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 1e9 + 1
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

#define MAX_N 100
#define MAX_M 100

bool kaibun_hantei(string s) {
	REP(i, s.size()) {
		if(s[i] != s[s.size() - 1 - i]) {
			return false;
		}
	}

	return true;
}

int main(){
    string s;
	cin >> s;
	int n = s.size();

	if(!kaibun_hantei(s)) {
		cout << "No" << endl;
		return 0;
	}

	if(!kaibun_hantei(s.substr(0, (n-1)/2))) {
		cout << "No" << endl;
		return 0;
	}

	if(!kaibun_hantei(s.substr((n+1)/2, (n-1)/2))) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

    return 0;
}

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n), c(n);
    for (ll& it : p)
        cin >> it, --it;
    for (ll& it : c)
        cin >> it;
    vector<vector<ll>> pre(n, vector<ll>(1, 0));
    for (int i = 0; i < n; i++) {
        int idx = p[i];
        pre[i].push_back(c[i]);
        while (idx != i) {
            pre[i].push_back(pre[i].back() + c[idx]);
            idx = p[idx];
        }
    }
    ll ans = -(1e18L);
    for (int i = 0; i < n; i++) {
        ll sum = 0, len = (ll)pre[i].size() - 1;
        if (pre[i].back() > 0) {
            ll l = k / len, r = k % len;
            sum += pre[i].back() * l;
            sum += *max_element(pre[i].begin() + (l == 0), pre[i].begin() + r + 1);
            if (l >= 1) {
                ll altsum = pre[i].back() * (l - 1);
                altsum += *max_element(pre[i].begin() + 1, pre[i].end());
                sum = max(sum, altsum);
            }
        } else {
            ll r = min(len, k);
            sum += *max_element(pre[i].begin() + 1, pre[i].begin() + r + 1);
        }
        ans = max(ans, sum);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 218816
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX]; // 重み付き有向グラフの隣接リスト表現

void dijkstra()
{
  priority_queue<pair<int, int> > PQ;
  int color[MAX];
  int d[MAX];
  for (int i = 0; i < n; i++)
  {
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while (!PQ.empty())
  {
    pair<int, int> f = PQ.top();
    PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    // 最小値を取り出し、それが最短でなければ無視
    if (d[u] < f.first * (-1))
      continue;

    for (int j = 0; j < adj[u].size(); j++)
    {
      int v = adj[u][j].first;
      if (color[v] == BLACK)
        continue;
      if (d[v] > d[u] + adj[u][j].second)
      {
        d[v] = d[u] + adj[u][j].second;
        // priority_queueはデフォルトで大きい値を優先するため-1をかける
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }
  for (int i = 0; i < n; i++)
  {
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main()
{
  int k, u, v, c;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> u >> k;
    for (int j = 0; j < k; j++)
    {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }
  dijkstra();
  return 0;
}


Measured memory_bytes: 7992
/// input macro from https://qiita.com/tanakh/items/1ba42c7ca36cd29d0ac8
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input!(n: usize, a: [u64; n]);

    let mut sum: u64 = 0;
    let mut last_hight = 0;
    let mut plus_height = 0;

    for ai in a {
        if last_hight > ai {
            sum += last_hight - ai;
        }
        else {
            last_hight = ai;
        }
    }

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


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  string s,t,u;
  
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  
  if (u == s) a--;
  else b--;
  
  cout << a << ' ' << b << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
int gcd(int a,int b) {
  if(b==0) return a;
  return gcd(b,a%b);
}
using namespace std;
signed main() {
  int n,k,gcm;
  cin>>n>>k;
  int a[n];
  int ma=0;
  rep(i,n) {
    cin>>a[i];
    ma=max(ma,a[i]);
  }
  if(n==1) {
    if(k==a[0]) {
      cout<<"POSSIBLE"<<endl;
    }
    else {
      cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
  }
  rep(i,n-1) {
    if(i==0) gcm=gcd(a[i],a[i+1]);
    else gcm=gcd(gcm,a[i+1]);
  }
  if(k<=ma&&k%gcm==0) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;
using ll = long;
const ll N = 200010;
ll a[N], n, k, pos;
int main()
{
	scanf("%lld%lld", &n, &k);
	for (ll i = 1; i <= n; i++)
		scanf("%lld", a + i);
	for (ll i = 1; i < n; i++)
		if (a[i] + a[i + 1] >= k)
		{
			pos = i;
			break;
		}
	if (pos == 0)
		return puts("Impossible"), 0;
	puts("Possible");
	for (ll i = 1; i < pos; i++)
		printf("%lld\n", i);
	for (ll i = n -1; i > pos ; i--)
		printf("%lld\n", i);
	printf("%lld", pos);
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
bool comp(ll &a,ll &b){
  return a>b;
}
int main(){
  int x,y,z,k;cin>>x>>y>>z>>k;
  ll a[1010],b[1010],c[1010];
  rep(i,x) cin>>a[i];
  rep(i,y) cin>>b[i];  
  rep(i,z) cin>>c[i];  
  ll d[1000010];
  int ss=0;
  rep(i,x){
    rep(j,y){
      d[ss]=a[i]+b[j];
      ss++;
    }
  }
  sort(d,d+ss,comp);
  sort(c,c+z,comp);
  vector<ll> res;
  rep(i,z){
    rep(j,ss){
      if(i*j>k) break;
      res.push_back(c[i]+d[j]);
    }
  }
  sort(res.begin(),res.end(),comp);
  rep(i,k){
    prin(res[i]);
  }

  
  

  

  return 0;
}


Measured memory_bytes: 18284
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int fct[200009],invfct[200009] ;
int bigmod(int a , int b)
{
    if(b==0) return 1 ;
    int x=bigmod(a,b/2) ;
    x=((x%mod) * (x%mod))%mod ;
    if(b%2) x=((x%mod) * (a%mod))%mod ;
    return x ;
}
int findpath(int x , int y , int a , int b)
{
    int k=((fct[a+b-x-y])*(invfct[a-x]%mod))%mod ;
    //cout<<"k "<<k<<" init "<<b-y<<" "<<a-x<<" "<<invfct[b-y]<<endl ;
    k=(k*(invfct[b-y]%mod))%mod ;
   // cout<<x<<" "<<y<<" final "<<a<<" "<<b<<" "<<k<<endl ;
    return k%mod ;
}
int32_t main()
{
    int n,m,a,b ; cin>>n>>m>>a>>b ;
    fct[0]=1 ; fct[1]=1 ; invfct[0]=1 ; invfct[1]=1 ;
    for(int i = 2 ; i <= n+m ; i++)
    {
        fct[i]=(i*fct[i-1])%mod ;
        invfct[i]=bigmod(fct[i],mod-2) ;
    }
    //cout<<invfct[2]<<" "<<fct[2]<<endl ;
    int p=n-a,ans=0 ;
    for(int i = b+1 ; i <= m ; i++)
    {
       // cout<<p<<" nw "<<i<<endl ;
        int k=(findpath(1,1,p,i)*findpath(p+1,i,n,m))%mod ; k%=mod ;
        //cout<<"k : "<<k<<endl ;
        ans+=k ; ans%=mod ;
    }
    cout<<ans<<endl ;
}


Measured memory_bytes: 6700
#include <bits/stdc++.h>
#define int long long
#define vi vector <int>
#define si set <int>
#define mii map <int,int>
#define pii pair <int,int>
#define endl "\n"
#define FOR(P,Q) for(int P=0;P<(Q);P++)
#define FORR(P,Q) for(int P=1;P<=(Q);P++)
#define rep(P,R,Q) for(int P=(R);P<=(Q);P++)
#define repb(P,R,Q) for(int P=(R);P>=(Q);P--)
#define pb push_back
#define eb emplace_back
#define bug(j) cerr<<j<<" "
#define NL cerr<<endl
#define D1(arr,a) rep(i,1,a) bug(arr[i]) 
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;

const int mod = 1e9+7;
    
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif
	int tces=1;
	// cin>>tces;
	while(tces--){
		// int n;
		// cin>>n;
		// vi v(n+5);
		// FORR(i,n){
		// 	cin>>v[i];
		// }
		int n,k;
		cin>>n>>k;
		int ncr[2005][2005];
		memset(ncr,0, sizeof(ncr));
		FOR(i,n+1){
			ncr[i][0]=1;
		}
		FORR(i,n){
			FORR(j,n){
				ncr[i][j]=(ncr[i-1][j-1]%mod+ncr[i-1][j]%mod)%mod;
			}
		}
		FORR(i,k){
			int ans=(ncr[k-1][i-1]%mod * ncr[n+1-k][i]%mod)%mod;
			cout<<ans<<endl;
		}
		// unordered_map<int,int> m;
		// FORR(i,n-1){
		// 	m[v[i+1]-v[i]]++;
		// }

	}
	
return 0;
}

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

int a[3];

int main(){
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if ((a[0] == a[1] && a[1] != a[2]) || (a[0] != a[1] && a[1] == a[2])) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main() {
    rep(i,10000){
        int x; cin >> x;
        if(x==0)
        break;
        else
        cout << "Case " << i+1 << ": " << x << endl;
    }

    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1)*a%MOD;
	}
}
int main()
{   
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int c=0;
	if(n%2)
	{
		if(a[0]==!0)
		{
			cout<<0<<endl;
			return 0;
		}
		for(int i=1;i<n;i+=2)
		{
			if(a[i]!=i+1 || a[i+1]!=i+1)
				{
					cout<<0<<endl;
					return 0;
				}
				c++;
		}
	}
	else
	{
		for(int i=0;i<n;i+=2)
		{
			if(a[i]!=i+1 || a[i+1]!=i+1)
			{
				cout<<0<<endl;
				return 0;
			}
			c++;
		}
	}
	cout << mpow(2,c) << endl;
return 0;
}

Measured memory_bytes: 640
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# 1 <= A <= 10**6
# 1 <= B <= 10**12
# 1 <= N <= 10**12
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]

if N >= B:
    ans_x = B - 1
else:
    ans_x = N

ans = math.floor(A*ans_x/B) - A*math.floor(ans_x/B)

print(ans)

Measured memory_bytes: 72900
N = int(input())
H = list(map(int, input().split()))

ans = 0

def solve(arr):
  global ans
  min_h = min(arr)
  ans += min_h
  new_arr = [x - min_h for x in arr]
  sub_arr = []
  for x in new_arr:
    if x == 0:
      if len(sub_arr) > 0:
        solve(sub_arr)
        sub_arr = []
    else:
      sub_arr.append(x)
  else:
    if len(sub_arr) > 0:
      solve(sub_arr)

solve(H)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int ans = 0;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph& G, int v, int n, int cnt) {
    seen[v] = true; // v を訪問済にする
    if (cnt == n - 1) {
        bool ok = true;
        for (int i = 0; i < n; i++) {
            if(!seen[i]){
                ok = false;
            }      
        }
        if (ok) ans++;
        return;
    }

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        cnt++;
        dfs(G, next_v,n, cnt); // 再帰的に探索
        cnt--;
        seen[next_v] = false;
    }
}

int main() {

    // 頂点数と辺数
    int n, m; cin >> n >> m;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    // 頂点 s をスタートとした探索
    int cnt = 0;
    seen.assign(n, false); // 全頂点を「未訪問」に初期化
    dfs(G, 0, n, cnt);

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

Measured memory_bytes: 3580
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	long long n;
	cin >> n;
	vector<long> a(n,0);
	for(long i=0;i<n;i++){
		cin >> a[i];
	}
	
	sort( a.begin(),a.end() );
	
	for(long i=0;i<n-1;i++){
		if(a[i]==a[i+1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1792
from queue import deque

INF = 2**31-1
n, s = map(int, input().split())
A = list(map(int, input().split()))
q = deque()
t = 0
ans = INF
for a in A:
    t += a
    q.append(a)
    if t < s:
        continue
    while t >=s:
        t -=q.popleft()
    ans = min(ans,len(q)+1)
print(ans if ans < INF else 0)


Measured memory_bytes: 18224