akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int dp[101][101];
int a[101];	
int k;
int dfs(int pos,int sta,int lead,int limit){
	if(pos == -1) return sta == k;//最后看是否恰有k为非零位
	if(!lead&&!limit&&dp[pos][sta]!=-1) return dp[pos][sta];
	int up = limit?a[pos]:9;
	int tmp = 0;
	for(int i = 0;i <= up;++i){
		if(lead&&i == 0) tmp += dfs(pos - 1,sta,lead,limit&&i == a[pos]);//注意前导零
		else tmp += dfs(pos-1,sta + (i == 0?0:1),lead&&i == 0,limit&&i == a[pos]);
	}
	if(!limit&&!lead) dp[pos][sta] = tmp;//记录状态
	return tmp;
}
int main(){
	string s;
	cin >> s;

	cin >> k;
	int l = s.size();
	int pos = 0;
	memset(dp,-1,sizeof dp);
	for(int i = l-1;i >= 0;-- i){
		a[pos++] = s[i] - '0';
	}
	cout <<	dfs(pos-1,0,1,1);
}

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

int main() {
	int n;
	cin >> n;
	n=n%10;
	if (n==3) cout << "bon" << endl;
	else if (n==0 || n==1 || n==6 || n==8) cout << "pon" << endl;
	else cout << "hon" << endl;
	return 0;
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int k = in.nextInt();
		int r = 0;
		for (int i = 0; i < n; i++)
			if (in.nextInt() >= k)
				r++;
		System.out.println(r);
		in.close();
	}
}

Measured memory_bytes: 49092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
using vp = vector<pair<int,int>>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main(){
    string s;cin >> s;
    int n;cin >> n;
    deque<char> ans;
    rep(i,s.size()) ans.push_back(s[i]);
    bool TF = true;
    rep(i,n){
        int a;cin >> a;
        if(a == 1){
            if(TF) TF = false;
            else if(!TF) TF = true;
        }
        if(a == 2){
            int b;cin >> b;
            char c;cin >> c;
            if(b == 1){
                if(TF) ans.push_front(c);
                if(!TF) ans.push_back(c);
            }
            if(b == 2){
                if(TF) ans.push_back(c);
                if(!TF) ans.push_front(c);
            }
        }
    }
    string Ans = "";
    if(!TF) reverse(ans.begin(),ans.end());
    rep(i,ans.size()) Ans += ans[i];
    cout << Ans << endl;
}

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

struct die {
	int val[6];
	void N() {
		int tmp[6];
		for (int i = 0; i < 6; i++) {
			tmp[i] = val[i];
		}
		val[0] = tmp[1];
		val[4] = tmp[0];
		val[5] = tmp[4];
		val[1] = tmp[5];
	}
	void E() {
		int tmp[6];
		for (int i = 0; i < 6; i++) {
			tmp[i] = val[i];
		}
		val[2] = tmp[0];
		val[5] = tmp[2];
		val[3] = tmp[5];
		val[0] = tmp[3];
	}
	void W() {
		int tmp[6];
		for (int i = 0; i < 6; i++) {
			tmp[i] = val[i];
		}
		val[3] = tmp[0];
		val[5] = tmp[3];
		val[2] = tmp[5];
		val[0] = tmp[2];
	}
	void S() {
		int tmp[6];
		for (int i = 0; i < 6; i++) {
			tmp[i] = val[i];
		}
		val[0] = tmp[4];
		val[1] = tmp[0];
		val[5] = tmp[1];
		val[4] = tmp[5];
	}
	int find(int a, int b) {
		if ((val[3] == a && val[1] == b) || (val[1] == a && val[2] == b) || (val[2] == a && val[4] == b) || (val[4] == a && val[3] == b)) {
			return val[0];
		}
		if ((val[3] == a && val[5] == b) || (val[5] == a && val[2] == b) || (val[2] == a && val[0] == b) || (val[0] == a && val[3] == b)) {
			return val[1];
		}
		if ((val[0] == a && val[1] == b) || (val[1] == a && val[5] == b) || (val[5] == a && val[4] == b) || (val[4] == a && val[0] == b)) {
			return val[2];
		}
		if ((val[0] == a && val[4] == b) || (val[4] == a && val[5] == b) || (val[5] == a && val[1] == b) || (val[1] == a && val[0] == b)) {
			return val[3];
		}
		if ((val[0] == a && val[2] == b) || (val[2] == a && val[5] == b) || (val[5] == a && val[3] == b) || (val[3] == a && val[0] == b)) {
			return val[4];
		}
		if ((val[3] == a && val[4] == b) || (val[4] == a && val[2] == b) || (val[2] == a && val[1] == b) || (val[1] == a && val[3] == b)) {
			return val[5];
		}
	}
};

