akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vvint b(n, vint(m + 1));
    rep(i, n) rep(j, m + 1) cin >> b[i][j];

    int ans = INT32_MAX;
    rep(i, 1 << n)
    {
        vint sk(m);
        bool poss = true;
        int now = 0;
        rep(j, n)
        {
            if (((1 << j) & i) == 0)
            {
                continue;
            }

            now += b[j][0];
            rep(k, m)
            {
                sk[k] += b[j][k + 1];
            }
        }
        rep(k, m)
        {
            if (sk[k] < x)
                poss = false;
        }
        if (poss)
        {
            ans = min(now, ans);
        }
    }

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

    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
const int MAX = 200010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  mint ans2,ans1=1,ans,ans3=1;
  long long int i,n,a,b;
  scanf("%lld %lld %lld\n",&n,&a,&b);
  ans=modpow(2,n,1000000007);
  for(i=1;i<=a;i++){
    ans1=ans1*(n-i+1)/i;
  }
  for(i=1;i<=b;i++){
    ans3=ans3*(n-i+1)/i;
  }
  ans2=ans-ans1-1-ans3;
  printf("%lld\n",ans2);
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int m = fs.nextInt();
        PriorityQueue<Integer> a = new PriorityQueue<Integer>(Collections.reverseOrder());
        for(int i=0; i<n; i++) a.add(fs.nextInt());
        for(int i=0; i<m; i++) a.add((int)a.poll()/2);
        long total = 0;
        for(int i:a) total+=i;
        System.out.println(total);
    }

}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

typedef long long ll;

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

	ll a = 0, b = 0;
	for(ll i=1; i*i<=N; i++){
		if(N%i == 0) {a = i; b=N/i; }
	}

	ll ans = (a-1) + (b-1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		int asel = Math.min(a, k);
		int bsel = Math.min(b, k-asel);
		int csel = Math.min(c, k-asel-bsel);
		
		System.out.println(asel - csel);
	}

}



Measured memory_bytes: 35684
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    string S;
    cin >> S;
    //resolve
    int cnt = 0;
    string two_char;
    map<string,int> char_cnt_map;
    for (auto c: S) {
        if (cnt%2==0) two_char = "";
        two_char+=c;
        if (cnt%2==1) char_cnt_map[two_char]++;
        cnt++;
    }
    int ans1=min(char_cnt_map["10"],char_cnt_map["01"])*2;
    ans1 += char_cnt_map["00"];
    ans1 += char_cnt_map["11"];

    cnt = 0;
    two_char;
    char_cnt_map.clear();
    for (auto c: S) {
        if (cnt==0) {
            cnt++;
            continue;
        }
        if (cnt%2==1) two_char = "";
        two_char+=c;
        if (cnt%2==0) char_cnt_map[two_char]++;
        cnt++;
    }
    int ans2=min(char_cnt_map["10"],char_cnt_map["01"])*2;
    ans2 += char_cnt_map["00"];
    ans2 += char_cnt_map["11"];    

    // output
    cout << max(ans1,ans2) << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.*

fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map{it.toInt()}
    val aa = readLine()!!.split(" ").map{it.toLong()}
    var total = aa.sum()

    val queue = PriorityQueue<Long>(n)
    queue.addAll(aa)

    val cards = mutableMapOf<Long, Long>()
    repeat(m) {
        val (b, c) = readLine()!!.split(" ").map{it.toLong()}
        cards[c] = (cards[c] ?: 0) + b
    }
    val keys = cards.keys.sortedDescending()

    for (key in keys) {
        for (i in 1..cards[key]!!) {
            if (queue.peek() < key) {
                val diff = key - queue.poll()
                total += diff
                queue.add(key)
            } else {
                break
            }
        }
    }

    println(total)
}

Measured memory_bytes: 85136
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int min = 1001;
        for(int i = 0; i < N; i++){
            int m = sc.nextInt();
            X -= m;
            min = Math.min(min, m);
        }
        System.out.println(N + X/min);
        sc.close();
    }

}


Measured memory_bytes: 22996
<?php
  $n = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));

  if ($n % 2 == 1) {
    echo 'No' . PHP_EOL;
    return;
  }

  $half = $n / 2;
  $be = substr($s, 0, $half);
  $af = substr($s, $half);
  $ans = ($be === $af) ? 'Yes' : 'No';
  echo $ans . PHP_EOL;


