akhauriyash/Code-Regression huggingface dataset:
# include<iostream>
using namespace std;
int main(){
int a;
cin>>a;
/*if(( a % 1000 ) / 100 == ( a % 100 ) / 10 and (a % 100 ) / 10 == a % 10){
    cout<<a<<endl;
}*/
for (int i=a; i<=999; i++){
    if( ( i % 1000 ) / 100 != ( i % 100 ) / 10 || ( i % 100 ) / 10 != i % 10 ){
        continue;
    }
    if( ( i % 1000 ) / 100 == ( i % 100 ) / 10 and ( i % 100 ) / 10 == i % 10 ){
        cout<<i;
        break;
    }
    }
}


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

int main(){
  int n;
  cin >> n;
  if(n>=30)cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 3616
n,m = map(int,input().split())
ll = [list(map(int,input().split())) for _ in [0]*m]
to=set()
nfrom=set()
for l in ll:
  if l[0]==1:
    to.add(l[1])
  if l[1]==n:
    nfrom.add(l[0])
if len(to&nfrom)>0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 60212
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int64_t a = 200000, z = 0, ans, c;
	c = s.size();
	for (int64_t i = 0; i < c; i++){
		if (s.at(i) == 'A') {
			a = min(a, i);
		}
		else if (s.at(i) == 'Z') {
			z = max(z, i);
		}
	}
	ans = z - a + 1;
	cout << ans<< endl;
}

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

