akhauriyash/Code-Regression huggingface dataset:
class Dice
  def initialize(numbers)
    @numbers = numbers
    @map = {:top => 1, :R => 6, :S => 2, :E => 3, :N => 5, :W => 4}
  end

  def move(vec)
    case vec
    when "N"
      temp = @map.clone
      temp[:top] = @map[:S]
      temp[:R] = @map[:N]
      temp[:S] = @map[:R]
      temp[:N] = @map[:top]
      @map = temp.clone
    when "W"
      temp = @map.clone
      temp[:top] = @map[:E]
      temp[:R] = @map[:W]
      temp[:E] = @map[:R]
      temp[:W] = @map[:top]
      @map = temp.clone
    when "S"
      temp = @map.clone
      temp[:top] = @map[:N]
      temp[:R] = @map[:S]
      temp[:S] = @map[:top]
      temp[:N] = @map[:R]
      @map = temp.clone
    when "E"
      temp = @map.clone
      temp[:top] = @map[:W]
      temp[:R] = @map[:E]
      temp[:E] = @map[:top]
      temp[:W] = @map[:R]
      @map = temp.clone
    end
  end

  def spin
    temp = @map.clone
    temp[:E] = @map[:N]
    temp[:W] = @map[:S]
    temp[:S] = @map[:E]
    temp[:N] = @map[:W]
    @map = temp.clone
  end

  def top_number
    @numbers[@map[:top] - 1]
  end

  def right_number
    @numbers[@map[:E] - 1]
  end

  def front_number
    @numbers[@map[:S] - 1]
  end

  def back_number
    @numbers[@map[:N] - 1]
  end

  def left_number
    @numbers[@map[:W] - 1]
  end

  def bottom_number
    @numbers[@map[:R] - 1]
  end

  def get_place(number)
    index = @numbers.index(number)
    @map.key(index + 1)
  end

  def numbers
    @numbers
  end

  def map
    @map
  end

  def equal?(dice)
    count = 1
    while count <= 6 do
      if dice.top_number == self.top_number
        4.times do
          if dice.left_number == self.left_number &&
             dice.right_number == self.right_number &&
             dice.front_number == self.front_number &&
             dice.back_number == self.back_number &&
             dice.bottom_number == self.bottom_number then
             return true
          end
          dice.spin
        end
      end
      if count % 2 == 0
        dice.move("N")
      else
        dice.move("W")
      end
      count += 1
    end
    return false
  end
end

n = gets.to_i
dices = Array.new(n)
n.times do |i|
  dices[i] = Dice.new(gets.split.map(&:to_i))
end

flag = false
for i in (0...n) do
  for j in ((i+1)...n) do
    if dices[i].equal?(dices[j])
      flag = true
    end
  end
end
flag ? (puts "No") : (puts "Yes")