Measured memory_bytes: 4856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdin = new Scanner(System.in);
		String a = stdin.next();
		String b = stdin.next();
		
		if(a.charAt(0)>b.charAt(0)) {
			System.out.println(">");
		}else if(a.charAt(0)==b.charAt(0)) {
			System.out.println("=");
		} else {
			System.out.println("<");
		}
		
		


	}

}

Measured memory_bytes: 21204
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
double nn[1000006];
double sum[1000006];
int main()
{
  double n, m, d;
  cin >> n >> m >> d;
  double ans = max(0.0, n - d) * (d==0?1.0:2.0) * (m - 1);
  ans /= n * n;
  printf("%.10lf\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> lP;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int d,t,s;
    cin>>d>>t>>s;
    if((d+s-1)/s<=t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

const int MAX_N = 10000;
const int V = 10000;

vector<int> G[MAX_N];
vector<int> rG[MAX_N];
vector<int> vs; //??°?????????????????????
bool used[MAX_N]; //?????§????????????????????????
int cmp[MAX_N];	//?±????????????£????????????????????????????????????

void add_edge(int from,int to)
{
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v)
{
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
	vs.push_back(v);
}

void rdfs(int v,int k)
{
	used[v] = true;
	cmp[v] = k;
	for(int i=0;i<rG[v].size();i++){
		if(!used[rG[v][i]]){
			rdfs(rG[v][i],k);
		}
	}
}

int scc(int n)	//?????£??????????????°?????????
{
	memset(used,0,sizeof(used));
	vs.clear();
	for(int v=0;v<n;v++){
		if(!used[v]){
			dfs(v);
		}
	}
	memset(used,0,sizeof(used));
	int k=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(!used[vs[i]]){
			rdfs(vs[i],k++);
		}
	}
	return k;
}

int main()
{
	int n,m,from,to,k,l,u,v;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> from >> to;
		add_edge(from,to);
	}
	k = scc(n);	
	cin >> l;
	for(int i=0;i<l;i++){
		cin >> u >> v;
		printf("%d\n",(cmp[u] == cmp[v]));
	}
}

Measured memory_bytes: 4812
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<bits/stdc++.h>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3F3F3F3F
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int cnt;
string s;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	if(s[0]!='A'){
		cout<<"WA";
		return 0;
	}
	for(int i=2;i<=s.size()-2;i++){
		if(s[i]=='C')
		cnt++;
	}
	if(cnt!=1){
		cout<<"WA";
		return 0;
	}
	for(int i=0;i<s.size();i++){
		if(s[i]!='A' && s[i]!='C' && s[i]>='A' && s[i]<='Z'){
			cout<<"WA";
			return 0;
		}
	}
	cout<<"AC";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
<?php
    $slime_cnt = fgets(STDIN);
    $slimes = fgets(STDIN);
    # $slime = explode('', $slimes);
    $slime = str_split($slimes);

    $cnt = (int)$slime_cnt;
    for($i=0; $i<=$slime_cnt; $i++){
        if($slimes[$i] == $slimes[$i+1]){
            $cnt = $cnt -1;
        }
    }
    echo $cnt;
?>

Measured memory_bytes: 10744
s = input()
 
start0 = 0
start1 = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      start1 += 1
    elif s[i] == "1":
      start0 += 1
  elif i % 2 == 1:
    if s[i] == "0":
      start0 += 1
    elif s[i] == "1":
      start1 += 1

print(min([start0, start1]))

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin>>x;
	cout<<(x<1200?"ABC":"ARC")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
struct Node {
  int x, y, d;
};
bool operator<(const Node &lhs, const Node &rhs) {
  return lhs.d < rhs.d;
}
int hx[4] = {0, 0, 1, -1};
int hy[4] = {1, -1, 0, 0};
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> mp(h);
  for(int i = 0; i < h; i++) cin >> mp[i];
  int white = 0;
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(mp[i][j] == '.') white++;
  multiset<Node> q;
  q.insert(Node{0, 0, 1});
  bool c[h][w];
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) c[i][j] = false;
  while(q.size() > 0) {
    Node now = *q.begin();
    q.erase(q.begin());
    if(c[now.y][now.x]) continue;
    c[now.y][now.x] = true;
    if(now.y == h - 1 && now.x == w - 1) {
      cout << white - now.d << endl;
      return 0;
    }
    for(int i = 0; i < 4; i++) {
      int nx = now.x + hx[i], ny = now.y + hy[i];
      if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
      if(mp[ny][nx] =='.')
      q.insert(Node{nx, ny, now.d + 1});
    }
    
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn dfs(i: usize, edges: &Vec<Vec<usize>>, memo: &mut Vec<u64>) -> u64 {
    // println!("{}", i);
    if edges[i].len() == 0 {        
        return 0;
    }
    if memo[i] != 0 {
        return memo[i];
    }
    let mut max = 0;
    for node in &edges[i] {
        let len = dfs(*node, edges, memo) + 1;
        if len > max {
            max = len;
        }
    }
    memo[i] = max;
    return max;
}

fn main() {
    let (n, m) = input_tuple();
    let mut edges: Vec<Vec<usize>> = vec![Vec::new(); (n+1) as usize];
    let mut memo: Vec<u64> = vec![0; (n+1) as usize];
    for i in 1..(n+1) as usize {
        edges[0].push(i);
    }
    for _ in 0..m {
        let (x, y) = input_tuple();
        edges[x as usize].push(y as usize);
    }
    // println!("{:?}", edges);
    println!("{}", dfs(0, &edges, &mut memo) - 1);
}


Measured memory_bytes: 15228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    string s;
    cin >> s;
    ll cnt = 0;
    if (s.at(0) == '+') cnt++;
    if (s.at(1) == '+') cnt++;
    if (s.at(2) == '+') cnt++;
    if (s.at(3) == '+') cnt++;
    cout << cnt - (4-cnt) << endl;
}


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

