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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    char c; cin >> c;
    int x = c - 'a';
    if(0 <= x && x < 26) cout << 'a' << endl;
    else cout << 'A' << endl;
    
    return 0;
}


Measured memory_bytes: 3636
N = int(input())
S = sorted([int(input()) for _ in range(N)])
sumofS = sum(S)
if sumofS % 10 != 0:
    print(sumofS)
    quit()

for s in S:
    if s % 10 != 0:
        print(sumofS-s)
        quit()

print(0)

Measured memory_bytes: 2940
N, M = map(int, input().split())

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

count = 0
BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))

A.sort()
BC.sort(reverse=True, key=lambda x: x[1])

count = 0
CArr = []
for b, c in BC:
    if count >= N:
        break
    for i in range(b):
        CArr.append(c)
        count += 1
        if count >= N:
            break

for i in range(len(CArr)):
    if A[i] < CArr[i]:
        A[i] = CArr[i]

ans = sum(A)
print(ans)

Measured memory_bytes: 22508
N = int(input())
S = input()

color = []
for i in range(len(S)):
    color.append(S[i])
lst = []

for i in range(N-1,-1,-1):
    if i<=N-2:
        if color[i+1]==color[i]:
            color.pop(i+1)


print(len(color))

Measured memory_bytes: 4212
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	ll a, b, ans;
	in(a);
	in(b);

	ans = a-2 * b;
	if (ans < 0) {
		ans = 0;
	}
	outn(ans);

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    int r, g, b, n;
    int ans = 0;
    cin >> r >> g >> b >> n;
    rep(i, 3001){
        rep(j, 3001){
            int k = (n - i*r - j*g) / b;
            if(k >= 0 && (n - i*r - j*g)%b == 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
    int i=0;
    for(int j=0; j<k; j++) {
        llong s=0;
        while(s+T[i] <= P) {
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve() {
    llong left=0;
    llong right=100000 * 10000;
    llong mid;
    while(right-1>left) {
        mid = (left + right)/2;
        int v = check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    
    return right;
}

int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


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

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  int A, X;
  cin >> X >> A;
  if(X < A) cout << 0 << "\n";
  else cout << 10 << "\n";
  return 0;
}

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

#define int long long

int32_t main() {
	double a , b , x , y ;
	cin >> a >> b >> x >> y ;
	cout << fixed << setprecision(10) << (a*b)/2 <<' ';
	if(x == a/2 && y == b/2){
		cout << 1 ;
	}else{
		cout << 0 ;
	}
	return 0;
}

Measured memory_bytes: 256
//Copyright(c)2018 Mstdream
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=100010;
int siz[N],n,tot,vis[N],dep[N];
map<LL,int>f;
struct Q{
	LL v;int id;
	bool operator<(const Q&x)const{
		return v>x.v;
	}
}q[N];
vector<int>g[N];
vector<pair<int,int> >ans;
bool flag=1;
void dfs(int x){
	tot++;vis[x]=1;
	for(auto v:g[x]){
		if(vis[v])flag=0;
		else dep[v]=dep[x]+1,dfs(v);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&q[i].v);
		f[q[i].v]=i;
		q[i].id=i;
		siz[i]=1;
	}
	sort(q+1,q+n+1);
	for(int i=1;i<n;i++){
		LL d=q[i].v+2*siz[q[i].id]-n;
		int fa=f[d];
		if(!fa)cout<<"-1"<<endl,exit(0);
		siz[fa]+=siz[q[i].id];
		ans.push_back(make_pair(q[i].id,fa));
		g[fa].push_back(q[i].id);
	}
	dfs(q[n].id);
	for(int i=1;i<=n;i++)q[n].v-=dep[i];
	if(tot==n&&flag&&!q[n].v){
		for(auto x:ans){
			printf("%d %d\n",x.first,x.second);
		}
	}
	else puts("-1");
}


Measured memory_bytes: 18164
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n: usize = read();
    let mut a: Vec<i32> = Vec::with_capacity(n);
    let mut sub: Vec<bool> = Vec::with_capacity(n+1);
    let mut count: i32 =0; 
    unsafe{
	a.set_len(n);
	sub.set_len(n+1);
    }
   
    for i in 0..n+1{
	sub[i as usize] = true;
    }
    for i in 0..n{
	a[i as usize] = read();
    }
    let mut ij: usize = 1;
    while sub[ij]{
	sub[ij] = false;
	ij = a[ij-1] as usize;
	count += 1;
	if ij==2{
	    println!("{}",count);
	    return;
	}
    }
    println!("-1");
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int k, x;
    cin >> k >> x;
    FOR(i, x - k + 1, x)
        cout << i << " ";
    FOR(i, x + 1, x + k - 1)
        cout << i << " ";
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
class UnionFind:
    def __init__(self,n):
        super().__init__()
        self.par = [-1]*n
        self.rank = [0]*n
        self.tsize = [1]*n

    
    def root(self,x):
        if self.par[x] == -1:
            return x 
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x_r = self.root(x)
        y_r = self.root(y)
        
        if self.rank[x_r]>self.rank[y_r]:
            self.par[y_r] = x_r

        elif self.rank[x_r]<self.rank[y_r]:
            self.par[x_r] = y_r

        elif x_r != y_r:
            self.par[y_r] = x_r
            self.rank[x_r] += 1

        if x_r != y_r:
            size = self.tsize[x_r]+self.tsize[y_r]
            self.tsize[x_r] = size
            self.tsize[y_r] = size

    def isSame(self,x,y):
        return self.root(x) == self.root(y)

    def size(self,x):
        return self.tsize[self.root(x)]


def main():
    n,m = tuple([int(t)for t in input().split()])

    bridge = [tuple([int(t)-1 for t in input().split()])for _ in [0]*m]
    bridge = bridge[::-1]

    uf = UnionFind(n)
    ans = [n*(n-1)//2]
    for a_i,b_i in bridge:
        if not uf.isSame(a_i,b_i):
            ans.append(ans[-1]-uf.size(a_i)*uf.size(b_i))
            uf.unite(a_i,b_i)
        else:
            ans.append(ans[-1])
    ans.pop()
    for a in ans[::-1]:
        print(a)



if __name__ == "__main__":
    main()

Measured memory_bytes: 28036
#include <iostream>

using namespace std;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;

    int ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i]) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [(usize1, usize); m]
    }
    let mut ds = vec![10; n];
    for &(s, c) in &v {
        if ds[s] < 10 && ds[s] != c {
            println!("-1");
            return;
        }
        ds[s] = c;
    }
    if ds[0] == 0 && n > 1 {
        println!("-1");
        return;
    }
    if ds[0] == 10 {
        if n == 1 {
            ds[0] = 0;
        } else {
            ds[0] = 1;
        }
    }
    for i in 1..n {
        if ds[i] == 10 {
            ds[i] = 0;
        }
    }
    println!("{}", ds.iter().map(|&x| (x as u8 + '0' as u8) as char).collect::<String>());
}


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

int main() {
  int INFINITY = (1<<30);
  int H, N; cin >> H >> N;
  int A[N], B[N], C[H+1];
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  C[0] = 0; for (int h = 1; h <= H; h++) C[h] = INFINITY;
  for (int h = 0; h < H; h++) {
    if (C[h] == INFINITY) continue;
    for (int i = 0; i < N; i++) {
      int j = min(h + A[i], H);
      int p = C[h] + B[i];
      if (p < C[j]) C[j] = p;
    }
  }
  cout << C[H] << endl;
}

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

int main() {
  int x;
  cin >> x;
  int ans=pow(x,3);
  cout << ans <<endl;
  return 0;
 
}


Measured memory_bytes: 3272
$primes = [2,3]

def is_prime?(n)
	i = 0
	while $primes[i] <= Math.sqrt(n).to_i
		return false if n % $primes[i] == 0
		i += 1
	end
	return true
end

def next_prime(n)
	n += 1 if n % 2 == 0
	loop do
		return n if is_prime?(n)
		n += 2
	end
end

def make_prime(n)
	while $primes[-1] <= n
		$primes << next_prime($primes[-1]+1)
	end
end

def print_prime(n)
	if is_prime?(n)
		i = $primes.index(n)
		print $primes[i-1], " ", $primes[i+1]
	else
		i = 0
		i += 1 while $primes[i] < n
		print $primes[i-1], " ", $primes[i]
	end
	puts ""
end

while gets
	n = $_.to_i
	if n < 3 || 50000 < n
		puts "n must be in the range (3..50000)"
		next
	end
	make_prime(n) if $primes[-2] < n
	print_prime(n)
end

Measured memory_bytes: 6152
import sys

mod = 10**9 + 7
N, M = map(int,input().split())
A = []
#次が壊れている段目...k
#その段までの行き方a_kとする
#a_k = a_(k-2) + a_(k-1)
#フィボナッチ数やんけ！！
pos = 0 #現在地

fib = [1, 1]
for i in range(N-1):
    fib.append(fib[i] + fib[i+1])

ans = 1
#各ステップでは壊れている段の直後にいる
for i in range(M):
    a = int(input())
    step = a-1 - pos
    if step >= 0:
        ans = (ans * (fib[step] % mod)) % mod
        pos = a+1
    else:
        print("0")
        sys.exit()
step = N - pos
ans = (ans * (fib[step] % mod)) % mod
print(str(ans))

Measured memory_bytes: 474120
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#define MAX_N 100
#define INF 10000000

using namespace std;


int n;
string s;
int a[200000];

void solve() {
	string a = "No";
	if (s.length() >= 4) {
		if (s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I') a = "Yes";
	}
	cout << a << endl;
}

int main() {
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 256
<?php
# 文字列の入力
fscanf(STDIN, "%s", $s);
$tmp = str_split($s);
$bFlg = false;
for($i = 0;$i < count($tmp)-1;$i++){
    $j = $i+1;
    if($tmp[$i] == $tmp[$j]){
        $bFlg = true;
    }
}
# 出力
echo(($bFlg)?'Bad':'Good');
?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = pow(10, 9) + 7;

int main(){
    ll n;
    cin >> n;
    vector<int> sosu(n + 1, 0);
    ll ans = 1;
    for(int i = 2; i <= n; i++){
        bool f = true;
        for(int j = 2; j < i; j++){
            if(i%j == 0) f = false;
        }
        if(f) sosu[i] = 1;
    }

    for(int i = 2; i <= n; i++){
        if(sosu[i] == 1){
            ll c = 0, waru = i;
            while(waru <= n){
                c += n/waru;
                waru *= i;
            }
            ans *= (c + 1)%mod;
            ans %= mod;
        }
    }
    cout << ans%mod << endl;
}

Measured memory_bytes: 3620
S = input()


list_S=list(S)

if list_S[0]==list_S[1] and list_S[2]==list_S[3] and list_S[0] != list_S[2]:
    print("Yes")
elif list_S[0]==list_S[2] and list_S[1]==list_S[3] and list_S[0] != list_S[1]:
    print("Yes")
elif list_S[0]==list_S[3] and list_S[1]==list_S[2] and list_S[0] != list_S[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int H,W;

void input() {
  cin >>H >>W;
  if (H > W) swap(H, W);
  // 常に横長とする
}

int main() {
  input();

  ll res = 100000000000000;
  for (int i=0; i<H-1; i++){
    ll h = H, w = W;
    // i行目の次の所で1回目切る
    ll c1 = w * (i+1);
    h -= i+1;
    // 現在h*wのフィールドになっている
    // h, wのどちらかが偶数なら半分こ
    if (h*w % 2 == 0){
      chmin(res, abs(c1 - h*w/2));
    }else{
      ll tmp1 = (h*w-h) / 2, tmp2 = (h*w+h) / 2;
      ll tmp = max((ll)h, max(abs(c1 - tmp1), abs(c1 - tmp2)));
      chmin(res, tmp);
      tmp1 = (h*w-w) / 2, tmp2 = (h*w+w) / 2;
      tmp = max((ll)h, max(abs(c1 - tmp1), abs(c1 - tmp2)));
      chmin(res, tmp);
    }
  }
  for (int j=0; j<W-1; j++){
    ll h = H, w = W;
    // j行目の次の所で1回目切る
    ll c1 = h * (j+1);
    w -= j+1;
    // 現在h*wのフィールドになっている
    // h, wのどちらかが偶数なら半分こ
    if (h*w % 2 == 0){
      chmin(res, abs(c1 - h*w/2));
    }else{
      ll tmp1 = (h*w-h) / 2, tmp2 = (h*w+h) / 2;
      ll tmp = max((ll)h, max(abs(c1 - tmp1), abs(c1 - tmp2)));
      chmin(res, tmp);
      tmp1 = (h*w-w) / 2, tmp2 = (h*w+w) / 2;
      tmp = max((ll)h, max(abs(c1 - tmp1), abs(c1 - tmp2)));
      chmin(res, tmp);
    }
  }

  cout <<res <<endl;
}

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


int main() {
    ll n,x,ans=0;cin>>n>>x;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n-1){
       if(a[i]+a[i+1]>x){
           ans+=a[i]+a[i+1]-x;
           if(a[i]>x)  a[i+1]=0; 
           else a[i+1]=x-a[i];
       } 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define mst(x) memset(x, 0, sizeof(x))

using namespace std;

const int maxn = 1e5 + 5;
int cnt[maxn], d[maxn], fa[maxn];
int ans = 0;
vector<int> G[maxn];

void AddEdge(int u, int v){
    G[u].push_back(v);
    G[v].push_back(u);
    d[u]++;d[v]++;
}
void BuildTree(int f){
    for(int i = 0; i < G[f].size(); i++){
        int v = G[f][i];
        if(v == fa[f])continue;
        fa[v] = f;
        BuildTree(v);
    }
}
void dfs(int x){
    int son = 0;
    for(int i = 0; i < G[x].size(); i++){
        int v = G[x][i];
        if(v == fa[x])continue;
        son++;
        dfs(v);
        cnt[x] += min(1, cnt[v]);
    }
    ans += max(0, son - cnt[x] - 1);
    cnt[x] += max(0, son - cnt[x] - 1);
}

int main()
{
//    freopen("e:\\in.txt", "r", stdin);
    mst(cnt);mst(d);
    memset(fa, -1, sizeof(fa));
    int n, root = 0, Max = 0;
    cin>>n;
    for(int i = 0; i < n - 1; i++){
        int u, v;
        scanf("%d%d", &u, &v);
        AddEdge(u, v);
        if(d[u] >= Max){
            Max = d[u];
            root = u;
        }
        if(d[v] >= Max){
            Max = d[v];
            root = v;
        }
    }
    fa[root] = root;
    BuildTree(root);
    dfs(root);
    cout<<max(1, ans)<<endl;
    return 0;
}


Measured memory_bytes: 11904
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
void get_divisors(vl& d, ll n) {
    for(ll i= 1; i*i <= n; i++) {
        if (n%i == 0){
            ll m = n / i;
            if (i==m) d.push_back(m);
            else {
                d.push_back(i);
                d.push_back(m);
            }
        }
    }
}
#endif


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

    ll N; cin >> N;

    vl d;
    get_divisors(d, N);

    ll ans = 0;
    for(ll i : d) {
        ll q = N / i;
        ll m = i - 1;
        if (q < m) ans += m;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,s,e) for(int i = s; i < e; ++i)
#define rep2(i,s,e) for(int i = s; i < e; ++i)  
#define rep_1(i,s,e) for(int i = s; i >= 0; --i)
#define ll long long
#define ull unsigned long long
#define vi vector< int >
#define vvi vector< vector< int > >
#define pii pair< int,int >
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fastio cin.tie(0),cout.tie(0);ios::sync_with_stdio(0);
using namespace std;

int main(){

  fastio
  string n; 
  int k; cin >> n >> k;
  bool arr[10]; 
  memset(arr,1,sizeof(arr));
  int x;
  rep(i,k){
  	cin >> x;
  	arr[x] = false;
  }
  vector< char > valid;
  rep(i,10){
  	if(arr[i]){
      valid.pb(i + '0');
  	}
  }
  vi pos;
  rep(i,(int)n.length()){
  	if(!arr[n[i] - '0']) pos.pb(i);
  }
  int len = (int)n.length();
  string ans = "";
  if(!pos.size()){cout << n << '\n';
   return 0;
  }
  else if(pos[0] == 0){
  	auto z = upper_bound(all(valid),n[pos[0]]);
  	if(z == valid.end()){
  		if(valid[0] == '0'){
  			ans += valid[1];
  			ans += valid[0];
  			rep(i,len - 1) ans += valid[0];
  		}
  		else{
  			ans += valid[0];
  			ans += valid[0];
  			rep(i,len - 1) ans += valid[0];
  		}
  	}
  	else{
  			ans = *z + ans;
  			rep(i,len - 1) ans += valid[0];
  	}
  	cout << ans << '\n';
  }
  else{
  	//cout << pos[0] << '\n';
  	auto z = upper_bound(all(valid),n[pos[0]]);
  	if(z == valid.end()){
  		rep(i,len - pos[0]) ans += valid[0];
  		bool flag = true;
  		for(int i = pos[0] - 1; i >= 0; --i){
  			auto p = upper_bound(all(valid),n[i]);
  			if(flag && p == valid.end()){
  				ans = valid[0] + ans;
  			}
  			else if(flag && !(p == valid.end())){
  				ans = *p + ans;
  				flag = false;
  			}
  			else ans = n[i] + ans;
  		}
  		if(ans.length() == n.length()){
  			if(ans < n){
  				ans = (valid[0] == '0'?valid[1]:valid[0]) + ans;
  			}
  		}
  	}
  	else{
  		ans += *z;
  		rep(i, len - pos[0] - 1) ans += valid[0];
  		for(int i = pos[0] - 1; i >= 0; --i){
  			ans = n[i] + ans;
  		}
  	}
  	cout << ans << '\n';
  }
	return 0;
} 


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
  
int main()
{
  int a,i;
  float sum=0;
    char s[15];
    float y;
    // 入力
    scanf("%d",&a);
    for(i=0;i<a;i++){
    scanf("%f %s",&y,s);
	if(strcmp(s,"JPY")==0){
    sum+=y;
    }else{
    sum+=y*380000;
    }
    }
    // 出力
    printf("%f",sum);

  return 0;
}


Measured memory_bytes: 128
/**
 *    author:  tourist
 *    created: 28.04.2018 15:37:00       
**/
#include <bits/stdc++.h>

using namespace std;

struct seg {
  int c0;
  int c1;
  long long inv;

  inline bool operator < (const seg &other) const {
    return (long long) c1 * other.c0 < (long long) c0 * other.c1;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> v(n);
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector< multiset<seg> > a(n);
  for (int i = n - 1; i >= 0; i--) {
    seg s = {v[i] == 0, v[i] == 1, 0};
    while (!a[i].empty() && *a[i].begin() < s) {
      seg t = *a[i].begin();
      a[i].erase(a[i].begin());
      s.inv += t.inv + (long long) s.c1 * t.c0;
      s.c0 += t.c0;
      s.c1 += t.c1;
    }
    a[i].insert(s);
    if (i > 0) {
      if (a[i].size() > a[p[i]].size()) {
        swap(a[i], a[p[i]]);
      }
      for (auto &t : a[i]) {
        a[p[i]].insert(t);
      }
      a[i].clear();
    }
  }
  seg s = {0, 0, 0};
  for (auto &t : a[0]) {
    s.inv += t.inv + (long long) s.c1 * t.c0;
    s.c0 += t.c0;
    s.c1 += t.c1;
  }
  cout << s.inv << '\n';
  return 0;
}


Measured memory_bytes: 28416
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,p[200020];
bool high[200020];
pair<int,int>f[200020],mx[800080];
void upd(int k,int l,int r,int x)
{
	if(l==r)
	{
		mx[k]=f[x];
		return ;
	}
	if(p[x]<=l+r>>1)upd(k<<1,l,l+r>>1,x);
	else upd(k<<1|1,(l+r>>1)+1,r,x);
	mx[k].first=max(mx[k<<1].first,mx[k<<1|1].first);
	mx[k].second=max(mx[k<<1].second,mx[k<<1|1].second);
}
pair<int,int>query(int k,int l,int r,int ll,int rr)
{
	if(l>=ll&&r<=rr)return mx[k];
	if(rr<=l+r>>1)return query(k<<1,l,l+r>>1,ll,rr);
	if(ll>l+r>>1)return query(k<<1|1,(l+r>>1)+1,r,ll,rr);
	auto s1=query(k<<1,l,l+r>>1,ll,rr),s2=query(k<<1|1,(l+r>>1)+1,r,ll,rr);
	return make_pair(max(s1.first,s2.first),max(s1.second,s2.second));
}
bool check(int mx1,int mx2,int cnt1,int cnt2,int cnt)
{
	auto s1=mx2==n?make_pair(0,0):query(1,1,n,mx2+1,n),s2=mx1==n?make_pair(0,0):query(1,1,n,mx1+1,n);
//	printf("%d %d %d %d %d %d %d %d %d\n",cnt1,cnt2,cnt,s1.first,s1.second,s2.first,s2.second,cnt+cnt1-cnt2,cnt+cnt2-cnt1);
	if((cnt+cnt1-cnt2)&1)return cnt+cnt1-cnt2>=0&&cnt+cnt1-cnt2<=s1.first||cnt+cnt2-cnt1>=0&&cnt+cnt2-cnt1<=s2.first;
	else return cnt+cnt1-cnt2>=0&&cnt+cnt1-cnt2<=s1.second||cnt+cnt2-cnt1>=0&&cnt+cnt2-cnt1<=s2.second;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&p[i]);
	int cur=0,cnt=0;
	for(int i=1;i<=n;++i)
		if(p[i]>cur)cur=p[i],high[i]=1,++cnt;
	for(int i=n;i;--i)
	{
		if(p[i]<n)f[i]=query(1,1,n,p[i]+1,n);
		if(high[i])f[i].first+=2,f[i].second+=2;
		else swap(f[i].first,f[i].second),++f[i].first,++f[i].second;
		if(!(f[i].first&1))f[i].first=0;
		if(f[i].second&1)f[i].second=0;
		upd(1,1,n,i);
	//	printf("%d %d\n",f[i].first,f[i].second);
	}
	if(!check(0,0,0,0,cnt)){printf("-1");return 0;}
	int mx1=0,mx2=0,cnt1=0,cnt2=0;
	for(int i=1;i<=n;++i)
	{
		cnt-=high[i];
		f[i]=make_pair(0,0);
		upd(1,1,n,i);
		if(check(max(mx1,p[i]),mx2,cnt1+(p[i]>mx1),cnt2,cnt))cnt1+=(p[i]>mx1),mx1=max(mx1,p[i]),putchar('0');
		else cnt2+=(p[i]>mx2),mx2=max(mx2,p[i]),putchar('1');
	//	printf("%d %d %d %d\n",mx1,mx2,cnt1,cnt2);
	}
	return 0;
}


Measured memory_bytes: 9216
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc156
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc156A();
        }

        public static void solve_abc156B()
        {
        }

        public static void solve_abc156A()
        {
            int[] nr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            if (nr[0] < 10)
            {
                Console.WriteLine(nr[1] + (100 * (10 - nr[0])));
            }
            else
            {
                Console.WriteLine(nr[1]);
            }

        }
    }
}


Measured memory_bytes: 11220
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+eps)



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

  string s;
  cin >> s;
  if( (s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]) || (s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]) || (s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]) ){
    cout << "Yes" << endl; return 0;
  } else{
    cout << "No" << endl; return 0;
  }