Measured memory_bytes: 10868
#include<bits/stdc++.h>
using namespace std;
//挫折中。sortを使えば簡単に解ける、と思ったがsortの形式がわからない。わかりきったもののみ使うべきか、どうか。
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i<N;i++)
    cin >> a.at(i);
  sort(a.begin(), a.end(), greater<int>());

  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0)
      Alice += a.at(i);
    else
      Bob += a.at(i);
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
char s[110];
int n;
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%s",s);n=strlen(s);
	char a[]="keyence";
	if (n<7) cout<<"NO";
	else
	{
		int x=0,y=0;
		for (int i=0;i<7;i++) if (s[i]==a[i]) x++;else break;
		for (int i=n-1;i>n-8;i--) if (s[i]==a[7-(n-i)]) y++;else break;
		if (x+y>=7) cout<<"YES";
		else cout<<"NO";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010;
int N;
char s[maxn];
int main(){
	//freopen("in","r",stdin);
	scanf("%s",s+1);
	N=strlen(s+1);
	int ans=0,cnt=0;
	for(int i=1;i<=N;i++){
		if(s[i]=='g'){
			if(cnt)
				cnt--,ans++;
			else
				cnt++;
		}
		else{
			if(cnt)
				cnt--;
			else
				cnt++,ans--;
		}
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 384
fn main(){
  let mut buf = String::new();
  
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  let k: usize = buf.split_whitespace().skip(1).next().unwrap().parse().unwrap();
  
  buf.clear();
  
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  let mut ps: Vec<u32> = buf.split_whitespace().map(|e| e.parse().unwrap()).collect();

  ps.sort();

  let ans: u32 = ps.iter().take(k).sum();
  
  println!("{}", ans);
}


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

using namespace std;

void solve();

int main()
{
#ifdef OFFLINE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

typedef pair<int, int> pii;
#define fst first
#define snd second

const int N = 200000;

pii a[N];

void solve() {
    int n; cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i].fst;
        a[i].snd = i;
    }
    
    sort(a, a+n);

    set<int> s;
    s.insert(-1);
    s.insert(n);

    long long ans = 0;

    for (int i=0; i<n; i++) {
        auto ins = s.insert(a[i].snd);
        auto it = ins.fst;
        auto it_lo = it; --it_lo;
        auto it_up = it; ++it_up;

        ans += (long long)(*it - *it_lo) * (*it_up - *it) * a[i].fst;
    }

    cout << ans << endl;
}


Measured memory_bytes: 11136
N = int(input())
D = []
ans = 0
for i in range(N):
    a, b = map(int,input().split(' '))
    D.append((a+b,a,b))
D = sorted(D, reverse=True)
for n,i in enumerate(D):
    if n%2 == 0:
        ans += i[1]
    else:
        ans -= i[2]
print(ans)

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	float N;
	cin >> N;
	int gusu = N / 2;
	int kisu = (N + 1) / 2;
	float kisu1 = kisu;
	cout << float(kisu / N);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n, m; cin >> n >> m;
   V<queue<int>> A(n);
   for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
         int a; cin >> a; a--;
         A[i].push(a);
      }
   }

   V<set<int>> st(m);
   for (int i = 0; i < n; i++) {
      st[A[i].front()].insert(i);
      A[i].pop();
   }

   V<bool> deleted(m, false);
   bool terminal = false;
   int ans = INF;
   while (!terminal) {
      DUMP(st)
      int maxSize = 0, maxSport = -1;
      for (int j = 0; j < m; j++) {
         if (chmax(maxSize, (int)st[j].size())) {
            maxSport = j;
         }
      }
      chmin(ans, maxSize);
      DUMP(maxSport)
      deleted[maxSport] = true;
      DUMP(deleted)
      for (auto i : st[maxSport]) {
         while (A[i].size() > 0 && deleted[A[i].front()]) {
            A[i].pop();
         }
         if (A[i].size() == 0) {
            terminal = true;
            break;
         }
         st[A[i].front()].insert(i);
      }
      st[maxSport].clear();
      DUMP(st)
      cerr << endl;
   }
   cout << ans << endl;
   return 0;
}


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

A = sorted(list(map(int, input().split())))

INF = 10**6

ind = INF
for i in range(len(A)):
    if A[i]>=0:
        ind = i
        break
    else:
        A[i] *= -1

if ind == INF:
    ind = N

if ind %2 == 0:
    print(sum(A))
elif ind==N:
    print(sum(A)-2*A[ind-1])
else:
    print(sum(A)-2*min(A[ind], A[ind-1]))

Measured memory_bytes: 14412
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long
	int n;
	cin >> n;
	long long ans = 0;
	long long now = 0;
	int gyao = 0;
	cin >> gyao;
	if (gyao > 0) {
		now = gyao;
		ans = 0;
	}
	else {
		now = 1;
		ans = 1 - gyao;
	}
	long long final_ans = 1000000000000000;
	vector<int> wow;
	for (int i = 1;i < n;++i) {
		int hoge = 0;
		cin >> hoge;
			wow.push_back(hoge);
			if (now > 0) {
				if (hoge + now >= 0) {
					ans += abs(-1 - (hoge + now));
					now = -1;
				}
				else {
					now = hoge + now;
				}
			}
			else {
				if (hoge + now <= 0) {
					ans += abs(1 - (hoge + now));
					now = 1;
				}
				else {
					now += hoge;
				}
			}
		}
		final_ans = ans;
		if (gyao < 0) {
			now = gyao;
			ans = 0;
		}
		else {
			now = -1;
			ans = gyao + 1;
		}

		for (int i = 1;i < n;++i) {
			int hoge = wow[i-1];
			if (now > 0) {
				if (hoge + now >= 0) {
					ans += abs(-1 - (hoge + now));
					now = -1;
				}
				else {
					now = hoge + now;
				}
			}
			else {
				if (hoge + now <= 0) {
					ans += abs(-1 + (hoge + now));
					now = 1;
				}
				else {
					now += hoge;
				}
			}
		}
	cout << min(ans, final_ans) << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>//連立方程式
