akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, nums[200009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int mx=0;
    cin>>N;
    rep(i,N){
        int x; cin>>x;
        nums[x] = nums[x-1]+1;
        if(nums[x]>mx) mx=nums[x];
    }
    cout1(N-mx);
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main(){

	int n, len, cnt;
	string str;
	
	n = 0;
	while(getline(cin, str)){
		len = str.length();
		cnt = 0;
		for(int i=len-1; i>=0; i--){
			if(str[i] >= '0' && str[i] <= '9'){
				n += (str[i] - '0') * pow(10, cnt);
				cnt++;
			}
			else {
				cnt = 0;
			}
		}
	}

	cout << n << endl;

	return 0;

}

Measured memory_bytes: 1216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC168B
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string kin = Console.ReadLine();
            string s = Console.ReadLine();
            int k = int.Parse(kin);

            string result;
            if (s.Length <= k)
            {
                result = s;
            }
            else
            {
                result = s.Substring(0, k) + "...";
            }
            Console.WriteLine(result);

#if DEBUG
            Console.WriteLine();
#endif
        }
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define prvp(a) for(auto x : a) cout << "{" << x.ff << ',' << x.ss << "}";cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(int a, int b){return (int)((long long) a * b % mod);}
inline int modexpo(int a, int b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(int a, int b){ return mul(a, modexpo(b, mod - 2));}

clock_t time_p = clock();

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

void pre(){ // Reset each global variable (esp. for graphs)
  
}

const int N = 1e6 + 5;

void solve(){
  vector<int> prime;
  vector<bool> isPrime(N, true);
  isPrime[0] = isPrime[1] = 0;

  for(ll i = 2; i < N; i++){
    if(isPrime[i]){
      prime.push_back(i);
      for(ll j = i * i; j < N; j += i){
        isPrime[j] = 0;
      }
    }
  }
  int x; cin >> x;
  auto itr = *lower_bound(all(prime), x);
  cout << itr << '\n';
}

int main(){
  fastio

  pre();

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

  ktj();
}


Measured memory_bytes: 1020
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int [][][] array = new int [4][3][10];
		for (int i = 0; i < n; i++) {
			int b = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			int v = scan.nextInt();
			
			array[b-1][f-1][r-1] += v;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 10; k++) {
					System.out.print(" " + array[i][j][k]);
					
				}
				System.out.println();
			}
			if (i !=3) {
				System.out.println("####################");
			}
		}
		
 	}
}



Measured memory_bytes: 29276
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	int a[n];
	int b[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&a[i]);
	}
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&b[i]);
	}
	int count=0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i]>b[i])
		{
			count=count+a[i]-b[i];
		}
	}
	printf("%d\n",count );
}

Measured memory_bytes: 128
#include <stdio.h>