using namespace std;

#define N 3

int main()
{
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A, A + N);

	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ans += A[i + 1] - A[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
S = N.times.map { gets.chomp }

counter = Hash.new(0)

S.each do |s|
  next unless %w(M A R C H).include?(s[0])
  counter[s[0]] += 1
end

ans = 0

%w(M A R C H).combination(3) do |a, b, c|
  ans += counter[a] * counter[b] * counter[c]
end

puts ans


Measured memory_bytes: 10236
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void codeforces()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int32_t main()
{
    
        int a, b, v, w, T;
        cin>>a>>v>>b>>w>>T;
        if( b == a){
            cout<<"YES";
            return 0;
        }
        // if( b + T*w <= a + T*v) cout<<"YES";
        // else cout<<"NO";
        
        // if( b <= a){
        //     cout<<"YES";
        //     return 0;
        // }
        // if( v <= w){
        //     cout<<"NO";
        //     return 0;
        // }
        // if ( (b < a) or ( b > a and w >= v) ){
        //     cout<<"NO";
        //     return 0;
        // }
        // cout<<"YES";
        if( b < a){
            if( b - T*w >= a - T*v) cout<<"YES";
            else cout<<"NO";
            return 0;
        }
          if( b + T*w <= a + T*v) cout<<"YES";
        else cout<<"NO";
        // float t = (((b-a)*1.0)/(v-w));
        // // cout<<t;
        // if( floor(t) != ceil(t)){
        //     cout<<"NO";
        //     return 0;
        // }
        // int t1 = t;
        // if( t1 <= T){
        //     cout<<"YES";
        // }
        // else{
        //     cout<<"NO";
        // }

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
  int A, B;

  cin >> A >> B;

  if((A+B)%3 == 0 || A % 3 == 0 || B % 3 == 0){
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import bisect
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

for x in X:
    p0, p1, p2, p3 = (10**12 for _ in range(4))
    si = bisect.bisect_left(S, x)
    ti = bisect.bisect_left(T, x)

    if si != 0 and ti != 0:
        p0 = max(x-S[si-1], x-T[ti-1])
    if si != 0 and ti != B:
        p1 = min(x-S[si-1], T[ti]-x)*2+max(x-S[si-1], T[ti]-x)
    if si != A and ti != 0:
        p2 = min(S[si]-x, x-T[ti-1])*2+max(S[si]-x, x-T[ti-1])
    if si != A and ti != B:
        p3 = max(S[si]-x, T[ti]-x)
    print(min(p0, p1, p2, p3))


Measured memory_bytes: 16152
$/=get.words;$_=sort -*,get.words;
say .[^$1].sum/$1;
$!=+.grep: *==.[$1-1];
(+.[^$1].grep(*==.[$1-1]),+$1..(+$2 min$!))[.[$1-1]==.[0]]>>.&{combinations($!,$_).elems}.sum.say

Measured memory_bytes: 74912
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long y = in.nextLong();

            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n - i; j++) {
                    if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
                        out.print(i + " " + j + " " + (n - i - j));
                        return;
                    }
                }
            }

            out.print("-1 -1 -1");

        }

    }
}