#include<math.h>

int main(void)
{
	double a,b,c,d,e,f,x,y;
	
	while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		x = (e * c - b * f) / (e * a - b * d);
		y = (c - x * a) / b;
		if (x == -0) x = 0;
		if (y == -0) y = 0; 
		printf("%4.3f %4.3f\n",x,y);
	}
	return 0;
}

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

char S[100001];


int main(void){

	int a,b,c,d;

	scanf("%d %d %d %d",&a,&b,&c,&d);

	printf("%d\n",(a<b?a:b)+(c<d?c:d));

	return 0;
}


Measured memory_bytes: 128
require 'pp'
n, m = STDIN.gets.split(" ").map(&:to_i)
xs = STDIN.gets.split(" ").map(&:to_i).sort

counts = m - n

if counts <= 0
  puts 0
else
  ds = []
  for i in 0...(xs.size-1)
    ds << xs[i+1] - xs[i]
  end

  ds = ds.sort
  puts ds[0, counts].reduce(:+)
end


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

#define loop(i,n) for(int i=1;i<=n;i++)
int n,m;
int order[1002];
int dice[1002];

int solve(){
  int pos=1;
  loop(i,n)cin>>order[i];
  loop(j,m)cin>>dice[j];
  for(int t=1;t<=m;t++){
    pos+=dice[t];
    if(pos>=n)return t;
    pos+=order[pos];
    if(pos>=n)return t;
  }
}