int main(){
 int N;
 int X;
 int sum=0;
 int ans=1;
 vector<int> vec(101,0);
 cin >> N ;
 cin >> X;
 for(int i=0;i<N;i++){
   cin >> vec[i];
 }
 for(int i=0;i<N;i++){
   sum += vec[i];
   if(sum > X) break;
   ans++;
 }
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	char c;
	cin >> c;
	cout << (char)(c+1) << endl;

	return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;

  int Ans = 1000;
  for (int key = 0; key < 1000; key++) {
    int tmp = key;
    int d = tmp % 10;
    int col = 0;
    bool flag = false;
    for (int i = N - 1; i >= 0; i--) {
      if (d == (S[i] - '0')) {
        tmp /= 10;
        d = tmp % 10;
        col++;
        if (col == 3) {
          flag = true;
        }
      }
    }
    if (!flag) Ans--;
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>>a(n,vector<int>(2));
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        a[i][0]=temp;
        a[i][1]=i;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int ret;
    for(int i=0;i<n;i++){
        if(i==a[0][1]){
            cout<<a[1][0]<<endl;
        }else{
            cout<<a[0][0]<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define gc getchar()
using namespace std;
const int N=109;
int n,first[N],number,deep[N],Max,fa[N],Mx[N];
struct edge
{
	int to,next;
	void add(int x,int y)
	{
		to=y,next=first[x],first[x]=number;
	}
}e[N<<1];
int read()
{
	int x=1;
	char ch;
	while (ch=gc,ch<'0'||ch>'9') if (ch=='-') x=-1;
	int s=ch-'0';
	while (ch=gc,ch>='0'&&ch<='9') s=s*10+ch-'0';
	return s*x;
}
void dfs(int x,int last)
{
	deep[x]=deep[last]+1;
	fa[x]=last;
	for (int i=first[x];i;i=e[i].next)
		if (e[i].to!=last) dfs(e[i].to,x);
	if (deep[x]>deep[Max]) Max=x;
}
void Dfs(int x,int last,int dep)
{
	int son=0;
	for (int i=first[x];i;i=e[i].next)
		if (e[i].to!=last) son++,Dfs(e[i].to,x,dep+1);
	Mx[dep]=max(Mx[dep],son);
}
int solve()
{
	Max=0;
	dfs(1,0);
	int x=Max;
	Max=0;
	dfs(x,0);
	return Max;
}
int main()
{
	n=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		e[++number].add(x,y),e[++number].add(y,x);
	}
	int y=solve();
	printf("%d ",(deep[y]+1)/2);
	if (deep[y]&1)
	{
		int z=y;
		for (int i=1;i<=deep[y]/2;i++) z=fa[z];
		memset(Mx,0,sizeof(Mx));
		Dfs(z,0,1);
		long long Min=1;
		for (int i=1;i<=deep[y]/2;i++)
			Min=Min*Mx[i];
		int now=deep[y];
		for (int i=first[z];i;i=e[i].next)
		{
			int w=e[i].to;
			memset(Mx,0,sizeof(Mx));
			Dfs(z,w,1);
			Dfs(w,z,1);
			long long ret=2;
			for (int i=1;i<=deep[y]/2;i++)
				ret=ret*Mx[i];
			Min=min(Min,ret);
		}
		printf("%lld\n",Min);
	}
	else
	{
		int z=y,w;
		for (int i=1;i<deep[y]/2;i++) z=fa[z];
		w=fa[z];
		memset(Mx,0,sizeof(Mx));
		Dfs(z,w,1);
		Dfs(w,z,1);
		long long ret=2;
		for (int i=1;i<deep[y]/2;i++)
			ret=ret*Mx[i];
		printf("%lld\n",ret);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 51

enum DIR{
	North,
	East,
	South,
	West,
};

int diff_x[4] = {0,1,0,-1},diff_y[4] = {1,0,-1,0};
bool can_move[NUM][NUM][4],dp[2][NUM][NUM][4];
int table[128];
DIR dir_array[4] = {North,East,South,West};

int N;

bool rangeCheck(int x,int y){

	if(x >= 0 && x < NUM && y >= 0 && y < NUM)return true;
	else{
		return false;
	}
}

int main(){

	table['N'] = 0;
	table['E'] = 1;
	table['S'] = 2;
	table['W'] = 3;

	int start_x,start_y,T;
	scanf("%d %d %d %d",&N,&start_x,&start_y,&T);

	for(int i = 0; i < NUM; i++){
		for(int k = 0; k < NUM; k++){
			for(int p = 0; p < 4; p++)can_move[i][k][p] = false;
		}
	}

	//移動可能情報の作成
	int x1,y1,x2,y2;
	for(int loop = 0; loop < N; loop++){

		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);

		if(x1 == x2){ //縦の移動

			for(int y = min(y1,y2); y < max(y1,y2); y++){
				can_move[x1][y][North] = true;
				can_move[x1][y+1][South] = true;
			}

		}else{ //横の移動

			for(int x = min(x1,x2); x < max(x1,x2); x++){
				can_move[x][y1][East] = true;
				can_move[x+1][y1][West] = true;
			}
		}
	}

	int CURRENT = 0,NEXT = 1;

	for(int i = 0; i < NUM; i++){
		for(int k = 0; k < NUM; k++){
			for(int p = 0; p < 4; p++){
				dp[CURRENT][i][k][p] = false; //dp[CURRENT/NEXT][x][y][dir] = true/false
			}
		}
	}

	for(int i = 0; i < 4; i++)dp[CURRENT][start_x][start_y][i] = true;

	int dist,next_x,next_y;
	char buf[2];

	DIR dir;

	for(int loop = 0; loop < T; loop++){

		scanf("%d %s",&dist,buf);
		dir = dir_array[table[buf[0]]];

		for(int count = 0; count < dist; count++){ //合計でdist移動する

			//dp[NEXT]の初期化
			for(int i = 0; i < NUM; i++){
				for(int k = 0; k < NUM; k++){
					for(int p = 0; p < 4; p++){
						dp[NEXT][i][k][p] = false;
					}
				}
			}
			//dp[CURRENT]を走査
			for(int i = 0; i < NUM; i++){ //xのループ
				for(int k = 0; k < NUM; k++){ //yのループ
					for(int p = 0; p < 4; p++){ //今向いている方向
						if(!dp[CURRENT][i][k][p])continue;

						for(int a = 0; a < 4; a++){ //進んだ後に向く方向
							if(abs(p-a) == 2)continue; //Uターン禁止

							next_x = i+diff_x[p]; //今向いている向きに進む
							next_y = k+diff_y[p];

							if(rangeCheck(next_x,next_y) == false || can_move[i][k][p] == false
									|| can_move[next_x][next_y][a] == false)continue; //範囲外または行けないならSKIP

							if(count < dist-1){

								dp[NEXT][next_x][next_y][a] = true;

							}else{ //count == dist-1:向きを考慮する!!

								if(dir_array[p] == dir || dir_array[a] == dir){
									dp[NEXT][next_x][next_y][a] = true;
								}
							}
						}
					}
				}
			}
			swap(CURRENT,NEXT);
		}
	}

	for(int i = 0; i < NUM; i++){
		for(int k = 0; k < NUM; k++){
			for(int a = 0; a < 4; a++){
				if(dp[CURRENT][i][k][a]){
					printf("%d %d\n",i,k);
					break;
				}
			}
		}
	}

	return 0;
}



Measured memory_bytes: 3248
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	ll n, m, ans = 1;

	cin >> n >> m;

	if(abs(n - m) >= 2){
		cout << 0 << endl;
	}
	else{
		for(ll i = 1; i <= n; i++){
			ans *= i;
			ans %= MOD;
		}
		for(ll i = 1; i <= m; i++){
			ans *= i;
			ans %= MOD;
		}

		if(n == m){
			ans = (ans * 2) % MOD;
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}
 



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	cout << s[0]<<s.size()-2<<s[s.size()-1] << endl;

}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
using Grid = vector<vector<char>>; // [y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

//This sample is RMQ. Change a little difference by yourself.
template<typename Function>
class SegmentTree {
public:
	Int invalid_value = Int_max;
	Int depth = 1;
	Int leaf_size, tree_size, arr_size;
	Function f;
	Container data;

	//計算量はO(n)。*nは配列の長さ
	SegmentTree(Container arg,  Function func)
	: f(func){
		arr_size = arg.size();
		Int n = 1;
		tree_size = 1;

		while (n < arr_size) {//完全二分木にするため2^n > lenとなる最小の2^nを求める
			n *= 2;
			tree_size += n;
			depth++;
		}
		leaf_size = n;
		data.resize(tree_size);//木の配列のサイズを初期化

		for (Int i = 0; i < n; ++i) {//葉の値を初期化
			if (i <= arr_size - 1)data[n + i - 1] = arg[i];
			else data[n + i - 1] = invalid_value;
		}
		//goes well till here.

		Int tmp_size = leaf_size;
		for (Int i = 0; i < depth - 1; ++i) {
			for (Int j = 0; j < tmp_size / 2; ++j) {//ノードは(j * 2, j * 2 + 1)
				data[(tmp_size + j * 2 - 2) / 2] = f(data[tmp_size + j * 2 - 1], data[tmp_size + j * 2]);
			}
			tmp_size /= 2;
		}

	}

	//k番目の配列の値をvalに変える。計算量はO(log n)
	void update(Int k, Int val) {
		//木のインデックスに変える
		k += leaf_size - 1;
		data[k] = val;
		//再帰的に更新する
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = f(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}

	//[a, b)のクエリを返す。使うときはquery(a, b, 0, 0, n)で呼び出してね。計算量はO(log n)
	Int query(Int a, Int b, Int k = 0, Int l = 0, Int r = -1) {
		if (r < 0)r = leaf_size;
		if (r <= a || b <= l)return invalid_value;
		if (a <= l && r <= b)return data[k];
		Int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		Int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
};

template<typename Function>
SegmentTree<Function> make_SegmentTree(Container arg, Function func) {
	SegmentTree<Function> seg(arg, func);
	return seg;
}

int main() {

	Int N; cin >> N;
	Container P(N);
	rep(i, N)cin >> P[i];
	auto seg = make_SegmentTree(P, [](Int a, Int b) {return a > b ? b : a; });
	Int ans = 0;
	rep(i, N) {
		Int min = seg.query(0, i + 1);
		if (min == P[i])ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ins insert
#define int long long int
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i = 0 ; i < n ; i++ )
#define f1(i,n) for(int  i = 1 ; i <= n ; i++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() int t;cin>>t;while(t--)

map<int,int> div1;

void divisors(int n)
{
	if(n%2 == 0)
	{
		while(n%2 == 0)
		{
			div1[2]++;
			n/=2;
		}
	}	

	for(int i = 3; i*i<=n ;i+=2)
	{
		if(n%i == 0)
		{
			while(n%i == 0)
			{
				div1[i]++;
				n/=i;
			}
		}
	}

	if(n>1)
		div1[n]++;


}



int32_t main()
{
	fast();

	int n ;
	cin >> n ;


	divisors(n);


	int ans = 0;

	for(auto it = div1.begin(); it!= div1.end() ; it++)
	{
		int tot = it->ss;
		int cnt = 1;
		while(cnt<=tot)
		{
			ans++;
			tot-=cnt;
			cnt++;

		}
	}

	cout<<ans;
	
	return 0;

}

Measured memory_bytes: 3664
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        mut f: [usize; n]
    }

    f.sort();

    let mut heap = BinaryHeap::new();
    heap.push(f.pop().unwrap());

    let mut ans = 0usize;

    for _ in 1..n {
        let p = f.pop().unwrap();
        ans += heap.pop().unwrap();
        heap.push(p);
        heap.push(p);
    }

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


Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int main(){
	string A,B,C;
	cin>>A>>B>>C;
	char ans;
	int lenA=A.length();
	int lenB=B.length();
	int lenC=C.length();
	int t1=0,t2=0,t3=0;
	ans=A[0];
	
	while(lenA!=-1 && lenB!=-1 && lenC!=-1){
		if(ans=='a'){
			ans=A[t1++];
			lenA--;
		}
		else if(ans=='b'){
			lenB--;
			ans=B[t2++];
		}
		else if(ans=='c'){
			ans=C[t3++];
			lenC--;
		}
	}
	if(lenA==-1)
		cout<<"A"<<endl;
	else if(lenB==-1)
		cout<<"B"<<endl;
	else if(lenC==-1)
		cout<<"C"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}

ll dp[100010];

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n, k;
    cin >> n >> k;
    fill_n(dp, 100200, INF);
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= k; ++j){
            if(i+j >= n) continue;
            chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    ppp(dp[n-1]);
    
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define no_of_test(x)        int x; cin>>x; while(x--)
//Actual Code Is At The Top
const int mod = 1e9 + 7;
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}

int32_t main()
{   
	very_slow
	//no_of_test(x)
	{  
    int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<" "<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3584
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int maxx = 100010;
int n, m, order = 0;
int low[maxx], dfn[maxx], father[maxx], son[maxx];
//father:??¶?????? son:??????????????° 
vector<int> cutpoint, edge[maxx];
vector< pair<int, int> > cutedge;

void tarjan(int u)
{
	dfn[u] = low[u] = ++order;
	bool flag = false;
	for (int i = 0; i<edge[u].size(); i++)
	{
		int v = edge[u][i];
		if (!dfn[v])
		{
			son[u]++;
			father[v] = u;
			tarjan(v);
			if (low[v] >= dfn[u]) flag = true;
			//???u????????? 
			if (low[v]>dfn[u]) cutedge.push_back(make_pair(min(v, u), max(v, u)));
			//???v-u????????? 
			low[u] = min(low[u], low[v]);
		}
		else if (v != father[u]) low[u] = min(low[u], dfn[v]);
	}
	//???????????\???????£????????£???\?????????????????\?????????
	//??????????????\?????????????????????????????????u????\???????????????????????????????
	if ((father[u] == 0 && son[u]>1) || (father[u] && flag)) cutpoint.push_back(u);
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		edge[u+1].push_back(v+1), edge[v+1].push_back(u+1);
	}
	tarjan(1);
	sort(cutedge.begin(), cutedge.end());
	sort(cutpoint.begin(), cutpoint.end());
	
	int len = cutpoint.size();
	for (int i = 0; i< len; i++) 
		printf("%d\n", cutpoint[i]-1);
	return 0;
}

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

int main(void){
    int h, w;
    while (cin >> w >> h) {
        if (h * w == 0) return 0;
        
        int on_h, on_c;
        bool check[30][30] = {};
        char s[30][30];
        for (int i = 0; i < h; i++) {
            cin >> s[i];
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '@') {
                    on_h = i;  on_c = j;
                }
                else if (s[i][j] == '.') check[i][j] = true;
            }
        }
        
        int ans = 1, dh[4] = {1, 0, -1, 0}, dc[4] = {0, 1, 0, -1};
        queue<int> que_h, que_c;
        que_h.push(on_h);
        que_c.push(on_c);
        
        while (!que_h.empty()) {
            int qh = que_h.front(), qc = que_c.front();
            for (int i = 0; i < 4; i++) {
                if (qh + dh[i] >= 0 && qh + dh[i] < h && qc + dc[i] >= 0 && qc + dc[i] < w 
                && check[qh + dh[i]][qc + dc[i]]) {
                    ans++;
                    check[qh + dh[i]][qc + dc[i]] = false;
                    que_h.push(qh + dh[i]);
                    que_c.push(qc + dc[i]);
                }
            }
            que_h.pop();
            que_c.pop();
        }
        
        cout << ans << endl;
    }
}



Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */

int counter(int a) {	// bitを数える
	int i, ans = 0;
	for(i=0;i<20;i++) {
		if (a & (1 << i)) ans++;
	}
	return ans;
}

/* main *************************************************************/
int main()
{
	int		a[20],b,c,i,j,k,n,m,x[20][20],y[20][20],f,ans;
	char	str[256];
	
	scanf("%d", &n);
	for(i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		for(j=1;j<=a[i];j++) {
			scanf("%d %d", &x[i][j], &y[i][j]);
		}
	}
	
	k = 1;
	for(i=1;i<=n;i++) k = k*2;
	k = k - 1;
	
	m = 0;
	for(ans=k;ans>=0;ans--) {
		f = 1;
		for(i=1;i<=n;i++) {
			if (ans & (1 << (i-1) )) {		// 正直者
				for(j=1;j<=a[i];j++) {
					if (y[i][j]) {			// xは正直者
						if ((ans & (1 << (x[i][j]-1) )) == 0) f = 0; //矛盾
					} else {				// xは不親切
						if ((ans & (1 << (x[i][j]-1) )) != 0) f = 0; //矛盾
					}
				}
			}
		}
		
		if (f) {	//矛盾しない
			m = max(m , counter(ans) );
		}
	}
	
	printf("%d\n",m);


	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)


int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N, K;
	int A, B;
	vector<int> d;
	// cin >> N >> K;
	cin >> A >> B;


	cout << max(max(A + B, A - B), A * B) << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(d%2==0)
    out(a-b);
    else
      out(b-a);
}

Measured memory_bytes: 3824
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
m = -10*100
for i in range(2**N):
    tmp = 0
    for j in range(N):
        if (i>>j)&1:
            tmp += V[j]-C[j]
    m = max(tmp, m)

print(m)

Measured memory_bytes: 41068
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
      int x=sc.nextInt();
      int y=sc.nextInt();
      if(!(y%2==0)){
        System.out.println("No");
        return;
      }
      int a=0;
      for(int i=0;i<=x;i++){
      	a=y-(i*4);
        if(a==(x-i)*2){
        	System.out.println("Yes");
          return;
        }
      }
      System.out.println("No");
      return;
	}
}

Measured memory_bytes: 27076
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n,a,b;
  cin >>n>>a>>b;
  cout  <<min(n*a,b)<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int calc(int x){
	int s = 0;
	while(x){
		s += x % 10;
		x /= 10;
	}
	return s;
}

signed main(){
	int n,tmp,keta = 0,ma = 0;
	cin >> n;
	tmp = n;
	ma = calc(n);
	while(tmp){
		ma = max(ma,calc(tmp - 1) + 9 * keta);
		keta++;
		tmp /= 10;
	}
	cout << ma << endl;
	return 0;
}

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

int main()
{
  int n;
cin >> n ;
int i,b[n];

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

for(i=n-1;i>=0;i--){
cout << b[i] ;
if(i!=0) cout<< " ";
} 

  cout<<endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
const int maxn = 500000 + 20;
int dp[maxn][2];
bool check(LL L1, LL R1, LL L2, LL R2) {
    if (R1 >= L2 && L2 >= L1) {
        return true;
    }
    if (L1 >= L2 && R2 >= L1) {
        return true;
    }
    if (R2 >= R1 && R1 >= L2) {
        return true;
    }
    return false;
}
void work() {
    memset(dp, 0x3f, sizeof dp);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
//    cout << check(1, 2, 3, 4) << endl;
    for (LL i = 0; i <= n - 2; ++i) {
        LL resA = a - i * d + (n - 2 - i) * c, resB = a + (n - 2 - i) * d - i * c;
        if (check(resA, resB, b - d, b - c) || check(resA, resB, b + c, b + d)) {
            printf("YES\n");
            return;
        }
    }
    printf("NO\n");
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


Measured memory_bytes: 4096
#Kは 1 以上 100以下の整数
#Sは英小文字からなる文字列
#Sの長さは1以上100以下

k = int(input())
s =input()

if len(s) <= k: #Sの長さがKまで
    print(s)
else:
    s = s[:k]
    s = s+"... "
    print(s)

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

int main () {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
bool vis[110][110];
int map[110][110];
int n,m,ans;
int x0[5]={0,1,0,-1,0};
int y0[5]={0,0,-1,0,1};
void dfs(int x,int y,int kind)
{
	vis[ x ][ y ]=1;
	for(int k=1,X,Y;k<=4;k++)
	{
		X=x+x0[ k ],Y=y+y0[ k ];
		if( X<1 || X>n || Y<1 || Y>m || vis[ X ][ Y ] || map[ X ][ Y ]!=kind )   continue ;
		dfs( X,Y,kind );
	}
}
int main()
{
	string s;
	while( scanf("%d%d",&n,&m)!=EOF )
	{
		if( !n || !m )   break ;
		for(int i=1;i<=n;i++)
		{
			cin>>s;
			for(int j=1;j<=m;j++)
				if( s[ j-1 ]=='#' )   map[ i ][ j ]=1;
				else
					if( s[ j-1 ]=='@' )   map[ i ][ j ]=2;
					else   map[ i ][ j ]=3;
		}
		ans=0,memset( vis,0x0,sizeof vis );
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				if( !vis[ i ][ j ] )
					ans++,dfs( i,j,map[ i ][ j ] );
		printf("%d\n",ans);
	}
	return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int tmp = N;
  for (int i = 0; i < M;i++){
    int input = 0;
    cin >> input;
    tmp -= input;
  }

  if(tmp < 0)
    tmp = -1;

  cout << tmp;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  long long int D, N; cin >> D >> N;
  if (N == 100)
    N = 101;
  if (D == 0) {
    cout << N * 1 << endl;
  } else if (D == 1) {
    cout << N * 100 << endl;
  } else {
    cout << N * 10000 << endl;
  }
}


Measured memory_bytes: 256
N = int(input())

if N == 3:
    ans = [2, 3, 25]
else:
    # [合計が6の倍数]を常に満たすように追加する
    if N % 2 == 0:
        As = [2, 10, 3, 9, 4, 8, 6, 12]
    else:
        As = [6, 2, 10, 3, 9, 4, 8, 12]

    ans = []
    for i in range(N):
        ans.append(As[i % 8] + 12 * (i // 8))

print(' '.join(map(str, ans)))


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

import sys
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(len(A)):
        ans *= A[i]
        if ans > 10**18:
            print('-1')
            sys.exit()
    else:
        print(ans)

Measured memory_bytes: 21640
/*input
0
*/

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

int main() {
    int x;
    cin >> x;
    cout << (1-x) << endl;
}

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



int main(void)
{
    double L;
    cin >> L;
    double ans = (L/3)*(L/3)*(L/3);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	vector<vector<int>> c(3,vector<int>(3,0));
	rep(i,3) rep(j,3) cin >> c[i][j];
	vector<int> a(3),b(3);
	a[0] = 0;
	b[0] = c[0][0];
	b[1] = c[0][1];
	b[2] = c[0][2];
	if(c[1][0]-b[0] == c[1][2]-b[2] && c[1][2]-b[2]==c[1][1]-b[1] && c[2][0]-b[0] == c[2][2]-b[2] && c[2][2]-b[2]==c[2][1]-b[1]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int A[100][100];
vector<vector<pair<int,int> > > G(100);
const int INF=INT_MAX/2;

int main(){
  rep(i,100) rep(j,100){
    if(i==j) A[i][j]=0;
    else A[i][j]=INF;
  }
  int N,M; cin>>N>>M;
  rep(i,M){
    int a,b,c; cin>>a>>b>>c; a--,b--;
    A[a][b]=A[b][a]=c;
    G[a].push_back(make_pair(b,c));
    G[b].push_back(make_pair(a,c));
  }
  rep(k,N) rep(i,N) rep(j,N) A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
  int ans=0;
  rep(i,N) rep(j,G[i].size()){
    int b=G[i][j].first, c=G[i][j].second;
    if(A[i][b]<c) ans++;
  }
  cout<<ans/2<<endl;
  return 0;
}


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

using namespace std;

#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=1e6+7;
const int mod=1e9+7;



int main(void)
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    LL n,a,b,mi,mx;
    cin>>n>>a>>b;
    if(a>b || (n==1 && a!=b))
    {
        cout<<0<<endl;
        return 0;
    }
    mi=a*(n-1)+b;
    mx=b*(n-1)+a;
    cout<<mx-mi+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    int m = n;
    if(m % 2 == 1) m++;
    cout << (double)m/2 / n << endl;
    return 0;
}


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

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

    int minv = 100000;
    for (int i = 0; i < n-1; ++i) {
        int s1 = 0;
        int s2 = 0;
        for (int j = 0; j <= i; ++j) s1 += w[j];
        for (int j = i + 1; j <n ; ++j) s2 += w[j];
        minv = min(minv, abs(s1 - s2));
    }
    cout << minv << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> l, r;

    rep(i, m) {
        int li, ri;
        cin >> li >> ri;
        l.push_back(li);
        r.push_back(ri);
    }
    cout << max(0, (*min_element(all(r)) - *max_element(all(l)) + 1)) << endl;
    return 0;
}



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

int main()
{
	int n,a,b,tmp=0;
	cin>>n>>a>>b;             
	for (int i=1; i<=n; i++) 
	{
		int q=i,k=0;
		do{
			k=k+(q%10);
			q=q/10;
		}while (q>0);
		if (k<=b && k>=a)
			tmp+=i;
	}
	cout<<tmp;
	return 0;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100000
#define MOD 1000000007

int main(void){
  int i,j,k,n,temp;
  int rank[6]={1,10,9,12,3,4};

  char s[MAX];
  scanf(" %s",s);

  long long dp[strlen(s)][13];

  for(i=0;i<strlen(s);i++){
    for(j=0;j<13;j++){
      dp[i][j]=0;
    }
  }

  if(s[strlen(s)-1]=='?'){
    for(i=0;i<10;i++){
      dp[0][i]=1;
    }
  }else{
    dp[0][s[strlen(s)-1]-'0']=1;
  }

  for(i=1;i<strlen(s);i++){
    if(s[strlen(s)-i-1]=='?'){
      for(j=0;j<13;j++){
        for(k=0;k<10;k++){
          dp[i][(j+k*rank[i%6])%13]+=dp[i-1][j];
        }
      }
      for(j=0;j<13;j++){
        dp[i][j]%=MOD;
      }
    }else{
      n=s[strlen(s)-i-1]-'0';
      for(j=0;j<13;j++){
        dp[i][(j+n*rank[i%6])%13]+=dp[i-1][j];
      }
      for(j=0;j<13;j++){
        dp[i][j]%=MOD;
      }
    }
  }

  printf("%lld\n",dp[strlen(s)-1][5]);

  return 0;
}


Measured memory_bytes: 10368
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    k = ni()
    l = 50
    ans = [l - 1 for _ in range(l)]

    for i in range(l):
        ans[i] += k // l

    for i in range(l):
        tgt = k % l
        if i < tgt:
            ans[i] += l
            ans[i] -= tgt - 1
        else:
            ans[i] -= tgt

    print(l)
    print(*ans, sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9448
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1000000 + 10;
const ll MOD = 998244353;
const ll INF = 1000000000000000000;

ll n, a[N];
ll sum[N], SUM, sum_p[N];

ll POW(ll x, ll t){
	if (t == 0) return 1;
	if (t % 2 == 0) return POW(x * x % MOD, t / 2);
	return x * POW(x, t - 1) % MOD;
}

ll ans = 0;

int main(){
	//ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		SUM += a[i];
		sum[a[i]] += a[i];
		SUM %= MOD;
	}
	for (int i = 1; i < N; i++){
		for (int j = i; j < N; j += i){
			sum_p[i] += sum[j];
			sum_p[i] %= MOD;
		}
		sum_p[i] = sum_p[i] * sum_p[i] % MOD;
	} 
	//cout << "YES";
	for (ll i = N - 1; i > 0; i--){
		for(ll j = 2 * i; j < N; j += i) sum_p[i] -= sum_p[j], sum_p[i] %= MOD;
		sum_p[i] += MOD;
		sum_p[i] %= MOD;
		ans += POW(i, MOD - 2) * sum_p[i] % MOD;
		ans %= MOD;
	}
	//cout << "YES";
	ans -= SUM;
	ans = (ans + MOD) % MOD;
	ans = ans * ((MOD + 1) / 2ll) % MOD;
	cout << (ans + MOD) % MOD;










	return 0;
}


Measured memory_bytes: 18688
#ifndef CLion
//#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m)%m)
#define rep(i,s,e) for (int i = s; i < e; ++i)
#define mem(a,v) memset(a , v , sizeof a)
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const int N = 1e4 + 9 , base = 26;

char a[10][10],b[10][10];
int n , m , k , tot;

void row( int r ){
    rep(i,0,m) b[r][i] = '&';
}

void col( int c ){
    rep(i,0,n) b[i][c] = '&';
}

void go( int x , int y ){
    rep(i,0,n) rep(j,0,m) b[i][j] = a[i][j];
    rep(i,0,10) if ( (x & (1 << i)) ) row(i);
    rep(i,0,10) if ( (y & (1 << i)) ) col(i);

    int cnt = 0;
    rep(i,0,n) rep(j,0,m) cnt += (b[i][j] == '#');
    tot += (cnt == k);
}

void Main(int cse , bool last){
    cin >> n >> m >> k;
    rep(i,0,n) rep(j,0,m) cin >> a[i][j];

    rep(i,0,pow(2,n)) rep(j,0,pow(2,m)) go(i,j);
    cout << tot;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef CLion
    freopen( "in.txt" , "r" , stdin  );
    //freopen( "out.txt", "w" , stdout );
#endif

    int t = 1;
    //cin >> t;
    for ( int cse = 1; cse <= t; ++cse ) Main(cse, cse == t);
    return 0;
}


Measured memory_bytes: 4020
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f

let () =
  let n = read_int () in
  let xs = read_ints n in
  let cs = Array.make 100002 0 in
  flip List.iter xs (fun x ->
    let i = min 100001 x in cs.(i) <- cs.(i) + 1);
  for_iter 0 100002 (fun i -> if i <= cs.(i) then cs.(i) - i else cs.(i))
  |> List.fold_left (+) 0
  |> printf "%d\n"


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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong(), y = sc.nextLong();
        String ans = Math.abs(x-y)>=2?"Alice":"Brown";
        System.out.println(ans);
    }
}


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

int main(){

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

    vector<vector<int> > A(n + 1, vector<int> (n + 1, 0));

    for(int i = 0; i < m; i++){
        A[a[i]][b[i]]++;
        A[b[i]][a[i]]++;
    }

    for(int i = 1; i <= n; i++){
        int ans = 0;
        for(int j = 0; j <= n; j++){
            ans += A[i][j];
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll x,ans;
int main(){
	cin >> x;
	ans=100;
	for(ll i=0;;i++){
		if(ans>=x)return printf("%lld",i),0;
		ans+=ans/100;
	}
	return 0;
}

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

int main() {
  int AN, BN, MN, X, Y, C, MIN=999999, MINA=999999, MINB=999999;
  cin >> AN >> BN >> MN;
  vector<int> A(AN), B(BN);
  rep(i, AN){
    cin >> A.at(i);
    MINA=min(MINA, A.at(i));
  }
  rep(i, BN){
    cin >> B.at(i);
    MINB=min(MINB, B.at(i));
  }
  MIN=MINA+MINB;
  rep(i, MN){
    cin >> X >> Y >> C;
    MIN=min(A.at(X-1)+B.at(Y-1)-C, MIN);
  }
  cout << MIN << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
const int N=1e6+5;
string a;
int main()
{
    int n,m;
    //scanf("%d",&n);
    cin>>a;
    if(a=="SUN") cout<<"7"<<endl;
    else if(a=="MON") cout<<"6"<<endl;
    else if(a=="TUE") cout<<"5"<<endl;
    else if(a=="WED") cout<<"4"<<endl;
    else if(a=="THU") cout<<"3"<<endl;
    else if(a=="FRI") cout<<"2"<<endl;
    else if(a=="SAT") cout<<"1"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if((a==b)&&(b==c)&&(c==a)){
  printf("Yes\n");
  } else {
  printf("No\n");
  }
  
  return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define ft first
#define sd second
#define pb(a) push_back(a)
#define PII std::pair<int,int>
#define PLL std::pair<ll,ll>
#define mp(a,b) std::make_pair(a,b)
#define ITR(a,b) for(auto a:b)
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=3000+10;
int n,a[MAXN],f[MAXN],e,beg[MAXN],to[MAXN],nex[MAXN],in[MAXN];
std::queue<int> q;
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline bool chkmin(T &x,T y){return y<x?(x=y,true):false;}
template<typename T> inline bool chkmax(T &x,T y){return y>x?(x=y,true):false;}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline void insert(int x,int y)
{
	to[++e]=y;
	nex[e]=beg[x];
	beg[x]=e;
}
inline void toposort()
{
	REP(i,1,n)if(!in[i])q.push(i);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(register int i=beg[x];i;i=nex[i])
		{
			in[to[i]]--,chkmax(f[to[i]],f[x]^1);
			if(!in[to[i]])q.push(to[i]);
		}
	}
}
int main()
{
	read(n);
	REP(i,1,n)read(a[i]);
	REP(i,1,n-1)
	{
		int u,v;read(u);read(v);
		if(a[u]>a[v])insert(v,u),in[u]++;
		if(a[v]>a[u])insert(u,v),in[v]++;
	}
	toposort();
	REP(i,1,n)if(f[i])printf("%d ",i);puts("");
	return 0;
}


Measured memory_bytes: 384