Measured memory_bytes: 25172
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

// MainT1P2018C
public class Main {

    private static boolean isOdd(int val) {
        return ((val & 1) != 0);
    }

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in);
             PrintWriter out = new PrintWriter(System.out))
        {
            final int N = in.nextInt();
            final long[] A = new long[N];
            for (int i = 0; i < N; ++i) {
                A[i] = in.nextInt();
            }

            final int halfN = N / 2;
            long result = 0L;
            Arrays.sort(A);
            if (isOdd(N)) {

                long r1 = 0L;
                r1 -= 2 * Arrays.stream(A, 0, halfN).sum();
                r1 += 2 * Arrays.stream(A, halfN, N).sum();
                r1 -= A[halfN];
                r1 -= A[halfN + 1];

                long r2 = 0L;
                r2 -= 2 * Arrays.stream(A, 0, halfN + 1).sum();
                r2 += 2 * Arrays.stream(A, halfN + 1, N).sum();
                r2 += A[halfN];
                r2 += A[halfN - 1];

                result = Math.max(r1, r2);

            } else {
                result -= 2 * Arrays.stream(A, 0, halfN).sum();
                result += 2 * Arrays.stream(A, halfN, N).sum();
                result -= A[halfN];
                result += A[halfN - 1];
            }
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 63332
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int dice[] = {0,1,2,3,5,4,6};
			int sum=1;
			int n=in.nextInt();
			if(n==0)
				return;
			while(n-->0)
			{
				int dice2[]=new int[7];
				String st=in.next();
				if(st.equals("North"))
				{
					dice2[4]=dice[1];
					dice2[1]=dice[2];
					dice2[3]=dice[3];
					dice2[6]=dice[4];
					dice2[5]=dice[5];
					dice2[2]=dice[6];

					dice[1]=dice2[1];
					dice[2]=dice2[2];
					dice[3]=dice2[3];
					dice[5]=dice2[5];
					dice[4]=dice2[4];
					dice[6]=dice2[6];
					sum+=dice[1];
				}
				if(st.equals("East"))
				{
					dice2[3]=dice[1];
					dice2[2]=dice[2];
					dice2[6]=dice[3];
					dice2[4]=dice[4];
					dice2[1]=dice[5];
					dice2[5]=dice[6];

					dice[1]=dice2[1];
					dice[2]=dice2[2];
					dice[3]=dice2[3];
					dice[5]=dice2[5];
					dice[4]=dice2[4];
					dice[6]=dice2[6];
					sum+=dice[1];
				}
				if(st.equals("West"))
				{
					dice2[5]=dice[1];
					dice2[2]=dice[2];
					dice2[1]=dice[3];
					dice2[4]=dice[4];
					dice2[6]=dice[5];
					dice2[3]=dice[6];

					dice[1]=dice2[1];
					dice[2]=dice2[2];
					dice[3]=dice2[3];
					dice[5]=dice2[5];
					dice[4]=dice2[4];
					dice[6]=dice2[6];
					sum+=dice[1];
				}
				if(st.equals("South"))
				{
					dice2[2]=dice[1];
					dice2[6]=dice[2];
					dice2[3]=dice[3];
					dice2[1]=dice[4];
					dice2[5]=dice[5];
					dice2[4]=dice[6];

					dice[1]=dice2[1];
					dice[2]=dice2[2];
					dice[3]=dice2[3];
					dice[5]=dice2[5];
					dice[4]=dice2[4];
					dice[6]=dice2[6];
					sum+=dice[1];
				}
				if(st.equals("Right"))
				{
					dice2[1]=dice[1];
					dice2[5]=dice[2];
					dice2[2]=dice[3];
					dice2[3]=dice[4];
					dice2[4]=dice[5];
					dice2[6]=dice[6];

					dice[1]=dice2[1];
					dice[2]=dice2[2];
					dice[3]=dice2[3];
					dice[5]=dice2[5];
					dice[4]=dice2[4];
					dice[6]=dice2[6];
					sum+=dice[1];
				}
				if(st.equals("Left"))
				{
					dice2[1]=dice[1];
					dice2[3]=dice[2];
					dice2[4]=dice[3];
					dice2[5]=dice[4];
					dice2[2]=dice[5];
					dice2[6]=dice[6];

					dice[1]=dice2[1];
					dice[2]=dice2[2];
					dice[3]=dice2[3];
					dice[5]=dice2[5];
					dice[4]=dice2[4];
					dice[6]=dice2[6];
					sum+=dice[1];
				}
			}
			System.out.println(sum);
		}
	}
}

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