//  vint s(n);
//  REP(i, n) scan(s[i]);


//  cout <<  << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int, int> mp;
    rep(i,n) mp[a[i]]++;
    priority_queue<int, vector<int>, greater<int>> pq;
    for(auto m = mp.begin(); m != mp.end(); m++){
        pq.push(m->second);
    }

    int ans = 0;
    rep(i,mp.size()-k){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int m, f, r;
    while (true) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        if (m == -1 || f == -1) {
            cout << 'F' << endl;
        }
        else if (m + f >= 80) cout << 'A' << endl;
        else if (m + f < 80 && m + f >= 65) cout << 'B' << endl;
        else if (m + f < 65 && m + f >= 50) cout << 'C' << endl;
        else if (m + f < 50 && m + f >= 30) {
            if (r >= 50) cout << 'C' << endl;
            else cout << 'D' << endl;
        }
        else cout << 'F' << endl;
    }
}


Measured memory_bytes: 3068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var xy = new (int x, int y)[N+1];

            for (int i=1;i<N+1;i++)
            {
                var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

                xy[i] = (line[0], line[1]);
            }

            var permutation = GetPermutation(Enumerable.Range(1, N));

            double sum = 0;

            foreach (var p in permutation)
            {
                for(int i = 0; i < p.Length-1; i++)
                {
                    var a = (Math.Sqrt(Math.Pow(xy[p[i]].x - xy[p[i + 1]].x, 2) + Math.Pow(xy[p[i]].y - xy[p[i + 1]].y, 2)));
                    //Console.WriteLine(a);
                    sum += a;
                }
            }

            Console.WriteLine(sum / (double)permutation.ToArray().Length);
        }

        public static IEnumerable<T[]> GetPermutation<T>(IEnumerable<T> collection)
        {
            // 未確定要素が一個のみ
            if (collection.Count() == 1)
            {
                yield return new T[] { collection.First() };
            }

            foreach (var item in collection)
            {
                var selected = new T[] { item };
                var unused = collection.Except(selected);

                // 確定した要素以外の組み合わせを再帰で取り出し連結
                foreach (var rightside in GetPermutation(unused))
                {
                    yield return selected.Concat(rightside).ToArray();
                }
            }
        }
    }
}