int main(){
  cin>>n>>m;
  while(n||m){
    cout<<solve()<<endl;
    cin>>n>>m;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    queue<ll> q;
    for (ll ai : a) q.push(ai);

    int m;
    cin >> m;
    vector<ll> b(m);
    rep(i, m) cin >> b[i];
    sort(b.begin(), b.end());

    for (ll bi : b) {
        while (q.front() < bi && !q.empty()) {
            q.pop();
        }
        if (q.front() == bi) {
            continue;
        } else {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << 1 << endl;

}



Measured memory_bytes: 7636
fun main() {
    nextInt()
    val n = nextLongList()
    println(n.map { it - 1 }.sum())
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 38904
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define NIL -1

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

struct NODE{
	int p, l, r;
};

struct NODE bt[25];

void preorder (int curr )
{
	if (curr == NIL ) return;
	cout << ' ' << curr;
	preorder (bt[curr].l );
	preorder (bt[curr].r );

}

void inorder (int curr )
{
	if (curr == NIL ) return;
	inorder (bt[curr].l );
	cout << ' ' << curr;
	inorder (bt[curr].r );
}

void postorder (int curr )
{
	if (curr == NIL ) return;
	postorder (bt[curr].l );
	postorder (bt[curr].r );
	cout << ' ' << curr;
}

int main()
{
	
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	int root;
	rep (i, n ){
		bt[i].p = NIL, bt[i].l = NIL, bt[i].r = NIL;		
	} // end rep
	rep (i, n ){
		int id, left, right;
		cin >> id >> left >> right;
		bt[id].l = left;
		bt[id].r = right;
		bt[left].p = id;
		bt[right].p = id;
	} // end rep
	rep (i, n )
		if (bt[i].p == NIL ){
			root = i; break;
		} // end if
	cout << "Preorder" << endl;
	preorder(root );				
	cout << endl;

	cout << "Inorder" << endl;
	inorder(root );				
	cout << endl;
	
	cout << "Postorder" << endl;
	postorder(root );				
	cout << endl;
		
	return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
#include<string.h>
int main()
{
	char a[1000];
	while(~scanf("%s",a))
	{
		int n=strlen(a);
		int flog=0;
		int f=0;
		for(int i=0;i<n;i++)
		{if(a[i]=='C') flog=1;
		if(a[i]=='F'&&flog==1)
		
		{f=1;printf("Yes\n");break;
		}
		}
		if(!f)printf("No\n");
		
	}
 
		
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    std::cout<<s[0] + std::to_string(s.size() - 2) +
        s[s.size() -1]<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>N;
    set<ll> d;
    rep(i,N) {
        cin>>A;
        d.insert(A);
    }
    cout<<d.size()<<endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

if s[0] == s[1] and s[2] == s[1]:
    print('No')
    exit()
if s[0] == s[1] and s[2] == s[3]:
    print('Yes')
    exit()
if s[0] == s[2] and s[3] == s[1]:
    print('Yes')
    exit()
if s[0] == s[3] and s[2] == s[1]:
    print('Yes')
    exit()

print('No')

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  int a[6],k;
  cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
  for(int i=0;i<5;i++)
  {
    for(int j=0;j<5;j++)
    {
      if(i!=j&&a[i]<a[j]&&a[j]-a[i]>k)
      {
        cout<<":("<<nl;
        return;
      }
    }
  }
  cout<<"Yay!\n";
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3644
#include <vector>
#include <iostream>
#include <numeric>
#include <algorithm>
#include <stack>
using namespace std;

/*
 * @title StronglyConnectedComponents
 */
class StronglyConnectedComponents{
public:
	int num,is_2sat,half,max_id,cnt;
	vector<vector<int>> edge;
	vector<int> label,order,low;
    stack<size_t> st;
	inline int rev(int i) { return i < half ? i + half : i - half; }
    inline void dfs(int& from) {
        low[from]=order[from]=cnt++;
        st.push(from);
        for(int& to:edge[from]) {
            if(order[to]==-1) {
                dfs(to);
                low[from]=min(low[from],low[to]);
            }
            else {
                low[from]=min(low[from],order[to]);
            }
        }
        if (low[from] == order[from]) {
            while(st.size()) {
                int u = st.top();st.pop();
                order[u] = num;
                label[u] = max_id;
                if (u == from) break;
            }
            max_id++;
        }
    }
	StronglyConnectedComponents(const int n, bool is_2sat=0):num(n),max_id(0),cnt(0),is_2sat(is_2sat){
		if(is_2sat) num<<=1;
		edge.resize(num);
		label.resize(num);
        order.resize(num,-1);
        low.resize(num);
	}
	inline int operator[](int idx) {
		return label[idx];
	}
	inline void make_edge(const int from,const int to) {
		edge[from].push_back(to);
	}
    //xがflg_xならばyがflg_y
	inline void make_condition(int x, bool flg_x, int y, bool flg_y) {
		if (!flg_x) x = rev(x);
		if (!flg_y) y = rev(y);
		make_edge(x, y);
		make_edge(rev(y), rev(x));
	}
    //is_2sat=1のときに、2satを満たすかを返却する
	inline bool solve(void) {
        for (int i = 0; i < num; i++) if (order[i] == -1) dfs(i);
        for (int& id:label) id = max_id-1-id;
		if(!is_2sat) return true;
        half=(num>>1);
		for (int i = 0; i < num; ++i) if (label[i] == label[rev(i)]) return false;
		return true;
	}
    vector<vector<int>> topological_sort(void) {
        vector<vector<int>> ret(max_id);
        for(int i=0;i<num;++i) ret[label[i]].push_back(i);
        return ret;
    }
	int is_true(int i) {
		return label[i] > label[rev(i)];
	}
	void print(void) {
		for(auto id:label) cout << id << " ";
		cout << endl;
	}
};


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    StronglyConnectedComponents scc(N);
    while(M--) {
        int u,v; cin >> u >> v;
        scc.make_edge(u,v);
    }
    scc.solve();
    auto vv=scc.topological_sort();
    cout << vv.size() << "\n";
    for(auto& v:vv) {
        cout << v.size();
        for(auto& e:v) cout << " " << e;
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 59812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define all(x) x.begin(), x.end()
using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    vector<pair<int,int>> aa, bb;
    rep(i,0,n) {
        aa.emplace_back(a[i],i);
        bb.emplace_back(b[i],i);
    }
    sort(all(aa));
    sort(all(bb));
    bool bad = false;
    rep(i,0,n) if(aa[i].first>bb[i].first) bad = true;
    if(!bad) {
        bool good = false;
        rep(i,1,n) if(aa[i].first<=bb[i-1].first) good = true;
        if(!good) {
            vector<int> p(n);
            rep(i,0,n) p[aa[i].second] = bb[i].second;
            vector<bool> seen(n);
            int cnt = 0;
            for(int j = 0; !seen[j]; j = p[j]) {
                seen[j] = true;
                ++cnt;
            }
            good = cnt<n;
        }
        bad = !good;
    }
    if(bad) cout << "No\n";
    else cout << "Yes\n";
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

// int main() {
//     while (true){
//         int H, W;
//         cin >> H >> W;
//         for (int i = 0; i < W; i++){
//             cout << '#';
//         }
//         cout << endl;
//         if (H == 0){
//             break;
//         }
//         for (int i = 0; i < H - 2; i++){
//             cout << '#';
//             for (int i = 0; i < W - 2; i++){
//                 cout << '.';
//             }
//             cout << '#';
//             cout << endl;
//         }
//         for (int i = 0; i < W; i++){
//             cout << '#';
//         }
//         cout << endl << endl;
//     }
// }

int main() {
    while (true){
        int H, W;
        cin >> H >> W;
        if (H == 0){
            break;
        }
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
                    cout << '#';                
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;

int main() {
	ll k = 1;
	cin >> n;
	REP(i, n) {
		k *= (i + 1);
		k %= MOD;
	}
	cout << k << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int x,y,z; cin >> x >> y >> z;
    int tmp = y;
    y = x;
    x = tmp;
     tmp = z;
    z = x;
    x = tmp ;
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# author: ismdeep
# dateime: 2019-02-09 20:08:40
# filename: b.py
# blog: https://ismdeep.com
a = [0, 0, 0, 0, 0]
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1

a.sort()

if 1 == a[1] and 1 == a[2] and 2 == a[3] and 2 == a[4]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,N = MI()
    A = sum(LI())
    print("YNeos"[H>A::2])
if __name__ == '__main__':
    main()

Measured memory_bytes: 78220
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// // descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, C, K;
    cin >> N >> C >> K;
    ll T[N];
    rep(i, 0, N) cin >> T[i];
    sort(T, T + N);

    ll rsl = 1;
    ll time = T[0] + K;
    ll cur_num = 1;

    rep(i, 1, N) {
        if(cur_num == C) {
            cur_num = 1;
            rsl++;
            time = T[i] + K;
        } else {
            if(T[i] <= time) {
                cur_num++;
            } else {
                rsl++;
                cur_num = 1;
                time = T[i] + K;
            }
        }
    }
    cout << rsl << endl;


}



Measured memory_bytes: 1024
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	var inputs []string

	for i := 0; i <= 2; i++ {
		sc.Scan()
		inputs = append(inputs, sc.Text())
	}

	lenFirst := len(inputs[0])

	if inputs[0] == inputs[1][:lenFirst] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1760
#include<iostream>
#include<cmath>
#include <cstring>
#include<map>
#define MAX 11
#define MAX_BITS 23
using namespace std;
int h,w;
int sum;
int sx,sy;
map<int,int> dp;
int s[MAX][MAX];
int housInd[MAX][MAX];
/*
 2
1 3
 0
*/
int dx[]={0,-1,0,1},dy[]={1,0,-1,0};
int func(int ny, int nx, int bit, int numResults){
//	cout << "hi" << bit << endl;
	if(housInd[ny][nx] != -1 && dp.find(bit | housInd[ny][nx] << MAX_BITS) != dp.end()){
		return dp[bit | housInd[ny][nx] << MAX_BITS];
	}
	
	int ret = 0;
	bool isLast = bit == (1 << sum) - 1;
	
	if (isLast && dp.find(bit | housInd[ny][nx] << MAX_BITS) != dp.end()) return dp[bit | housInd[ny][nx] << MAX_BITS];
	for (int i = 0; i < 4; i++) {
		for (int x = nx+dx[i], y = ny+dy[i]; 0 <= x && x < w && 0 <= y && y < h; x += dx[i], y += dy[i]) {
			int ind = housInd[y][x];
			if (ind == -1) {
				if (isLast && s[y][x] == 2) return dp[bit | housInd[ny][nx] << MAX_BITS] = 1;
			}
			else {
				if (!isLast) {
					if ((bit & 1 << ind) == 0) {
						ret += func(y, x, bit | (1 << ind), numResults+1);
						break;
					}
				}
			}
		}
	}
	
	return housInd[ny][nx] != -1 && numResults % 2 == 0 ? (dp[bit | housInd[ny][nx] << MAX_BITS] = ret) : ret;
}
int main(){
	while(cin>>w>>h,w||h){
		sum=0;
		dp.clear();
		for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					cin>>s[i][j];
					housInd[i][j] = -1;
					if(s[i][j]==2){
						sy=i;sx=j;
					}else if(s[i][j]==1) {
						housInd[i][j] = sum++;
					}
				}
		}
		int ans=func(sy,sx,0, 0);
		cout<<ans<<endl;
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> s(N);
    int sum = 0; 
    rep(i, N) {
        cin >> s[i];
        sum += s[i];
    }
    if (sum % 10 == 0) {
        int minus = sum;
        sort(all(s));
        rep(i, N) {
            if (s[i] % 10 != 0) {
                minus = s[i];
                break;
            }
        }
        sum -= minus;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
import math
def p_l(n):
    for i in range(n-1, 1, -1):
        flag=0
        for j in range(2, int(math.sqrt(i)) + 1):
            if i % j == 0:
                flag=1
        if flag==1:continue
        return i
def p_h(n):
    for i in range(n+1,50022):
        flag=0
        for j in range(2, int(math.sqrt(i)) + 1):
            if i % j == 0:
                flag=1
        if flag==1:continue
        return i   
while 1:
    try:
        n=int(input())
        print(p_l(n),p_h(n))
    except:break


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

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<int64_t> up(N), down(N);
    vector<int64_t> a(N + 1);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        if (i == 0) up[i] = a[i];
        else up[i] = __gcd(up[i - 1], a[i]);
    }
    down[N - 1] = a[N - 1];
    for (int i = N - 2; i >= 0; --i) {
        down[i] = __gcd(down[i + 1], a[i]);
    }

    int maxv = max(up[N - 2], down[1]);
    for (int i = 1; i < N - 1; ++i) {
        maxv = max<int64_t>(maxv, __gcd(up[i - 1], down[i + 1]));
    }

    cout << maxv << "\n";

    return 0;
}


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

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPS(i, r, n) for (ll i = (r); i < (n); i++)
#define REPR(i, n) for(ll i = (n); i >= 0; i--) // from n to 0
#define REPRS(i, r, n) for(ll i = (n); i >= (r); i--) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(ll);

/***** MAIN *****/
int main() {
  string s;
  cin >> s;
  ll stringLength = s.size();
  ll numerical_sequence[stringLength+1];
  numerical_sequence[0] = 0;
  
  ll count = 0, ans = 0;
  REP(i, stringLength) {
    if(s[i] == '>') count = 0;
    else count++;
    numerical_sequence[i+1] = count;
  }
  count = 0;
 
  ans += numerical_sequence[stringLength];
  REPR(i, stringLength-1) {
    if(s[i] == '<') count = 0;
    else count++;
    ans += max(numerical_sequence[i], count);
  }

  cout << ans;

  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(ll a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(ll i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}

Measured memory_bytes: 4740
#define Z 100
M[Z][Z][2],l=100000;main(w,h,i,j){
	M[0][0][0]=M[0][0][1]=M[1][1][0]=M[1][1][1]=1;
	for(i=1;i<Z;i++)M[i][0][0]=M[i-1][0][0],M[i][0][1]=0;
	for(j=1;j<Z;j++)M[0][j][0]=0,M[0][j][1]=M[0][j-1][1];
	for(i=1;i<Z;i++){
		for(j=1;j<Z;j++)M[i][j][0]=(M[i-1][j][0]+M[i-1][j-1][1])%l,M[i][j][1]=(M[i][j-1][1]+M[i-1][j-1][0])%l;
	}
	for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0);
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<pii> arr (N);

	vi s1 (N);
	vi e1 (N);
	vi s2 (N);
	vi e2 (N);
	vi s3 (N);
	vi e3 (N);
	vi s4 (N);
	vi e4 (N);
	F0R(i, N) {
		int a, b; cin >> a >> b; --a; --b;
		s1[i] = a + b;
		e1[i] = -a -b;
		s2[i] = a - b;
		e2[i] = b - a;
		s3[i] = -a + b;
		e3[i] = a - b;
		s4[i] = -a -b;
		e4[i] = a + b;
	}
	sort(s1.rbegin(), s1.rend());
	sort(s2.rbegin(), s2.rend());
	sort(s3.rbegin(), s3.rend());
	sort(s4.rbegin(), s4.rend());
	sort(e1.rbegin(), e1.rend());
	sort(e2.rbegin(), e2.rend());
	sort(e3.rbegin(), e3.rend());
	sort(e4.rbegin(), e4.rend());

	int hi = 0;
	hi = max(hi, s1[0] + e1[0]);
	hi = max(hi, s2[0] + e2[0]);
	hi = max(hi, s3[0] + e3[0]);
	hi = max(hi, s4[0] + e4[0]);
	print(hi);
	}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            cnt++;
    }
    cout<<cnt;
    return 0;
}

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

long long nCr(int n, int r) {
    long long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans * i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

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

    vector<int> num(N + 1);
    for (int i = 0; i < N + 1; i++) {
        num[i] = 0;
    }

    for (int i = 2; i <= N; i++) {
        int t = i;
        for (int j = 2; j <= N; j++) {
            int cnt = 0;
            while (t % j == 0) {
                t /= j;
                cnt++;
            }
            num[j] += cnt;
        }
    }

    int A75 = 0;
    int A25 = 0;
    int A15 = 0;
    int A5 = 0;
    int A3 = 0;

    for (int i = 0; i < N + 1; i++) {
        if (num[i] >= 2 && num[i] < 4) {
            A3++;
        }
        else if (num[i] >= 4 && num[i] < 14) {
            A5++;
        }
        else if (num[i] >= 14 && num[i] < 24) {
            A15++;
        }
        else if (num[i] >= 24 && num[i] < 74) {
            A25++;
        }
        else if (num[i] >= 74) {
            A75++;
        }
    }

    int ans = A75;
    if (A25 + A75 >= 2) {
        ans += nCr(A25 + A75, 2) * 2;
    }
    ans += (A25 + A75) * (A3 + A5 + A15);
    if (A15 + A25 + A75 >= 2) {
        ans += nCr(A15 + A25 + A75, 2) * 2;
    }
    ans += (A15 + A25 + A75) * A5;
    if (A5 + A15 + A25 + A75 >= 3) {
        ans += nCr(A5 + A15 + A25 + A75, 3) * 3;
    }
	ans += nCr(A5 + A15 + A25 + A75, 2) * A3;

    cout << ans << endl;
}


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

int main() {
    string n;
    string m;
 
   cin >> n >> m;
  int ans = 0;
  int ans1 = 0;
  if(n=="A"){
    ans = 10;
  }else if(n=="B"){
    ans = 11;
  }else if(n=="C"){
    ans = 12;
  }else if(n=="D"){
    ans = 13;
  }else if(n=="E"){
    ans = 14;
  }else if(n=="F"){
    ans = 15;
  }
  
  if(m=="A"){
    ans1 = 10;
  }else if(m=="B"){
    ans1 = 11;
  }else if(m=="C"){
    ans1 = 12;
  }else if(m=="D"){
    ans1 = 13;
  }else if(m=="E"){
    ans1 = 14;
  }else if(m=="F"){
    ans1 = 15;
  }
  
  if(ans < ans1){
    cout << "<" << endl;
  }else if(ans > ans1){
    
    cout << ">" << endl;
  }else{
    cout << "=" << endl;
  }
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll N, C;
  cin >> N >> C;
  vector<ll> x(N + 2), v(N + 2);
  x[0] = v[0] = 0;
  x[N + 1] = C;
  v[N + 1] = 0;
  repp(i, 1, N) cin >> x[i] >> v[i];

  vector<ll> cl(N + 2);
  ll temp = 0;
  repp(i, 0, N + 1) {
    temp += v[i];
    cl[i] = temp - x[i];
  }
  repp(i, 1, N + 1) {
    chmax(cl[i], cl[i - 1]);
  }

  vector<ll> acl(N + 2);
  temp = 0;
  repr(i, N + 1, 0) {
    temp += v[i];
    acl[i] = temp - (C - x[i]);
  }
  repr(i, N, 0) {
    chmax(acl[i], acl[i + 1]);
  }

  ll ans = 0;

  repp(i, 0, N) {
    ll temp = cl[i] + acl[i + 1];
    chmax(ans, temp - min(x[i], C - x[i + 1]));
  }

  cout << ans << endl;
}

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

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
*/




Measured memory_bytes: 25176
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        cout << 'x';
    }
    cout << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
k,t=map(int,input().split())
a=list(map(int,input().split()))
b=max(a)

if k%2==0:
    if 0<=2*(b-k//2)-1:
        print(2*(b-k//2)-1)
    else:
        print(0)

else:
    if 0<=2*(b-(k+1)//2):
        print(2*(b-(k+1)//2))
    else:
        print(0)

Measured memory_bytes: 3064