int main (void){
    int N;
    scanf("%d", &N);

    int l[N];
    for (int i = 0; i < N; i++){
        scanf("%d", &l[i]);
    }

    int max = l[0];
    for (int i = 1; i < N; i++){
        if (max < l[i]){
            max = l[i];
        }
    }

    int sum = 0;
    for (int i = 0; i < N; i++){
        sum += l[i];
    }
    sum -= max;

    if (max < sum){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b,c,f[15]; 
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);in(c);
	f[a]++;
	f[b]++;
	f[c]++;
	if(f[5]==2&&f[7]==1)printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;

	void solve() {
		int n = readNum();
		int[] ans = new int[n];
		for (int i = 0; i < n - 1; i++) {
			int[] ia = readNums();
			int c = ia[0];
			int s = ia[1];
			int f = ia[2];
			for (int j = 0; j <= i; j++) {
				int ss = s;
				while (ss < ans[j])
					ss += f;
				ans[j] = ss + c;
			}
		}
		pln(ans);
	}

	// -----------------------------------------------------
	// 2018/04/26 r2
	// -----------------------------------------------------
	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	long abs(long a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	long max(long a, long b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	long min(long a, long b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	long readLong() {
		String line = readLine();
		return plong(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	long[] readLongs() {
		String[] flds = readFlds();
		long[] nums = new long[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = plong(flds[i]);
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	void pln(int[] ia) {
		for (int i = 0; i < ia.length; i++)
			pln(ia[i]);
	}

	void pln(long[] la) {
		for (int i = 0; i < la.length; i++)
			pln(la[i]);
	}

	static BufferedReader _in;
	static PrintWriter _out;
	static boolean _bElapsed = false;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (_bElapsed)
			System.err.println((end - start) + "ms");
	}
}


Measured memory_bytes: 21460
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

signed main(){

  int N, Z, W, ans = (1<<30);
  vector<int> a;
  

  cin>>N>>Z>>W;

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

  ans = abs(a.back() - W);

  if(a.size() >= 2) ans = max(ans, (int)abs(a.back() - a[a.size()-2]));

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


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.List
import Control.Monad

main = do
    n <- readLn :: IO Int
    ps <- map read . words <$> getLine :: IO [Double]
    print . VU.sum . VU.drop (n `div` 2 + 1) $ toss n ps

toss n ps = VU.create $ do
    vec <- VUM.replicate (n + 1) 0
    VUM.write vec 0 1
    forM_ ps $ \p -> do
        forM_ [n,n-1..1] $ \i -> do
            p1 <- VUM.read vec i
            p2 <- VUM.read vec (i-1)
            VUM.write vec i (p1 * (1-p) + p2 * p)
        p0 <- VUM.read vec 0
        VUM.write vec 0 (p0*(1-p))
    return vec

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

int main() {
	long long N, M, K; cin >> N >> M >> K;
	vector<long long>A(N, M);
	for (long long i = 0; i < K; i++) {
		long long B; cin >> B;
		A.at(B - 1)++;
	}
	for (long long i = 0; i < N; i++) {
		cout << (A.at(i) - K > 0 ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 4048
#include <stdio.h>
int main(){
	int x,y,z;
	scanf("%d %d %d",&x,&y,&z);
	getchar();
	if(x==y && y!=z)
	{
		printf("Yes\n");
	}
	else if (x==z && y!=x){
		printf("Yes\n");
	}
	else if (y==z && x!=y){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1644
n, m = map(int, raw_input().strip().split())
div = []
for i in xrange(1, int(m ** 0.5) + 1):
    if i * i == m: div.append(i)
    elif m % i == 0:
        div.append(i)
        div.append(m // i)
div.sort()

ans = 1
for d in div:
    if m // d < n:
        break
    else:
        ans = d

print ans


Measured memory_bytes: 29164
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {

	int n;	
	cin >> n;

	vector<int> a(3 * n);
	for (int i = 0;i < 3 * n;i++) {
		cin >> a[i];
	}
	
	priority_queue<int,vector<int>,greater<int>> pq1;
	priority_queue<int> pq2;

	vector<ll> sum1(n + 1);
	vector<ll> sum2(n + 1);

	for (int i = 0; i < n;i++) {
		pq1.push(a[i]);
		sum1[0] += a[i];
		pq2.push(a[i + 2 * n]);
		sum2[n] += a[i + 2 * n];
	}

	//cout << sum1[0] << " " << sum2[n] << endl;
	

	for (int i = n; i < 2 * n;i++) {

		pq1.push(a[i]);
		sum1[i - (n - 1)] = sum1[i - n] - pq1.top();
		pq1.pop();
		sum1[i - (n - 1)] += a[i];
		//cout << sum1[i - (n - 1)] << " " << sum1[i - n] << endl;

	}

	for (int i = 2 *n-1; i>=  n;i--) {

		pq2.push(a[i]);
		sum2[i - n] = sum2[i - n + 1] - pq2.top();
		pq2.pop();
		sum2[i - n] += a[i];

	}



	ll ans = -BIG_NUM;
	for (int i = 0; i <= n;i++) {
		ans = max(ans, sum1[i] - sum2[i]);
		//cout <<i << " " << sum1[i] << " " << sum2[i] << endl;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	ll n;
	cin>>n;
	ll m=n;
	if(n==1)
	{
		cout<<0;
		return 0;
	}
	ll y,ans=0;
	for(ll a=2;a<=sqrt(n);a++)
	{
		y=0;
		while(m%a==0)
		{
			y++;
			m/=a;	
		}
		if(y==0)
		continue;
		ll low,high;
		low=1;
		high=y;
		ll mid,ans1;
		while(low<=high)
		{
			mid=low+(high-low)/2;
			ll xx=(mid*(mid+1))/2;
			if(xx<=y)
			{
				ans1=mid;
				low=mid+1;	
			}	
			else
			high=mid-1;
		}
		ans+=ans1;
	}
	if(m>1)
	{
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3692
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

    cin >> k >> n;

    vl a(n);
    rep(i, n) cin >> a[i];

    ll max = 0, maxi;
    rep(i, n - 1) {
        if(a[i + 1] - a[i] > max) {
            max = a[i + 1] - a[i];
            maxi = i;
        }
    }
    
    if(k + a[0] - a[n - 1] > max) {
        cout << a[n - 1] - a[0] << endl;
    } else {
        cout << k - (a[maxi + 1] - a[maxi]) << endl;
    }
}

Measured memory_bytes: 4764
N=int(input())
A=list(map(int,input().split()))

D={}
for i in range(N-1):
    if (A[i] in D.keys())==True:
        D[A[i]]+=1
    elif (A[i] in D.keys())==False:
        D[A[i]]=1
for i in range(1,N+1):
    try:
        print(D[i])
    except:
        print(0)

Measured memory_bytes: 112032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int h,w,n,a[100010]={},c[110][110];
    cin>>h>>w>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    bool go=true;
    int k=1;
    for(int i=0;i<h;i++){
        if(go){
            for(int j=0;j<w;j++){
                c[i][j]=k;
                a[k]--;
                if(a[k]==0) k++;
            }
            go=false;
        }
        else{
            for(int j=w-1;j>=0;j--){
                c[i][j]=k;
                a[k]--;
                if(a[k]==0) k++;
            }
            go=true;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<c[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 768
num = int(input())
in_list = list(map(int, input().split()))

count = 0

for i in range(1, num - 1):
  if (in_list[i-1] < in_list[i] and in_list[i] < in_list[i+1]) or (in_list[i-1] > in_list[i] and in_list[i] > in_list[i+1]):
    count += 1

print(count)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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



void solve() {
	ll L,R; cin >> L >> R;
    ll res = 2019;
    if(R-L+1 >= 2019){
        cout << 0 << endl;
        return;
    }else{
        for(ll i=L; i <= R; i++){
            for(ll j=i+1; j <= R; j++){
                res = min(res, i%2019*j%2019);
            }
        }
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,j,n,a[100000],i=0,dp[100000]={0},m;
    cin>>n>>k;
    while(i<n)
    {
        cin>>a[i++];
    }
    i=2;
    dp[1]=abs(a[0]-a[1]);
    while(i<n)
    {
        j=1;
        m=INT_MAX;
        while(j<=k && i-j>=0)
        {
            if(m>dp[i-j]+abs(a[i]-a[i-j]))
                m=dp[i-j]+abs(a[i]-a[i-j]);
            //dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
            j++;
        }
        dp[i]=m;
        i++;
    }
    cout<<dp[n-1];
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

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

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

  vector<int> cost(n);
  int koka[n][m];

  for (int i = 0; i < n; i++) {
    cin >> cost[i];
    for (int j = 0; j < m; j++) {
      cin >> koka[i][j];
    }
  }

  int ans = INF;
  for (int i = 0; i < (1 << n); i++) {
    vector<int> dekido(m, 0);
    int kane = 0;
    for (int h = 0; h < n; h++) {
      if ((i >> h) & 1) {  // その本を読む
        kane += cost[h];   // 買う
        for (int a = 0; a < m; a++)
          dekido[a] += koka[h][a];
      }
    }
    bool can = true;
    for (int a = 0; a < m; a++) {
      if (dekido[a] < x) can = false;
    }

    if (can) {
      ans = min(ans, kane);
    }
  }

  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000000 + 7;

long long modplus(long long a, long long b){
	long long ans = a + b;
	ans %= mod;
	return ans;
}
long long modminus(long long a, long long b){
	long long ans = a - b;
	ans %= mod;
	if(ans < 0) ans += mod;
	return ans;
}
long long modmul(long long a, long long b){
	long long ans = (a % mod) * (b % mod);
	ans = ((ans % mod) + mod) % mod;
	return ans;
}

long long modpow(long long A, long long P){
	long long a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	long long adash = modmul(a,a);
	if(p % 2) return modmul(modpow(adash, p / 2), a);
	else return modpow(adash, p / 2);
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<long long> A;
	int mis = 0;
	for(int i=0;i<N;i++){
		long long X;
		cin >> X;
		A.push_back(X);
		if(X < 0)mis++;
	}
	sort(A.begin(), A.end());
	// for(int i=0;i<N;i++){
	// 	cout << i << ":" << A[i] << endl;
	// }
	long long ans = 1;
	if(N == K){
		for(int i=0;i<N;i++){
			ans = modmul(ans, A[i]);
		}
	}
	else if(K % 2 == 1 && mis == N){
		for(int i=0;i<K;i++){
			ans = modmul(ans, A[N - i - 1]);
		}
	}
	else{
		int cnt = 0;
		vector<long long> M, P;
		for(int i=0;i<N;i++){
			if(A[i] < 0)M.push_back(A[i]);
			else P.push_back(A[i]);
		}
		reverse(P.begin(), P.end());
		int Mi = 0, Pi = 0;
		int MN = M.size(), PN = P.size();
		while(cnt < K){
			long long tmpP = -1, tmpM = -1;
			if(Pi + 1 < PN)tmpP = P[Pi] * P[Pi + 1];
			else if(Pi + 1 == PN)tmpP = P[Pi];
			if(Mi + 1 < MN)tmpM = M[Mi] * M[Mi + 1];
			if(tmpP > tmpM || cnt == K - 1){
				ans = modmul(ans, P[Pi]);
				Pi++;
				cnt++;
			}
			else{
				ans = modmul(ans , tmpM);
				Mi += 2;
				cnt += 2;
			}
			//cout << ans << endl;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 7996
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M, X;
  cin >> N >> M >> X;

  vector<int> C(N);
  int A[N][M];

  for(int i = 0; i < N; i++) {
    cin >> C[i];
    for(int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  
  int money = 0;
  int flag = 1;
  long long  min = 1000000000;
  for(int i = 0; i < (1 << N); i++) {
    int sum[M] = {0};
    money = 0;
    flag = 1;
    for(int j = 0; j < N; j++) {
      if(i & (1 << j)) {
        money += C[j];
        for(int k = 0; k < M; k++) {
          sum[k] += A[j][k];
        }        
      } 
   }

   for(int l = 0; l < M; l++) {
     if(sum[l] < X) { flag = 0; break; } 
   }
   if(flag) {
     if(min > money) min = money; 
   }
  
  }

  if(min != 1000000000)
  cout << min;
  else {
    cout << -1;
  }

  return 0;

}

Measured memory_bytes: 3636
#include<cstdio>
#include<string>
#include<cstring> 
#include<iostream>
using namespace std;
const int MAXL = 3010;
char s[MAXL], t[MAXL];
int f[MAXL][MAXL], pa[MAXL][MAXL][2];

void print(int x, int y)
{
	int nx = pa[x][y][0], ny = pa[x][y][1];
	if(nx && ny) print(nx, ny);
	if(f[nx][ny] + 1 == f[x][y])
		putchar(s[x]);
}

int main()
{
	scanf("%s%s",s+1,t+1);
	int n = strlen(s+1), m = strlen(t+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			f[i][j] = f[i-1][j];
			pa[i][j][0] = i-1; pa[i][j][1] = j;
			if(f[i][j-1] > f[i][j])
			{
				f[i][j] = f[i][j-1];
				pa[i][j][0] = i;
				pa[i][j][1] = j-1;
			}
			if(s[i] == t[j] && f[i-1][j-1] + 1 > f[i][j])
			{
				f[i][j] = f[i-1][j-1] + 1;
				pa[i][j][0] = i-1;
				pa[i][j][1] = j-1;
			}
		}
	}
	print(n, m);
	putchar(' ');
	return 0;
}

Measured memory_bytes: 106496
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    cin>>k;
    cin>>a>>b;
    int d=b-a;
    if (a%k==0)
    {
        cout<<"OK"<<endl;
    }
    else
    {

        int u=a/k;
         //  cout<<u<<endl;
        if (k*(u+1)<=b)
        {
              cout<<"OK"<<endl;

        }

        else

         cout<<"NG"<<endl;











    }















    return 0;
}


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

int main(){
  int N;
  int L;
  int origin=0;
  int eaten=0;
  int diff1=0;
  int min=100000000;
  int print;
  cin >> N;
  cin >> L;
  for(int i=1;i<=N;i++){
    origin += L+i-1;
  }
  for(int i=1;i<=N;i++){
    eaten=0;
    for(int j=1;j<=N;j++){
      if(i!=j){
        eaten+=L+j-1;
      }
    }
    diff1=origin-eaten;
    if(diff1<0){
      diff1=-diff1;
    }
    if(diff1<min){
      print=eaten;
      min=diff1;
    }
  }
  cout << print << endl;
}


Measured memory_bytes: 256
import math

X=int(input())

y=math.floor(math.sqrt(X))

L=[0 for i in range(y+1)]

for i in range(2,y+1):
    count=1
    while True:
        n=i**count
        if n<=X:
            count+=1
        else:
            break
    L[i]=i**(count-1)

if X<=3:
    print(1)
else:
    print(max(L))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 1)
	{
		cout << "No" << endl;
		return (0);
	}
	int i = 0;
	int j = s.size() / 2;
	bool f = true;
	while (i < s.size() / 2)
	{
		if (s[i] != s[j])
			f = false;
		i++;
		j++;
	}
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    

    int n;
    cin >> n;
    ll ary[n];
    rep(i,n) cin >> ary[i];

    map<ll, int> mp;

    rep(i,n)
    {
        auto itr = mp.find(ary[i]);
        if (itr==mp.end()) mp[ary[i]] = 1;
        else
        {
            mp.erase(itr);
        }
    }
    cout << mp.size() << endl;
}


Measured memory_bytes: 7296
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int cnt[10];

int main(){
    INIT;
    REP(i, 4){
        cin >> n;
        cnt[n]++;
    }
    if(cnt[1] > 0 && cnt[9] > 0 && cnt[7] > 0 && cnt[4] > 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    vector<ll> a(n); vin(a);
    ll ans = 1;
    int greater = a[0] <= a[1], less=a[0] >= a[1];
    rep(i, n - 1) {
        if(a[i] == a[i + 1]) continue;
        if(greater && less) {
            greater &= a[i] <= a[i + 1];
            less &= a[i] >= a[i + 1];
            continue;
        }
        if(greater && a[i] > a[i + 1] || less && a[i] < a[i + 1]) {
            ans++;
            if(i + 2 < n) {
                greater = a[i + 1] <= a[i + 2];
                less = a[i + 1] >= a[i + 2];
            }
        } else {
            greater &= a[i] <= a[i + 1];
            less &= a[i] >= a[i + 1];
        }
    }

    print(ans);

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    auto p = vector<int>(n);
    for (auto &p_i : p)
        cin >> p_i;

    auto counter = 0;
    for (int i = 1; i + 1 < n; i++) {
        auto a = min(p[i - 1], p[i + 1]);
        auto b = max(p[i - 1], p[i + 1]);
        if (a < p[i] && p[i] < b)
            counter++;
    }

    cout << counter;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  char a[1024];
  int i=0;
  
  fgets(a,sizeof(a),stdin);
  while(a[i]!='\n')
    i++;
  for(i=i-1;i>=0;i--)
    printf("%c",a[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 0
N = gets.to_i
as, bs, cs = 3.times.map{gets.split(' ').map{|n| n.to_i}}
sum, prev = 0, -1
as.each do |a|
  sum += bs[a - 1]
  if a == prev + 1 
    sum += cs[a - 2] 
  end
  prev = a
end
p sum

Measured memory_bytes: 1788
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,r,ans=10000,a,b;
	cin>>n>>r;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		if(b<=r&&ans>a) ans=a;
	}
	if(ans==10000) cout<<"TLE";
	else cout<<ans;
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int z;

int main()
{
  while((cin >> z) && z){
    int mx = 0;
    rrep(x, 1, z) erep(y, 1, x){
      int tmp = x * x * x + y * y * y;
      if(tmp > z * z * z) break;
      maxup(mx, tmp);
    }
    cout << z * z * z - mx << endl;
  }

  return 0;
}

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

int main()
{
    int a,b ;
    cin >> a >> b;
    if((a+b) % 2 == 0){
        cout << (a+b)/2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string s;
signed main() {
    cin >> s;
    s[5] = s[13] = ' ';
    cout << s << endl;
}


Measured memory_bytes: 256
// C# program to build the smallest number 
// by removing n digits from a given number 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{
    public static void Main(String[] args)
    {
        //var t = int.Parse(Console.ReadLine());
        //while (t > 0)
        {
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(input[0]);
            var k = int.Parse(input[1]);
            List<int> coll = new List<int>();
            for (int i = 0; i < n; i++)
            {
                coll.Add(int.Parse(Console.ReadLine()));
            }
            // var arr = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            // MAXXor(n, k, arr);
            ChrimasEve(n, k, coll);
        }

    }

    public static void ChrimasEve(int n, int k, List<int> lst)
    {
        lst.Sort();
        int min = int.MaxValue;
        for (int i = 0; i < lst.Count - k + 1; i++)
        {
            var lower = lst[i];
            var high = lst[i + k - 1];

            min = Math.Min(min, Math.Abs(high - lower));

        }

        Console.Write(min);
    }

}



Measured memory_bytes: 17324
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

point = sum(B)
for i in range(N-1):
  if A[i]==A[i+1]-1:
    point +=C[A[i]-1]
print(point)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vl Prime(MAX_N, 1);  // Prime[i] : iが素数のとき1、iが素数でないとき0

void Eratosthenes(ll n) {  // n未満の素数を求める    
    Prime[0] = Prime[1] = 0;
    for(ll i = 2; i*i < n; i++) {
        if(Prime[i]) {
            for(ll j = 2; i*j < n; j++) {
                Prime[i*j] = 0;
            }
        }
    }
}

int main() {
    ll x;
    cin >> x;

    Eratosthenes(MAX_N);

    for(ll i = x; ; i++) {
        if(Prime[i]) {
            out(i);
            re0;
        }
    }

    re0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int sum1 = 0;
	int sum2 = 0;
	string str;

	cin >> str;

	for (int i = 0; i < (int)str.size(); i++) {
		if (i % 2 == 0) {
			if (str[i] == '1') {
				sum1++;
			}
			else {
				sum2++;
			}
		}
		else {
			if (str[i] == '0') {
				sum1++;
			}
			else {
				sum2++;
			}
		}
	}

	cout << min(sum1, sum2) << endl;

	return(0);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  if(x / k >= d) cout << x - k * d << endl;
  else {
    ll n = x / d;
    x = x - n * d;
    if((k - n) % 2 == 0) cout << x << endl;
    else cout << d - x << endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{  int k,x,a,b,e;
	cin>>k>>x;
	b=(x-k)+1;
	e=(x+k);
	for(int i=b;i<e;i++)
	{
	    cout<<i<<" ";
	}
}	


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int main(void){
    string s;
    cin >> s;
    
    int l = s.size() - 1;
    while (l > 0) {
        string tmp[3];
        for (int i = 0; i < 7; i++) {
            if (i < 5) tmp[0] += s[l + i - 4];
            if (i < 6) tmp[1] += s[l + i - 5];
            tmp[2] += s[l + i - 6];
        }
        
        if (tmp[0] == "dream" || tmp[0] == "erase") l -= 5;
        else if (tmp[1] == "eraser") l -= 6;
        else if (tmp[2] == "dreamer") l -= 7;
        else {
            cout << "NO" << endl;
            return 0;
        }
        
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

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

	int h[n];
	REP(i,n)
	{
		cin >> h[i];
	}

    int res = 0;
	REP(i,n)
	{
		if(h[i] >= k)++res;
	}
    cout << res << endl;
    return 0;    
}



Measured memory_bytes: 640
#include <iostream>
#include <math.h>

using namespace std;

//= AOJ GRL_1_A


const int V_constraint=100000,E_constraint=500000, D_constraint=10000;
int V, E, R,S[E_constraint+10], T[E_constraint+10], D[E_constraint+10],C[V_constraint+10];
const int inf=V_constraint*D_constraint+100;
// int parent[100000];

int main() {
	
	
	//= prompt user for input
	cin >> V >> E >> R;
// if (E>E_constraint)
// 	cout<< "E>E_constraint";
for (int i=0; i<E; ++i){
	cin >> S[i] >> T[i] >> D[i];
	// if (D[i] >D_constraint)
	// cout<< "D>D_constraint";
}
// set distance from source to source as zero, other as infinite
for (int i=0;i<V;i++) C[i]=inf;
C[R]=0;
// parent[R]=R;

// for (int i=0; i<E; ++i)
// 	cout<<C[i];
// cout<<endl;

//= bellman-ford algo
for (int v=0;v<V-1;v++)
{
	bool update = false;

	for (int i=0;i<E;++i){
		if(C[S[i]]+D[i]<C[T[i]] && C[S[i]]<inf ){
		C[T[i]]=C[S[i]]+D[i];
		update = true; 
		//parent[T[i]]=S[i];
		}
}
if (!update) break; 
	}

//= output 	
// cout<<V<<endl;

for (int i=0; i<V; i++)
	if (C[i]!=inf)
	cout << C[i] <<endl;
	else
	cout <<"INF"<<endl;
	
	return 0;
}

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int A = 0;
		int[] B = new int[N+1];
		for (int i = 2; i < N+1; i++) {
			A = scan.nextInt();
			B[A]++;
		}

		for (int i = 1; i < N+1; i++) {
			System.out.println(B[i]);
		}

	}

}

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

void trace(vector<int> &a,int N){
  for(int i=0;i<N;i++){
    if(i){
      cout<<" ";
    }
    cout<<a[i];
  }
  cout<<endl;
  
}

int selectionsort(vector<int> &v,int N){
  int cnt=0;
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(v[j]<v[minj]){
        minj=j;
      }
    }
    if(i !=minj){
      swap(v[i],v[minj]);
      cnt++;
    }
  }
  return cnt;
}
int main() {
  vector<int> vec(3);
  for(int i=0;i<3;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<vec.at(2)*10+vec.at(0)+vec.at(1)<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
sub=[ input().split() for i in range(m)]
sub=[[int(i[0]),i[1]] for i in sub]

mis=[[0,0] for i in range(n)]

for i in range(m):
  if sub[i][1]=='AC':
    mis[sub[i][0]-1][0]=1
  elif sub[i][1]=='WA' and mis[sub[i][0]-1][0]!=1:
    mis[sub[i][0]-1][1]+=1
    
ans=[0,0]
for i in range(n):
  if mis[i][0]==1:
    ans[0]+=1
    ans[1]+=mis[i][1]
print(ans[0],ans[1])
 

Measured memory_bytes: 45600
#include<stdio.h>

int main(){
int up;//??????
bool b[1000][1000];
	int c=-1;
	int i2;
	int itizi;
	int i;	
	int con;//?¶??????????
	int saisyo[1000];
	for(i=0;c==-1;i++){
		scanf("%d",&up);
		if(up==0){c=i;break;}
		scanf("%d",&itizi);
		saisyo[i]=itizi;
		b[i][itizi]=true;	
		for(i2=1;i2<up;i2++){
			scanf("%d",&itizi);
			b[i][itizi]=true;
		}
	}
	
	for(i=0;i<c;i++){
		con=-1;
		for(i2=1;i2<=1000;i2++){
			if(con==-1&&b[i][i2]==true){
				con=i2;
			}
			else if(b[i][i2]==true){}
			else if(con!=-1&&b[i][i2]!=true){
				if(con==saisyo[i]){
					if(con==i2-1){printf("%d",con);}
					else {printf("%d-%d",con,i2-1);}
			    }
				else {
					if(con==i2-1){printf(" %d",con);}
				    else {printf(" %d-%d",con,i2-1);}
				}
				con=-1;
			}
		}
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 1132
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,a=1;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		if(a<k)
		{
			a=a*2;
		}
		else
		{
			a=a+k;
		}
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  while(1) {
    int n, m, s, g1, g2; cin >> n >> m >> s >> g1 >> g2;
    s--; g1--; g2--;
    if(n == 0) break;
    vector<vector<ll>> d(n, vector<ll>(n, INF));
    for(int i=0;i<n;++i) {
      d[i][i] = 0;
    }
    for(int i=0;i<m;++i) {
      int u, v, c; cin >> u >> v >> c;
      u--; v--;
      d[u][v] = c;
    }
    for(int k=0;k<n;++k) {
      for(int i=0;i<n;++i) {
        for(int j=0;j<n;++j) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
    ll ans = INF;
    for(int i=0;i<n;++i) {
      ans = min(ans, d[s][i] + d[i][g1] + d[i][g2]);
    }
    cout << ans << endl;
  }
}



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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
  ll h,w,K;
  cin >> h >> w >> K;

  vector<string> map(h);
  rep(i,h) cin >> map[i];

  ll ans = 0;
  for(ll i = 0; i < 1<< h; i++){
    for(ll j = 0; j < 1<< w; j++){
      vector<string> c = map;
      for(ll y = 0; y < h; y++){
        if(i>>y&1){
          rep(k,w){
            c[y][k] = 'r';
          }
        }
      }

      for(ll x = 0; x < w; x++){
        if(j>>x&1){
          rep(k,h){
            c[k][x] = 'r';
          }
        }
      }

      ll black = 0;
      for(ll y = 0; y < h; y++){
        for(ll x = 0; x < w; x++){
          if(c[y][x]=='#'){
            black++;
          }
        }
      }
      // cout << black << endl;
      if(black==K){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
} 



Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

using type = pair<int, ll>;
using event = pair<ll, type>;

int main(){
    int N, Q; cin >> N >> Q;
    vector<event> v;
    for (int i = 0; i < N; ++i) {
        int s, t, x; cin >> s >> t >> x;
        v.push_back({s-x, type(-1, x)});
        v.push_back({t-x, type(0, x)});
    }
    for (int i = 0; i < Q; ++i) {
        int d; cin >> d;
        v.push_back({d, type(1, i)});
    }
    sort(v.begin(), v.end());

    vector<ll> res(Q);
    multiset<ll> se;
    for (auto p : v) {
        ll x = p.first;
        int type = p.second.first;
        ll val = p.second.second;
        if (type == -1) se.insert(val);
        else if (type == 0) se.erase(se.lower_bound(val));
        else res[val] = (se.empty() ? -1: *(se.begin()));
    }
    for (auto v: res) cout << v << endl;
}

Measured memory_bytes: 26724