Measured memory_bytes: 50220
#include<iostream>
#include<string.h>
#include<string>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  while(1){
    int ni,mi;
    int i,j,k;
    cin>>ni>>mi;
    if(ni==0 && mi==0)break;
    int r,q;
    int record[1005][800]={};//n,t
    cin>>r;
    int t,n,m,s;
    rep(i,r){
      cin>>t>>n>>m>>s;
      if(s)
	record[n][t-500]+=m;
      else
	record[n][t-500]-=m;
    }
    rep(i,ni+1)rep(j,790)
      record[i][j+1]+=record[i][j];
 
    cin>>q;
    rep(i,q){
      int ts,te,tm;
      cin>>ts>>te>>tm;
      int ans=0;
      for(j=ts;j<te;j++){
	bool temp=false;
	rep(k,ni+1)
	  if(record[k][j-500]==tm)temp=true;
	if(temp)ans++;
      }
      cout<<ans<<endl;
    }

  }
}

Measured memory_bytes: 6140
n;s;e;w;i;main(){
    char t[1000];
    gets(t);
    
    for(;i<strlen(t);i++){
        if(t[i]=='N'){
            n=1;
        }else if(t[i]=='S'){
            s=1;
        }else if(t[i]=='E'){
            e=1;
        }else if(t[i]=='W'){
            w=1;
        }
    }
    
    if((n-s)==0 && (w-e)==0){
        printf("Yes");   
    }else{
    
        printf("No"); 
    }
    
    
}