int main()
{
	int q, a, b;
	die d;
	for (int i = 0; i < 6; i++) {
		cin >> d.val[i];
	}
	cin >> q;
	while (q--) {
		cin >> a >> b;
		cout << d.find(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);
    let mut v: Vec<i32> = vec![-1;n];

    for _ in 0..m{
        let line = read_as_vec::<i32>();
        let (s, c) = (line[0] as usize-1, line[1]);
        if s+1 > n{
            println!("-1");
            return;
        }

        if n != 1 && s == 0 && c == 0{
            println!("-1");
            return;
        }

        if v[s] != -1 && v[s] != c{
            println!("-1");
            return;
        }
        v[s] = c;
    }

    if n == 1{
        if v[0] == -1{
            println!("0");
            return;
        }else{
            println!("{}", v[0]);
            return;
        }
    }

    print!("{}", cmp::max(v[0], 1));
    for i in 1..n{
        if v[i] < 0{
            print!("0");
        }else{
            print!("{}", v[i]);
        }
    }
    println!("");
}


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

int main(){
  string s;
  cin >> s;
  int l = s.length();
  int a = 0, b = 0;
  rep(i, l){
    if(i % 2){
      if(s[i] != '0') a++;
      if(s[i] != '1') b++;
    } else {
    if(s[i] != '1') a++;
    if(s[i] != '0') b++;
    }
  }
  cout << min(a, b) << endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

const int maxn = 500005;
const int mod = 1e9+7;
ll f[maxn],rf[maxn];
ll fpow(ll a,ll b)
{
    ll ret = 1;
    while(b){if(b&1) ret=ret*a%mod;a=a*a%mod;b>>=1;}
    return ret;
}
void init()
{
    f[0] = 1;
    for(int i=1;i<maxn;++i) f[i]=f[i-1]*i%mod;
    rf[maxn-1] = fpow(f[maxn-1],mod-2);
    for(int i=maxn-2;i>=0;--i) rf[i]=rf[i+1]*(i+1)%mod;
}
ll comb(ll n,ll k){if(n<k||k<0)return 0;return f[n]*rf[k]%mod*rf[n-k]%mod;}
int main() {
    init();
    int n,m;
    cin>>n>>m;
    ll ans=f[n]*comb(m,n)%mod;
    ll tmp=0;
    for(int i=0;i<=n;++i) {
        int flag=(i&1)?-1:1;
        tmp+=flag*comb(n,i)*comb(m-i,n-i)%mod*f[n-i]%mod;
    }
    tmp%=mod;
    if(tmp<0) tmp+=mod;
    cout<<ans*tmp%mod<<endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin>>n>>k;
  ll h[n+1];
  for(ll i=1;i<=n;i++)
  {
  cin>>h[i];
  }
  ll dp[n+1];
  dp[1]=0;
  for(ll i=2;i<=n;i++)
  {
  dp[i]=LLONG_MAX;
  for(ll j=1;j<=k;j++)
  {
  if(i-j<=0) continue;
  dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
  }
  }
  cout<<dp[n];
}


Measured memory_bytes: 5196
#include<iostream>
using namespace std;
struct data {
  char name[11];
  int time;
};
int main() {
  int n, q, curtime = 0; cin >> n >> q;
  struct data queue[100000];
  for (int i = 0; i < n; ++i) cin >> queue[i].name >> queue[i].time;
  int head = 0, tail = n;
  while (head!=tail) {
    struct data s = queue[head%100000];
    ++head;
    s.time -= q;
    if (s.time <= 0) {
      curtime += (s.time + q);
      cout << s.name << " " << curtime << endl;
    }
    else {
      curtime += q;
      queue[tail%100000]=s;
      ++tail;
    }
  }
  return 0;
}



Measured memory_bytes: 4660
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    ll n, k;
    cin >> n >> k;
    int c = 0;
    while (n > 0) {
        n /= k;
        c ++;
    }
    println(c)
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	
  	int A[100];
  	int count = 0, n, mini;
  
  	cin >> n;
  	for(int i=0;i<n;i++) 
  	cin >> A[i];
  
  	for(int i=0;i<n;i++) {
  	
    mini = i;
    for(int j=i;j<n;j++)
    if(A[j]<A[mini])
    mini = j;
    
    
    if(mini != i) {
    	
      count++;
      swap(A[i], A[mini]);
      
    }
}

  	for(int i=0;i<n-1;i++)
    cout << A[i] << " ";
    
    cout << A[n-1] << "\n"
    	 << count << "\n";
  
	return 0;
}


Measured memory_bytes: 3080
#include<iostream>

using namespace std;

int main() {
	int r, g, b;

	cin >> r >> g >> b;

	if (((r * 100 + g * 10 + b) % 4) != 0) {
		cout << "NO";
	}
	else {
		cout << "YES";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cstring>
using namespace std;


/*
typedef struct {
	int a;
	char b;
}student;

struct name {
	int a;
	char b;
}; //c++中定义结构体变量可以直接用 name stu; c中定义结构体变量要用 struct name stu;
*/

struct Node {
	int num;
	Node* prev;
	Node* next;
};

class doubleLinked {
public:
	doubleLinked() {
		head = NULL;
	}
	~doubleLinked() {
		delete head;
	}
	void insert(int x) {
		Node* new_Node = new Node;
		if (head == NULL) {
			head = new_Node;
			head->num = x;
			head->prev = head;
			head->next = head;
		}
		else {
        new_Node->num = x;
		new_Node->next = head;
		new_Node->prev = head->prev;
		head->prev->next = new_Node;
		head->prev = new_Node;
		head = new_Node;
		}
		
	}
	void eleDelete(int x) {
		if (head == NULL)
			return;
		if (head->num == x) {
			deleteFirst();
		}
		else {
			Node* indexSearch = head->next;
			while (indexSearch!= head) {
				if (indexSearch->num == x) {
					indexSearch->next->prev = indexSearch->prev;
					indexSearch->prev->next = indexSearch->next;
					delete indexSearch;
					return;
				}
				indexSearch = indexSearch->next;
			}
		}
	}
	void deleteFirst() {
		if (head == NULL)
			return;
		if (head->next == head) {
			delete head;
			head = NULL;
		}
		else {
			Node* del_Node = head;
			del_Node->next->prev = del_Node->prev;
			del_Node->prev->next = del_Node->next;
			head = del_Node->next;
			delete del_Node;
		}
	}
	void deleteLast() {
		if (head == NULL)
			return;
		if (head->next == head) {
			delete head;
			head = NULL;
		}
		else {
			Node* del_Node = head->prev;
			del_Node->prev->next = del_Node->next;
			del_Node->next->prev = del_Node->prev;
			delete del_Node;
		}
	}
	void showList() {
		if (head != NULL)
			cout << head->num;
		Node* new_Node = head->next;
		while (new_Node != head) {
			cout << " " << new_Node->num;
			new_Node = new_Node->next;
		}
		cout << endl;
	}
private:
	Node* head;
};

int main() {

	int n;
	cin >> n;
	char m_str[20];
	int num;
	doubleLinked my_list;
	for (int i = 0; i < n; i++) {
		//string m_str;
		//cin >> m_str;
		scanf("%s", m_str);
		if (m_str[0] == 'i') {
			scanf("%d", &num);
			my_list.insert(num);
		}
		else if (strlen(m_str)==6) {
			scanf("%d", &num);
			my_list.eleDelete(num);
		}
		else if (m_str[6] == 'F') {
			my_list.deleteFirst();
		}
		else if(m_str[6] == 'L') {
			my_list.deleteLast();
		}
	}
	my_list.showList();
	return 0;
}


Measured memory_bytes: 34392
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

ll mod(ll val, ll m) {
    ll res = val % m;
    if (res < 0) res += m;
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    vint S(N);
    vint T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];
    ll p = 1000000007;
    v2ll dp(N + 1, vll(M + 1, 0));
    dp[0][0] = 1;
    ll ans = 0;
    rep(i, N + 1) dp[i][0] = 1;
    rep(i, M + 1) dp[0][i] = 1;
    REP(i, 1, N + 1) {
        REP(j, 1, M + 1) {
            if (S[i - 1] == T[j - 1]) {
                dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
                dp[i][j] %= p;
            }
            else {
                dp[i][j] = mod(dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1], p);
                //dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]); //dp[i - 1][j] + dp[i][j - 1] - 1; //max(dp[i][j - 1], dp[i - 1][j]);
              
            }
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}

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

#define ll long long 

int n, a, b, c, d;

int main(){
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	if(a > b) std::swap(a, b);
	for(int i = 0; i <= n - 1; ++ i){
		ll l = 1ll * c * i - 1ll * d * (n - 1 - i);
		ll r = 1ll * d * i - 1ll * c * (n - 1 - i);
		if(l <= b - a && b - a <= r){
			return printf("YES\n"), 0;
		}
	}
	printf("NO\n");
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int ans = K; rep(i, N-1) ans *= K-1;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a;
  cin>>a;
  int cou=0;
  bool pflag=true;
  bool wflag=true;
  bool gflag=true;
  bool yflag=true;
  rep(i,a){
    char c;
    cin>>c;
    if(c=='P'&&pflag){
      cou++;
      pflag=false;
    }
    if(c=='W'&&wflag){
      cou++;
      wflag=false;
    }
    if(c=='G'&&gflag){
      cou++;
      gflag=false;
    }
    if(c=='Y'&&yflag){
      cou++;
      yflag=false;
    }
  }
  if(cou==3){
    cout<<"Three"<<endl;
  }
  else{
    cout<<"Four"<<endl;
  }
}


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

typedef long long ll;
using namespace std;

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

	map<char,int> cntS;
	map<char,int> cntT;

	string s,t; cin >> s >> t;

	for (int i = 0;i < s.size();i++){
		cntS[s[i]]++;
		cntT[t[i]]++;
	}

	bool b[26];
	for (int i = 0;i < 26;i++) b[i] = false;

	for (int i = 0;i < 26;i++){
		char c = 'a' + i;
		for (int j = 0;j < 26;j++){
			if(cntS[c] == cntT['a'+j] && !b[j]){
				b[j] = true;
				break;
			}
			if(j == 25){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;

}



Measured memory_bytes: 916
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (x, y, a, b, c) = (v[0], v[1], v[2], v[3], v[4]);
    let p = read_vec::<i64>();
    let q = read_vec::<i64>();
    let r = read_vec::<i64>();
    let mut heap = BinaryHeap::new();
    for pnum in p {
        heap.push((pnum, 0));
    }
    for qnum in q {
        heap.push((qnum, 1));
    }
    for rnum in r {
        heap.push((rnum, 2));
    }

    let mut p_count = 0;
    let mut q_count = 0;
    let mut total = 0;
    let mut ans = 0i64;
    while let Some((num, color)) = heap.pop() {
        if color == 0 {
            if p_count == x {
                continue;
            }
            p_count += 1;
        }
        if color == 1 {
            if q_count == y {
                continue;
            }
            q_count += 1;
        }
        ans += num;
        total += 1;

        if total == x + y {
            break;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 15556
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
        int N;
        int a[100];
        cin >> N;
        for (size_t i = 0; i < N; i++) {
                cin >> a[i];
        }
        sort(a,a+N,greater<int>());
        int Alice = 0;
        int Bob = 0;
        for (size_t i = 0; i < N; i++) {
                if(i%2==0) {
                        Alice += a[i];
                }else{
                        Bob += a[i];
                }
        }
        cout << Alice - Bob << endl;

        return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

double yma[4];
double ymi[4];
double xma[4];
double xmi[4];
string str = "UDLR";

double calBoxArea(double time){
	double y_max = -1000000000;
	double y_min = 1000000000;
	double x_max = -1000000000;
	double x_min = 1000000000;
	// U
	y_max = max(y_max, yma[0] + time);
	y_min = min(y_min, ymi[0] + time);
	x_max = max(x_max, xma[0]);
	x_min = min(x_min, xmi[0]);
	// D
	y_max = max(y_max, yma[1] - time);
	y_min = min(y_min, ymi[1] - time);
	x_max = max(x_max, xma[1]);
	x_min = min(x_min, xmi[1]);
	// L
	y_max = max(y_max, yma[2]);
	y_min = min(y_min, ymi[2]);
	x_max = max(x_max, xma[2] - time);
	x_min = min(x_min, xmi[2] - time);
	// R
	y_max = max(y_max, yma[3]);
	y_min = min(y_min, ymi[3]);
	x_max = max(x_max, xma[3] + time);
	x_min = min(x_min, xmi[3] + time);

	return (y_max - y_min) * (x_max - x_min);
}

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

	REP(i, 4){
		yma[i] = -1000000000;
		ymi[i] = 1000000000;
		xma[i] = -1000000000;
		xmi[i] = 1000000000;
	}

	ll n;cin >> n;
	REP(i, n){
		double x, y;
		char c;
		cin >> x >> y >> c;
		REP(j, 4)if(str[j] == c){
			yma[j] = max(yma[j], y);
			xma[j] = max(xma[j], x);
			ymi[j] = min(ymi[j], y);
			xmi[j] = min(xmi[j], x);
		}
	}

	vector<double> ivent(1, 0);
	REP(i, 4)REP(j, i) {
		ivent.EB(abs(ymi[i] - ymi[j]) / 2.);
		ivent.EB(abs(ymi[i] - ymi[j]));
		ivent.EB(abs(yma[i] - yma[j]) / 2.);
		ivent.EB(abs(yma[i] - yma[j]));

		ivent.EB(abs(xmi[i] - xmi[j]) / 2.);
		ivent.EB(abs(xmi[i] - xmi[j]));
		ivent.EB(abs(xma[i] - xma[j]) / 2.);
		ivent.EB(abs(xma[i] - xma[j]));
	}

	double ans = 1000000000000000000.;

	REP(i, ivent.size()){
		ans = min(ans, calBoxArea(ivent[i]));
	}

	cout << Decimal << ans << endl;

	return 0;
}


Measured memory_bytes: 256
R, G, B, n = map(int, input().split())

ans = 0
rmax = n // R
for i in range(rmax + 1):
    gmax = (n - R * i) // G
    for j in range(gmax + 1):
        if (n - R * i - G * j) % B == 0:
            ans += 1
print(ans)

Measured memory_bytes: 40300
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	int x, y, z;
	x = y = z = 0;
	for(int i = 0; i < n; ++i){
		int p;
		cin >> p;
		if(p <= a) x++;
		else if(p <= b) y++;
		else z++;
	}
	cout << min(x, min(y, z)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second


ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


int main(){
    int n;
    cin>>n;
    vi v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }
    vi a(n);
    vi b(n);
    vi c(n);
    a[0] = v[0];
    for(ll i=1;i<n;i++){
        a[i] = gcd(a[i-1],v[i]);
    }

    b[n-1] = v[n-1];
    for(ll i=(n-2);i>=0;i--){
        b[i] = gcd(b[i+1],v[i]);
    }

    c[0] = b[1];
    c[n-1] = a[n-2];

    for(ll i=1;i<n-1;i++){
        c[i] = gcd(a[i-1],b[i+1]);
    }



    sort(c.begin(),c.end());

    cout<<c[n-1]<<endl;

}

Measured memory_bytes: 3456
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
const long long INF = 1LL<<58;
using namespace std;


auto former(const vector<long long> &v, long long x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
auto latter(const vector<long long> &v, long long x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}


int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<long long> S(a), T(b);
    for (int i = 0; i < a; i++) {
        cin >> S[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> T[i];
    }
    S.push_back(INF);S.push_back(-INF);
    T.push_back(INF);T.push_back(-INF);
    sort(S.begin(), S.end()); sort(T.begin(), T.end());
    for (int i = 0; i < q; i++) {
        long long x;
        cin >> x;
        long long ans = INF;

        for (int j = 0; j < 2; j++) {
            long long first = (j ? S[former(S, x)] : S[latter(S, x)]);
            for (int k = 0; k < 2; k++) {
                long long second = (k ? T[former(T, x)] : T[latter(T, x)]);
                ans = min(ans, abs(x-first) + abs(first-second));
            }
        }

        for (int j = 0; j < 2; j++) {
            long long first = (j ? T[former(T, x)] : T[latter(T, x)]);
            for (int k = 0; k < 2; k++) {
                long long second = (k ? S[former(S, x)] : S[latter(S, x)]);
                ans = min(ans, abs(x-first) + abs(first-second));
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] a = new int[10];
			for (int i = 0; i < n; i++) {
				int b = scanner.nextInt();
				a[b]++;
			}
			int sum = 0;
			for (int i = 1; i < 5; i++) {
				int c = Math.min(a[i], a[10 - i]);
				sum += c;
				a[i] -= c;
				a[10 - i] -= c;
			}
			sum += a[5] / 2;
			a[5] %= 2;
			ans = 0;
			dfs(1, 0, a, 0);
			System.out.println(sum + ans);
		}

	}

	int ans;

	private void dfs(int i, int sum, int[] a, int now) {
		int rem = sum;
		for (int j = 1; j < 10; j++)
			rem += a[j] * j;
		if (now + rem / 10 <= ans)
			return;
		ans = Math.max(ans, now);
		if (sum == 10) {
			dfs(1, 0, a, now + 1);
			return;
		}
		if (i >= 10)
			return;
		dfs(i + 1, sum, a, now);
		if (a[i] > 0 && sum + i <= 10) {
			a[i]--;
			dfs(i, sum + i, a, now);
			a[i]++;
		}
	}
}

Measured memory_bytes: 30624
#include<bits/stdc++.h>
using namespace std;
map<long long,long long>m;
long long to=0;
main()
{
	int t;
	long long sm=0,c,p;
	scanf("%d%lld",&t,&p);
	for(int i = 0;i < t;i++)
	{
		scanf("%lld",&c);
		sm+=c;
		sm%=p;
		to+=m[sm];
		m[sm]++;
		if(sm==0)
		to++;
	}
	printf("%lld",to);
}

Measured memory_bytes: 4224
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  int n, t, p, q, f;
  cin >> n;
  int D[n];
  map<int, int> M;
  for (int i = 0; i < n; ++i) {
    cin >> D[i];
  }
  for (int i = 0; i < n; ++i) {
    t = 0;
    for (int j = 0; i+j < n && j < 8; ++j) {
      t *= 10;
      t += D[i+j];
      M[t] = 1;
    }
  }
  t = 0;
  while (M[t]) ++t;
  cout << t << endl;
  return 0;
}

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

int main(){
    string s;
    cin>>s;
    int i = s.find("A"),ans;
    for (i;i<s.size();i++){
        if (s.at(i)=='Z'){
            ans = i;
        }
    }
    cout<<ans-s.find("A")+1<<endl;
}

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

using namespace std;

int main(){
 long h,w,n;
   cin >> h >> w >> n;

 map<pair<long,long>,long> mp;
  for(int k=0;k<n;k++) {
    long a,b;
    cin >> a >> b;
    a--;
    b--;
    for(int i=0;i<3&&a-i>=0;i++){
      for(int j=0;j<3&&b-j>=0;j++) mp[make_pair(a-i,b-j)]++;
     
      }
  }
    
  vector<long> num(10,0);
  num[0]=(h-2)*(w-2);
  for(auto m:mp){
    if(m.first.first>=h-2||m.first.second>=w-2) continue;
   num[m.second]++;
    num[0]--;
  }
  

  for(auto v:num) cout << v << endl;
}

Measured memory_bytes: 56448
#include <stdio.h>

int main(void)
{
	int a,b;
	while (1) {
		scanf("%d %d", &a, &b);
		
		if (a == 0 && b == 0) {
			break;
		}
		if (a > b) {
			printf("%d %d\n", b, a);
		} else {
			printf("%d %d\n", a, b);
		}
	}
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N, vector<int>(N, 1e9));
  for (int a, b, c; cin >> a >> b >> c;) {
    G.at(--a).at(--b) = c;
    G.at(b).at(a) = c;
  }
  for (int i = 0; i < N; i++) {
    G.at(i).at(i) = 0;
  }
  auto G2 = G;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        G.at(j).at(k) = min(G.at(j).at(k), G.at(j).at(i) + G.at(i).at(k));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      if (G2.at(i).at(j) == 1e9) continue;
      if (G2.at(i).at(j) != G.at(i).at(j)) ans++;
    }
  }
  cout << ans / 2 << "\n";
}

Measured memory_bytes: 3700
import java.util.Scanner

object Main{
  def main (args: Array[String]) = {
    val in = new Scanner(System.in)
    val a = in.nextInt
    val b = in.nextInt

    val result = if (a < b)
      "<"
    else if (a > b)
      ">"
    else
      "=="

    println("a " + result + " b")
  }
}

Measured memory_bytes: 45124
#include <bits/stdc++.h> 
using namespace std;
int main(){
	int aim,c,l,a,ans=0;
	cin>>c>>aim;
	for(int i=0;i<c;i++){
		cin>>l;
		a=a+l;
		if(a<=aim)ans++;
	}
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include <queue>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main()
{
  int N,Y;
  cin >> N >> Y;
  int yukiti = -1, higuti = -1, noguti = -1;
    for(int i = 0; i <= N; i++){
        for (int j = 0; j <= N-i; j++){
                int k = N - i - j;
                int sum = i*10000 + j*5000 + k*1000;
                if(sum == Y && i+j+k == N){
                    yukiti = i;
                    higuti = j;
                    noguti = k;
                }
            }
        }
        cout << yukiti << " " <<  higuti << " " << noguti << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static boolean contains(int n, int []arr) {
		while(n > 0) {
			int a = n % 10;
			for(int i = 0; i < arr.length; i++) {
				if(arr[i] == a) {
					return true;
				}
			}
			n /= 10;
		}
		return false;
	}
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] arr = new int[k];
		for(int i = 0; i < k; i++) {
			arr[i] = sc.nextInt();
		}

		while(true) {
			if(contains(n, arr)) {
				n++;
			}
			else {
				break;
			}
		}
		System.out.println(n);
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


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

    V<int> dp(n + 1, 1e9);
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(1 < i) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 4064
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    if((n+1)/2>=k){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

Measured memory_bytes: 256
# educational DP contest B
n=int(input())
x=[]
for i in range(n):
    x.append(list(map(int,input().split())))
def changemax(a,b):
    if a<b:
        a=b
        return a
    return a
dp=[]
dp.append([0,0,0])
for i in range(1,n+1):
    dp.append([0,0,0])
for m in range(n):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            dp[m+1][k]=changemax(dp[m+1][k],dp[m][j]+x[m][k])
print(max(dp[n]))


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

int main() {
  ll n;
  cin>>n;
  ll ans=1e18;
  for (ll i=1; i*i<=n; i++) {
    if (n%i) continue;
    ans=min(i-1+(n/i)-1,ans);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
primes :: [Int]
primes = 2 : f [3] [3,5..]
  where
    f [] _ = []
    f (x:xs) ys =
        let (ps, qs) = span (< x^2) ys
         in ps ++ f (xs ++ ps) [z | z <- qs, z `rem` x /= 0]

main :: IO ()
main = do
    x <- readLn :: IO Int
    print . head . dropWhile (x>) $ primes

Measured memory_bytes: 2428
pub fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    s.clear();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut min = n + 1;
    let mut cnt = 0;
    for p in s.split_whitespace().map(|w| w.parse::<usize>().unwrap()) {
        if p < min {
            cnt += 1;
            min = p;
        }
    }
    println!("{}", cnt);
}

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

int main()
{
	int w, h, x, y, r;
	
	cin >> w >> h >> x >> y >> r;

	if (0 <= x-r && x+r <= w ) {
		if (0 <= y - r && y + r <= h) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
	else {
		cout << "No\n";
	}

    return 0;
}




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

struct Puzzle {
    int f[9];
    int space;
    string path = "";

    bool operator < (const Puzzle& p) const {
        for(int i = 0; i < 9; i++) {
            if(f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

const int nxt[][2] = {{-1,0},{0,-1},{1,0},{0,1} };
const char dir[] = {'u','l','d','r'};

inline bool isTarget(Puzzle p) {
    for(int i = 0; i < 9; i++) {
        if(p.f[i] != (i+1)) return false;
    }
    return true;
}

string bfs(Puzzle s) {
    queue<Puzzle> Q;
    map<Puzzle,bool> V; //K-V对表示哪个迷宫(状态)是已经搜索过的了
    Q.push(s);
    V[s] = true;

    while(!Q.empty()) {
        Puzzle u = Q.front(); Q.pop();
        if(isTarget(u)) return u.path;
        int sx = u.space / 3;
        int sy = u.space % 3; // 得到空位所在的行列
        for(int i = 0; i < 4; i++) {
            int tx = sx + nxt[i][0];
            int ty = sy + nxt[i][1]; // 空位旁边所有拼图片
            if(tx < 0 || ty < 0 || tx >= 3 || ty >= 3) continue;
            Puzzle v = u;
            swap(v.f[u.space],v.f[tx*3 + ty]);
            v.space = tx * 3 + ty;
            if(!V[v]) {
                V[v] = true;
                v.path += dir[i];
                Q.push(v);
            }
        }
    }
}

int main() {
    Puzzle in;
    for(int i =0; i < 9; i++) {
        cin >> in.f[i];
        if(in.f[i] == 0) {
            in.f[i] = 9;
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;
    return 0;
}



Measured memory_bytes: 30520
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int x,a,b;

int main()
{
    cin >> x >> a >> b;
    if(abs(x-a)<abs(x-b)){
        cout<<"A"<<endl;
    }else{
        cout<<"B"<<endl;
    }
}

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


int digitsum(int a){
    int sum=0;
    while(a!=0){
        sum += a%10;
        a = a/10;
    }
    return sum;
}

void solve(){
    int n;
    cin >> n;
    if(n%digitsum(n)==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


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

int main(){
  
  int a,b,c,d;
  
  cin >> a >> b >> c >> d;
  
  if(d == 1){
    cout << 1;  
  }
  else{
    cout << 0;
  }
  
  return 0;
}

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

using namespace std;

string str;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> str;
	if (str[0] == 'S') {
		if (str[1] == 'U')
			cout << 7;
		else
			cout << 1;
	}
	if (str[0] == 'M')
		cout << 6;
	if (str[0] == 'T' && str[1] == 'U')
		cout << 5;
	if (str[0] == 'W')
		cout << 4;
	if (str[0] == 'T' && str[1] == 'H')
		cout << 3;
	if (str[0] == 'F')
		cout << 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

unordered_map<LL,LL> colorCount;

LL tolong(LL c0,LL c1,LL c2,LL c3){
    return (c0*1000000000LL+ c1*1000000LL +c2*1000LL +c3);
}

void toc(LL num,LL &c0, LL &c1,LL &c2,LL &c3){
    c0 = num/1000000000LL;
    num %= 1000000000LL;
    c1 = num/1000000LL;
    num%= 1000000LL;
    c2 = num/1000LL;
    num%=1000LL;
    c3 = num;
}

void add(LL c0,LL c1,LL c2,LL c3){
    colorCount[tolong(c0,c1,c2,c3)]+=1;
    colorCount[tolong(c3,c0,c1,c2)]+=1;
    colorCount[tolong(c2,c3,c0,c1)]+=1;
    colorCount[tolong(c1,c2,c3,c0)]+=1;
}

void sub(LL c0,LL c1,LL c2,LL c3){
    colorCount[tolong(c0,c1,c2,c3)]-=1;
    colorCount[tolong(c3,c0,c1,c2)]-=1;
    colorCount[tolong(c2,c3,c0,c1)]-=1;
    colorCount[tolong(c1,c2,c3,c0)]-=1;
}

int main(){

    int N;cin>>N;
    LL color[N];
    REP(i,N){
        LL c0,c1,c2,c3;
        cin>>c0>>c1>>c2>>c3;
        add(c0,c1,c2,c3);
        color[i]=tolong(c0,c1,c2,c3);
    }


    LL col[4];
    LL a,b,c,d,e,f,g,h;
    LL ans = 0;
    REP(i,N){
        toc(color[i],col[0],col[1],col[2],col[3]);
        sub(col[0],col[1],col[2],col[3]);
        a = col[0],b=col[1],c=col[2],d=col[3];
        REP(j,N){
            if(i==j)continue;
            toc(color[j],col[0],col[1],col[2],col[3]);
            sub(col[0],col[1],col[2],col[3]);
            REP(k,4){
                LL T = 1;
                e = col[(k)%4],h = col[(k+1)%4],g =col[(k+2)%4],f = col[(k+3)%4];
                T *= colorCount[tolong(e,f,b,a)];
                sub(e,f,b,a);
                T *= colorCount[tolong(f,g,c,b)];
                sub(f,g,c,b);
                T*= colorCount[tolong(g,h,d,c)];
                sub(g,h,d,c);
                T *= colorCount[tolong(h,e,a,d)];
                sub(h,e,a,d);

                ans += T;
                add(e,f,b,a);
                add(f,g,c,b);
                add(g,h,d,c);
                add(h,e,a,d);
            }
            add(col[0],col[1],col[2],col[3]);
        }
        toc(color[i],col[0],col[1],col[2],col[3]);
        add(col[0],col[1],col[2],col[3]);
    }

    cout<<ans/6<<endl;



    return 0;
}

Measured memory_bytes: 239448
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    FI(); /// skip this line for compile
    string s1,s2;
    int cnt=0;
    cin >> s1 >> s2;
    for(int i=0;i<3;i++){
        if(s1[i]==s2[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

long long k;
long long a[100];
int main()
{
	scanf("%lld", &k);
	long long pp = k / 50;
	k = k % 50;
	for(int i = 1; i <= 50; i++) a[i] = 49;
	for(int i = 1; i <= 50; i++)
	{
		a[i] += pp * 50;
		for(int j = 1; j <= 50; j++)
		{
			if(j != i) a[j] -= pp;
		}
	}
	for(int i = 1; i <= k; i++)
	{
		a[i] += 50;
		for(int j = 1; j <= 50; j++)
		{
			if(j != i) a[j]--;
		}
	}
	long long MIN;
	MIN = a[1];
	for(int i = 1; i <= 50; i++)
	{
		MIN = min(MIN, a[i]);
	}
	if(MIN < 0) {
		for(int i = 1; i <= 50; i++) a[i] += abs(MIN);
	}
	printf("50\n");
	for(int i = 1; i <= 50; i++) printf("%lld ", a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main () {
    int N;
    cin >> N;
    vector<int> a;
    for (int i = 0 ; i < N; i++) {
        int num;
        cin >> num;
        a.push_back(num);
    }
    sort(a.begin(), a.end(), greater<int>());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < N; i++) {
        int num = a.front();
        a.erase(a.begin());
        if (i % 2 == 0) {
            alice += num;
        } else {
            bob += num;
        }
    }
    cout << alice - bob << endl;

}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string rightS = "CODEFESTIVAL2016";

int main() {
    //cout.precision(10);
    string in;
    cin >> in;
    int ans = 0;
    for(int i = 0; i < in.size(); i++) {
        if(in[i] != rightS[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint,random
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c = inpl()
x = 4 * a * b
y = pow(c-a-b,2)
if x<y and c-a-b>0:
    print('Yes')
else:
    print('No')


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a>b && b>=c){
    cout << c << " " << b << " " << a << endl;return 0;
  }
  if(c>b && b>=a){
    cout << a << " " << b << " " << c << endl;return 0;
  }
  if(b>c && c>=a){
    cout << a << " " << c << " " << b << endl;return 0;
  }
  if(a>c && c>=b ){
    cout << b << " " << c << " " << a << endl;return 0;
  }
  if(b>a && a>=c){
    cout << c << " " << a << " " << b << endl;return 0;
  }
  if(c>a && a>=b){
    cout << b << " " << a << " " << c << endl;return 0;
  }
}  


Measured memory_bytes: 3112
N = int(input())
x_list = list(map(int, input().split()))
hp_list = []
min_x = min(x_list)
max_x = max(x_list)

for i in range(min_x, max_x+1):
  hp_sum = 0
  for j in x_list:
    hp = (j - i) ** 2
    hp_sum += hp
  hp_list.append(hp_sum)
print(min(hp_list))

Measured memory_bytes: 3064
n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort(reverse=True)
F.sort()

def ok(x):
    tot = 0
    for i in range(n):
        tot += max(0, A[i] - x//F[i])
    if tot <= k:
        return True
    else:
        return False

l = -1
r = 10**18
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Measured memory_bytes: 120140
package main

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

func main() {
	sc := NewScanner()
	A, B, C, D, E, F := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()

	mx := -1.0
	ans1 := 0
	ans2 := 0
	for i := 0; i*100*A <= F; i++ {
		for j := 0; i*100*A+j*100*B <= F; j++ {
			water := i*100*A + j*100*B
			if water == 0 {
				continue
			}
			for k := 0; water+C*k <= F; k++ {
				for l := 0; water+C*k+l*D <= F; l++ {

					if (C*k+l*D)*100 > E*water {
						continue
					}
					v := float64(C*k+l*D) / (float64(water + C*k + l*D))
					if mx < v {
						ans1 = water
						ans2 = C*k + l*D
						mx = v
					}
				}
			}
		}
	}
	fmt.Println(ans1+ans2, ans2)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640