int main()
{
  string ans;
  int n;
  cin >> n;
  int y = n / 100;
  int m = n % 100;
  if (1 <= m && m <= 12) {
    if (1 <= y && y <= 12) {
      ans = "AMBIGUOUS";
    } else {
      ans = "YYMM";
    }
  } else if (1 <= y && y <= 12) {
    ans = "MMYY";
  } else {
    ans = "NA";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int ans = 1000;
  for (int i = 0; i < S.length()-2; i++) {
    int substr = ((int)S[i]-(int)'0')*100 + ((int)S[i+1]-(int)'0')*10 + ((int)S[i+2]-(int)'0')*1;
    int diff = abs(substr-753);
    ans = min(ans, diff);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s[1] == 'B') s[1] = 'R';
    else s[1] = 'B';
    cout << s;
    return 0;
}


Measured memory_bytes: 3648
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int N, W;
ll w[110], v[110];

ll dp[110][100100];

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

  cin >> N >> W;
  REP(i, N) cin >> w[i] >> v[i];

  // dp[i][j] := i番目までの重さW以下となる最大価値
  dp[0][0] = 0;
  REP(i, N+1){
    REP(j, W+1){
      if(j-w[i] >= 0){
	dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
      }
      else{
	dp[i+1][j] = dp[i][j];
      }
    }
  }
  /*
  REP(i, N+1) {
    REP(j, W+1) cout << dp[i][j] << " ";
    cout << endl;
  }
  */
  cout << dp[N][W] << endl;
  
  return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

// i love camel

/// flow
struct edge {int to, cap, rev;}; // rev Index
const int _V = 200 + 2; // _N + source + sink
vector<edge> G[_V];
bool used[_V];

void addEdge(int from, int to){
	G[from].push_back((edge) {to, 1, G[to].size()});
	G[to].push_back((edge) {from, 0, G[from].size() - 1}); // rev
}

int dfs(int v, int t){
	if(v==t)return 1;
	used[v] = true;
	REP(i, G[v].size()){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			int d = dfs(e.to, t);
			if(d){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int maxFlow(int s, int t){
	int flow=0;
	while(true){
		memset(used, 0, sizeof used);
		int p = dfs(s, t);
		if(!p)return flow;
		flow += p;
	}
}

///

bool isPrime(int x){
	if(x==1)return false;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}

VI diff_odd, diff_even;
int main() {
	int n;
	cin >> n;
	int last=-1;
#define ADD(a) ((a)%2 ? diff_odd : diff_even).push_back(a)
	REP(i, n){
		int x;
		cin >> x;
		if(x!=last+1){ // not 隣接
			if(last>0)ADD(last);
			ADD(x-1);
		}
		last = x;
	}
	ADD(last);
	REP(i, diff_odd.size())addEdge(200, i);
	REP(j, diff_even.size())addEdge(j + diff_odd.size(), 201);
	REP(i, diff_odd.size()){
		REP(j, diff_even.size()){
			int o = diff_odd[i], e = diff_even[j];
			if(isPrime(abs(o-e)))addEdge(i, j + diff_odd.size());
		}
	}
	int ans, k = ans = maxFlow(200, 201);
	ans += (diff_odd.size() - k)/2*2;
	ans += (diff_even.size() - k)/2*2;
	ans += (diff_odd.size() - k) % 2 * 3;
	cout << ans << endl;
}


Measured memory_bytes: 384
s = list(input())
cnt=0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 'L':
            cnt = 1
    if i % 2 == 1:
        if s[i] == 'R':
            cnt = 1
if cnt == 1:
    print('No')
else: print('Yes')


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

const int limit = 100010;
using edge = struct {int to; LL cost;};
vector< vector<edge> > tree(limit);
vector<LL> depth(limit);

void dfs(int v, int p, LL d) {
    depth[v] = d;
    for (auto&& e : tree[v]) {
        if (e.to == p) {
            continue;
        }
        dfs(e.to, v, d + e.cost);
    }
}

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

    for (int i = 0; i < n - 1; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a--, b--;
        tree[a].push_back({b,c});
        tree[b].push_back({a,c});
    }

    int q,k;
    cin >> q >> k;
    k--;

    dfs(k, -1, 0);
    for (int i = 0; i < q; i++) {
        int x,y;
        cin >> x >> y;
        x--, y--;
        cout << depth[x] + depth[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define EPS 1e-6
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
long long const INF = 1e18 + 42;

 
int main(){
	fast;
	lli n;
	cin>>n;
	vector<lli> v(n);
	map<lli,lli> mp,m1,m2;
	for(int i=0; i<n ;i++){
	    cin>>v[i];
	    mp[v[i]]++;
	}
	lli ans=0;
	for(auto i: mp){
	    m1[i.ff]= (i.ss)*(i.ss-1)/2;
	    m2[i.ff]= (i.ss-1)*(i.ss-2)/2;
	}
	for(auto i: m1) ans+=i.ss;
	for(int i=0; i<n; i++){
	    cout<<(ans-m1[v[i]]+m2[v[i]])<<"\n";
	}
	return 0;
}


Measured memory_bytes: 26880
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
int main() 
{
 
int x,a;
cin>>x>>a;
if(x<a)
cout<<"0";
else if(x>=a)
cout<<"10";
return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

using namespace std;


int main()
{

	IOS;
   
    string a;
    string b;
    cin>>a>>b;
    int sum=0;

    
    if(b.length() <= a.length())
    {
    	cout<<"No"<<endl;
    }

     
     else if (b.length() > a.length())
     {
     	for(int i=0; i<a.length(); i++)
     	{
     		if(a[i] != b[i])
     		{
     			sum++;
     		}
     	}

     	if(sum>0)
     	{
     		cout<<"No"<<endl;
     	}

     	else
     	{
     		cout<<"Yes"<<endl;
     	}
     }


}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

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

    for (int i = 2; i < n; i += 2) {
        if (s.substr(0, (n - i) / 2) == s.substr((n - i) / 2, (n - i) / 2)) {
            ans = n - i;
            break;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
input()
a = [int(x) for x in input().split()]

lowest = a[0]
lowests = {a[0]}
diff = -1
pairs = []

for x in a[1:]:
    if lowest > x:
        lowests = {x}
        lowest = x
    elif lowest == x:
        lowests.add(x)
    elif diff == x - lowest:
        pairs += [(x, y) for y in lowests]
    elif diff < x - lowest:
        pairs = [(x, y) for y in lowests]
        diff = x - lowest

a, b = zip(*pairs)
print(min(len(set(a)), len(set(b))))


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

int main()
{
  int h, w;
  cin >> h >> w;
  
  string board[50];
  
  for (int i = 0; i < h; i++)
  {
    cin >> board[i];
  }
  
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if (board[i][j] == '#')
        continue;
      
      int num = 0;
      for (int d = 0; d < 8; d++)
      {
        const int ni = i + dy[d];
        const int nj = j + dx[d];
        
        if (ni < 0 || h <= ni)
          continue;
        if (nj < 0 || w <= nj)
          continue;
        if (board[ni][nj] == '#')
          num++;
      }
      
      board[i][j] = char(num + '0');
      
    }
  }
  
  for (int i = 0; i < h; i++)
  {
    cout << board[i] << endl;
  }
  
}

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

int main(){

    string s;
    string t;

    cin >> s >> t ;
    int n;
    n=s.size();

    if(t.substr(0,n)==s)cout << "Yes" << endl;
    else cout << "No" << endl;
   

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;

    if(n&1){
        cout<<"No";
        return 0;
    }

    string t = s.substr(0, n/2);
    s = s.substr(n/2);
    if(s==t) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
h,w,a,b = map(int, input().split(' '))
result = []
if h < b or w < a:
    print(0)
else:
    for i in range(b):
        r = [0 if x < a else 1 for x in range(w)]
        result.append(r)
    for i in range(b, h):
        r = [1 if x < a else 0 for x in range(w)]
        result.append(r)
    for i in result:
        print(''.join(map(str, i)))

Measured memory_bytes: 12916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

ll calc(ll H, ll W) {
    ll ret = 1e10;
    ll S1, S2, S3;

    ll H1 = H / 3;
    ll H2 = H - H1;

    S1 = H1 * W;
    S2 = H2 * (W / 2);
    S3 = H * W - S1 - S2;
    ret = min(ret, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));

    S2 = (H2 / 2) * W;
    S3 = H * W - S1 - S2;
    ret = min(ret, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));

    H1 = (H + 2) / 3;
    H2 = H - H1;

    S1 = H1 * W;
    S2 = H2 * (W / 2);
    S3 = H * W - S1 - S2;
    ret = min(ret, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));

    S2 = (H2 / 2) * W;
    S3 = H * W - S1 - S2;
    ret = min(ret, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));

    return ret;
}

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

    ll H, W;
    cin >> H >> W;
    ll ans = min(calc(H, W), calc(W, H));
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                if (i * j == n)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  scanf("%d",&n);
   n = n%10;
  if(n == 2||n==4 ||n == 5 || n==7 || n==9)
    printf("hon\n");

  else if(n == 0 || n == 1 || n==6 || n==8)
    	printf("pon\n");

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


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
map<P,int> mp;
vector<P> oder;

vector<int> G[100000];

int main()
{
	int n;
	cin >> n;
	for(int i = 0;i<n-1;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
		oder.emplace_back(a,b);
	}

	queue<P> Q;

	Q.emplace(0,-1);
	vector<int> color(n);
	color[0] = 1;
	int par = -1;
	while(!Q.empty())
	{
		int now = Q.front().first;
		par = Q.front().second;
		Q.pop();
		int nc = 1;

		for(auto i :G[now])
		{
			if(color[i]>0)continue;
			if(par!=-1)if(mp[P(min(now,par),max(now,par))]==nc)nc++;
			mp[P(min(now,i),max(now,i))]=nc++;
			color[i] = 1;
			Q.emplace(i,now);
		}
	}
	int mx = 0;
	for(auto p:oder) mx = max(mp[p],mx);
	cout<<mx<<endl;
	for(auto p:oder)
	{
		cout<<mp[p]<<endl;
	}
	
}


Measured memory_bytes: 15928
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int m,a,b,p[10000],i,t,ans;
    while(1){
        m=in();
        a=in();
        b=in();
        if(!m)break;
        rep(i,m)p[i]=in();
        t=0;
        for(i=b;i>=a;i--){
            if(t<p[i-1]-p[i]){
                t=p[i-1]-p[i];
                ans=i;
            }
        }
        print(ans);
    }
    return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	int n;
	cin>>n;
	int b[n-1];
	rep(i,n-1)cin>>b[i];
	int a[n];
	rep(i,n)a[i]=inf;
	a[0]=a[1]=b[0];
	for(int i=1;i<n-1;i++){
		a[i]=min(b[i],b[i-1]);
	}
	a[n-1]=b[n-2];
	int ans=0;
	rep(i,n)ans+=a[i];
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
n = int(input())
l = [int(x) for x in input().split()]
o = 0
for i in range(n - 2):
    # print('i', i)
    for j in range(i + 1, n - 1):
        # print('j',j)
        for k in range(j + 1, n):
            # print('k', k)
            if ((l[i] + l[j]) > l[k]) and ((l[i] + l[k]) > l[j]) and ((l[j] + l[k]) > l[i]) and (l[i] != l[j]) and (l[j] != l[k]) and (l[i] != l[k]):
                o += 1
                # print(i, j, k)
print(o)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 

void solve(){
	int arr[6]{1000};
	for(int i=1;i<=5;++i){
		cin >> arr[i];
		if(arr[i]==0){
			cout << i;
		}
	}
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //int t;//testcases
    //cin>>t;
    //while(t--){
		solve();
	//}
	return 0;
}


Measured memory_bytes: 3640
#!/usr/bin/env python3
from collections import deque

def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <= y+j <= gy and 0 <= x+k <= gx:
                if maze[new_y][new_x] == "." and \
                    visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])

def main():
    h, w = map(int, input().split())
    S = []
    for i in range(h):
        S.append(input())
    
    visited = [[-1]*w for j in range(h)]
    res = bfs(S, visited, 0, 0, h-1, w-1)
    if res == - 1 or res == None:
        print(-1)
    else:
        counter = 0
        for i in range(h):
            for j in range(w):
                if S[i][j] == '#':
                    counter += 1
        print(h*w-res-1-counter)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316