Measured memory_bytes: 1640
// ALDS1_6_C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include<iostream>
using namespace std;
#define MAX 100000
//SENTINELは常にどのカードよりも大きいものにする（今回は上限1000000000の二倍に設定）
#define SENTINEL 2000000000


struct Card {
	char suit;
	int value;
};

//配列を右側と左側にわけて保持するための配列を作る
//MergeSortは入力データ以外にも一時的なメモリを必要とする
//SENTINELの分も入れて少し大きめに
struct Card L [MAX / 2 + 2], R [MAX / 2 + 2];

void merge(struct Card Input[], int left, int mid, int right) {
	// Card[left],…,Card[mid],…,Card[right]
	int i, j, k;
	int size_l = mid - left;
	int size_r = right - mid;
	for (i = 0; i < size_l; i++) L[i] = Input[left + i];
	for (i = 0; i < size_r; i++) R[i] = Input[mid + i];
	L[size_l].value = R[size_r].value = SENTINEL;
	i = j = 0;
	for (k = left; k < right; k++) {
		//L[i]とR[j]を比較してソート
		if (L[i].value <= R[j].value)Input[k] = L[i++];
		else Input[k] = R[j++];
	}

}

void mergeSort(struct Card Input[],int left,int right)
{
	int mid;
	if (left + 1 < right) {
		//leftとrightの差が2以上で処理するつまり要素数が一以下なら処理しない
		mid = (left + right) / 2;
		//mid = 3
		mergeSort(Input, left, mid);//左
		mergeSort(Input, mid, right);//右
		merge(Input, left, mid, right);
	}
}

int partition(struct Card Input[],int left,int right){
	int i, j;
	struct Card kari, index;
	index = Input[right];
	i = left - 1;
	for (j = left; j < right; j++) {
		if (Input[j].value <= index.value) {
			//インデックスの値以下ならインデックスより左に要素を移動する
			i++;
			kari = Input[i]; Input[i] = Input[j]; Input[j] = kari;
		}
	}
	kari = Input[i + 1]; Input[i + 1] = Input[right]; Input[right] = kari;
	return i + 1;
}

void quickSort(struct Card Input[], int left, int right) {
	int index;
	if (left < right) {
		//インデックス以上と以下でソート
		index = partition(Input, left, right);
		//インデックスより前、後をソート
		quickSort(Input, left, index - 1);
		quickSort(Input, index + 1, right);
	}
}

int main()
{
	int num, i, value;
	struct Card Merge_deck[MAX], Quick_deck[MAX];
	char S[10];
	int stable = 1;

	//データ入力ココから
	cin >> num;
	for (i = 0; i < num; i++) {
		cin >> S >> value;
		Merge_deck[i].suit = Quick_deck[i].suit = S[0];
		Merge_deck[i].value = Quick_deck[i].value = value;
	}
	//データ入力ココまで

	mergeSort(Merge_deck, 0, num);
	quickSort(Quick_deck, 0, num - 1);

	for (i = 0; i < num; i++) if (Merge_deck[i].suit != Quick_deck[i].suit) stable = 0;
	//マージソートは常にStableなのでもし一つでもマージソートとクイックソートで異なるカードがあればNot Stable

	//出力ココから
	if (stable == 1)cout << "Stable\n";
	else cout<< "Not stable\n";
	for (i = 0; i < num; i++) {
		cout << Quick_deck[i].suit << " "<< Quick_deck[i].value << "\n";
	}
	//出力ココまで
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します



Measured memory_bytes: 5340
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: SpeedForces #2

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,t;
	cin >> n >> t;	
	int ans = 2e9;
	rep(i,0,n) {
		int u,v;
		cin >> u >> v;
		if (v <= t) {
			ans = min(ans, u);
		}
		
	}
	
	if (ans == 2e9) cout << "TLE";
	else cout << ans;
	
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  vector<Int> v;
  for(Int i=0;i<n;i++){
    v.emplace_back(1);
    while(i+1<n&&a[i]!=a[i+1]) i++,v.back()++;
  }
  
  if(v.size()<=3u){
    cout<<n<<endl;
    return 0;
  }
  
  Int ans=0;
  for(Int i=0;i+2<(Int)v.size();i++)
    chmax(ans,v[i]+v[i+1]+v[i+2]);
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4284
n=int(input())
l=list(map(int,input().split()))
c=0
while True:
  l1=[]
  for item in l:
    if item%2==0:
      l1.append(item/2)
  if len(l1)==n:
    l=l1
    c+=1
  else:
    break
print(c)

Measured memory_bytes: 2940
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    k, s = list(map(int, readline().split()))
    cnt = 0
    for x in range(k + 1):
        for y in range(k + 1):
            ts = s - x - y
            if 0 <= ts <= k:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 41308
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll H, W;
  cin >> H >> W;
  ll stage[W + 1][H + 1];
  ll odd = 0;
  ll even = 0;
  if (H == 1 || W == 1)
  {
    cout << 1 << endl;
    return 0;
  }
  if (W % 2 == 0)
  {
    odd = W / 2;
    even = W / 2;
  }
  else
  {
    odd = (W + 1) / 2;
    even = W / 2;
  }
  if (H % 2 == 0)
  {
    cout << (odd + even) * (H / 2) << endl;
    return 0;
  }
  else
  {
    cout << (odd + even) * ((H - 1) / 2) + odd << endl;
    return 0;
  }
}


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

int a, b, c;

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


if __name__ == '__main__':

    n = int(input())
    M = [[float("inf") for j in range(n)] for i in range(n)]

    for i in range(n):
        l = list(map(int, input().split(" ")))
        for k in range(l[1]):
            j = l[2 + 2 * k]
            c = l[2 + 2 * k + 1]
            M[i][j] = c

    d = [float("inf")] * n

    def dijkstra(s):
        color = [0] * n
        p = [None] * n
        d[s] = 0
        p[s] = -1

        while True:
            mincost = float("inf")
            for i in range(n):
                if color[i] != 2 and d[i] < mincost:
                    mincost = d[i]
                    u = i

            if mincost == float("inf"):
                break

            color[u] = 2

            for v in range(n):
                if color[v] != 2:
                    if d[u] + M[u][v] < d[v]:
                        d[v] = d[u] + M[u][v]
                        p[v] = u
                        color[v] = 1

    dijkstra(0)
    for i in range(n):
        print(i, d[i])



Measured memory_bytes: 5996
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a,b,c,i,j,k[1000][1000]={0},x,y,d1[5]={0,0,-1,1},d2[5]={1,-1,0,0},ans=999999999,qx[64000009],qy[64000009],l,r,vi[800][800];
void bfs(int x,int y){
	l=r=1;
	qx[1]=x;
	qy[1]=y;
	while(l<=r){
		if(k[qx[l]][qy[l]]!=c){
		    for(int i=0;i<4;i++){
		    	if(k[qx[l]][qy[l]]+1<k[qx[l]+d1[i]][qy[l]+d2[i]]){
		         	k[qx[l]+d1[i]][qy[l]+d2[i]]=k[qx[l]][qy[l]]+1;
		         	if(vi[qx[l]+d1[i]][qy[l]+d2[i]]==0){
		         		vi[qx[l]+d1[i]][qy[l]+d2[i]]==1;
		         		r++;
		         		qx[r]=qx[l]+d1[i];
		         		qy[r]=qy[l]+d2[i];
		         	}
		    	}
		    }
		}
		l++;
	}
}



/*void dfs(int x,int y){
	if(k[x][y]==c){
		return ;
	} 
	for(int i=0;i<=3;i++){	
	    if(k[x+d1[i]][y+d2[i]]>k[x][y]+1){
		    k[x+d1[i]][y+d2[i]]=k[x][y]+1;
		    dfs(x+d1[i],y+d2[i]);
    	}
    }
}*/
int main(){
	cin>>a>>b>>c;
	for(i=1;i<=a;i++){
		for(j=1;j<=b;j++){
			char ch;
			cin>>ch;
			if(ch=='.'){
				k[i][j]=999999;
			}else if(ch=='#'){
			    k[i][j]=-1;
			}else{
				x=i;
				y=j;
				k[i][j]=0;
				if(x==1||y==1||x==a||y==b){
					cout<<0;
					return 0;
				}
			}
		}
	} 
	bfs(x,y);
	
	for(i=1;i<=a;i++){
		for(j=1;j<=b;j++){
		//	cout<<k[i][j]<<' ';
			if(k[i][j]!=-1 &&k[i][j]!=999999){
				int v=min(min(i-1,j-1),min(a-i,b-j));
		     //
			// 	cout<<v<<endl;
				v=ceil(1.0*v/c)+1;
			//	cout<<ceil(1.0*v/c)<<endl;
				ans=min(ans,v);
			}
		}
	//	cout<<endl;
	}
	cout<<ans<<endl;
}

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

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

    int pt = 0, px = 0, py = 0;
    bool f = true;

    for (int i = 0; i < n; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        int d = abs(x - px) + abs(y - py);
        if (d % 2 != abs(t - pt) % 2 || t < d) {
            f = false;
        }
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string a,b,c; cin>>a>>b>>c;
    if(a.back()==b[0] && b.back()==c[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3604
n=int(input())
arr=[int(input()) for _ in range(n)]
cnt=0
flag=0
for i in range(n):
  if arr[i]==1:
    cnt+=1
  else:
    if arr[i]%2==1:
      flag=1
if cnt==0:
  if flag==0:
    print('second')
  else:
    print('first')
else:
  print('first')

Measured memory_bytes: 7072