akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

// z 以下にできる
fn check(z: u64, k: usize, xs: &Vec<u64>) -> bool {
    if z == 0 {
        return false;
    }
    let mut cost = 0;
    for &x in xs.iter() {
        if x <= z {
            continue;
        }
        cost += ((x + z - 1) / z) as usize - 1;
    }
    cost <= k
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let xs: Vec<u64> = sc.vec(n);
    let mut left = 0; // cannot
    let mut right = 1_000_000_002; // can do
    for _ in 0..30 {
        let mid = (left + right) / 2;
        // trace!("checK", mid, k, &xs, check(mid, k, &xs));
        if check(mid, k, &xs) {
            right = mid;
        } else {
            left = mid;
        }
    }
    put!(right);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 14812
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

vector<ll> fac;

void fact(ll n) {
    for (ll x = 1; x * x <= n; x++) {
        if (n % x == 0) {
            fac.push_back(x);

            if (n / x != x)
                fac.push_back(n/x);
        }
    }
    sort(fac.begin(), fac.end(), greater<ll>());
}

int main() {
    ll n, ans = 0;   cin >> n;
    fact(n);

    for (int i = 0; i < n; i++) {
        ll m = fac[i] - 1;
        if (m == 0)
            continue;
        if (n / m == n % m)
            ans += m;
        else 
            break;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int n;
	bool flag = true;

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

		if (i > 0) {
			if (v[i][0] != v[i-1][v[i-1].length()-1]) {
				flag = false;
				break;
			}
		}

		for (int j = 0; j < i; ++j)
		{
			if (v[j] == v[i]) {
				flag = false;
				break;
			}
		}

		if (!flag)
			break;
	}

	if (flag) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main() {
	string mark = "SHCD";
	int card[4][13];
	for(int i=0;i<4;i++) 
		for(int j=0;j<13;j++)
	    	card[i][j] = 0;
	
	int n;
	cin >> n;
	char c;
	int  x;
	for(int i = 0; i < n; i++) {
		cin >> c >> x;
		card[mark.find(c)][x-1] = 1;
	}

	for(int i=0;i<4;i++) 
		for(int j=0;j<13;j++) {
			if (card[i][j] == 0 ) {
				cout << mark[i] << " " << j+1 << endl;
			}
		}
	return 0;
}




Measured memory_bytes: 3184
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
char g[20][21];
int d[21][21];
int bfs[20][20];
pair<int,int>p[20];
int perm[10];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a+b){
		int sb=0;
		int sa=0;
		for(int i=0;i<b;i++)scanf("%s",g[i]);
		int now=0;
		for(int i=0;i<b;i++){
			for(int j=0;j<a;j++){
				if(g[i][j]=='o'){
					sb=i;
					sa=j;
				}else if(g[i][j]=='*'){
					p[now++]=make_pair(i,j);
				}
			}
		}
		for(int i=0;i<b;i++)
			for(int j=0;j<a;j++){
				if(g[i][j]=='x')bfs[i][j]=-2;
				else bfs[i][j]=-1;
			}
		queue<pair<int,int> >Q;
		Q.push(make_pair(sb,sa));
		bfs[sb][sa]=0;
		while(Q.size()){
			int nowb=Q.front().first;
			int nowa=Q.front().second;
			Q.pop();
			if(nowb&&bfs[nowb-1][nowa]==-1){
				bfs[nowb-1][nowa]=bfs[nowb][nowa]+1;
				Q.push(make_pair(nowb-1,nowa));
			}
			if(nowa&&bfs[nowb][nowa-1]==-1){
				bfs[nowb][nowa-1]=bfs[nowb][nowa]+1;
				Q.push(make_pair(nowb,nowa-1));
			}
			if(nowb<b-1&&bfs[nowb+1][nowa]==-1){
				bfs[nowb+1][nowa]=bfs[nowb][nowa]+1;
				Q.push(make_pair(nowb+1,nowa));
			}
			if(nowa<a-1&&bfs[nowb][nowa+1]==-1){
				bfs[nowb][nowa+1]=bfs[nowb][nowa]+1;
				Q.push(make_pair(nowb,nowa+1));
			}
		}
		for(int i=1;i<=now;i++){
			d[0][i]=bfs[p[i-1].first][p[i-1].second];
			if(d[0][i]==-1)d[0][i]=99999999;
		}
		for(int k=0;k<now;k++){
			for(int i=0;i<b;i++)
				for(int j=0;j<a;j++){
					if(g[i][j]=='x')bfs[i][j]=-2;
					else bfs[i][j]=-1;
				}
			queue<pair<int,int> >Q;
			Q.push(make_pair(p[k].first,p[k].second));
			bfs[p[k].first][p[k].second]=0;
			while(Q.size()){
				int nowb=Q.front().first;
				int nowa=Q.front().second;
				Q.pop();
				if(nowb&&bfs[nowb-1][nowa]==-1){
					bfs[nowb-1][nowa]=bfs[nowb][nowa]+1;
					Q.push(make_pair(nowb-1,nowa));
				}
				if(nowa&&bfs[nowb][nowa-1]==-1){
					bfs[nowb][nowa-1]=bfs[nowb][nowa]+1;
					Q.push(make_pair(nowb,nowa-1));
				}
				if(nowb<b-1&&bfs[nowb+1][nowa]==-1){
					bfs[nowb+1][nowa]=bfs[nowb][nowa]+1;
					Q.push(make_pair(nowb+1,nowa));
				}
				if(nowa<a-1&&bfs[nowb][nowa+1]==-1){
					bfs[nowb][nowa+1]=bfs[nowb][nowa]+1;
					Q.push(make_pair(nowb,nowa+1));
				}
			}
			for(int i=1;i<=now;i++){
				d[k+1][i]=bfs[p[i-1].first][p[i-1].second];
				if(d[k+1][i]==-1)d[k+1][i]=99999999;
			}
		}
		for(int i=0;i<now;i++){
			perm[i]=i+1;
		}
		int ret=99999999;
		do{
			int val=d[0][perm[0]];
			for(int i=1;i<now;i++)val+=d[perm[i-1]][perm[i]];
			ret=min(ret,val);
		}while(next_permutation(perm,perm+now));
		if(ret==99999999)printf("-1\n");
		else printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
{$mode objfpc}
        {$coperators on}
program Lexicographical_disorder________________________CODE_FESTIVAL_2016_qual_B____________________________________________________________;
const
        fi = 'lex.inp';
        fo = 'lex.out';
        sz=round(1e5)+100;
type
    Tnode = ^node;
    node  =
        record
            c:array['_'..'z'] of Tnode;
            cnt:longint;
        end;
var
    n,q,kth:longint;
    a:array[1..sz]of ansistring;
    s:string;
    nod,root:Tnode;
    count:array[0..sz,'_'..'z','_'..'z']of longint;


function min(const x,y:longint):longint; begin if x<=y then exit(x) else exit(y); end;
function max(const x,y:longint):longint; begin if x>=y then exit(x) else exit(y); end;
procedure spaw(var nod:Tnode);
var i:char;
    begin
        new(nod);
        nod^.cnt:=0;
        for i:='_' to 'z' do nod^.c[i]:=nil;
    end;

procedure enter;
var i : integer;
    begin
        readln(n);
        for i:=1 to n do
            begin
                readln(a[i]);
                a[i]:=a[i]+'_';
            end;
        readln(q);
    end;
procedure update(const a:ansistring);
var ch,rr:char;
    i:longint;
    begin
        nod:=root;
        for i:=1 to length(a) do
            begin
                ch:=a[i];
                if nod^.c[ch]=nil then spaw(nod^.c[ch]);
                nod := nod^.c[ch];
                inc(nod^.cnt);
            end;
    end;
procedure updateElement(p:longint);
var i:longint;
    ch,rr:char;
    begin
        nod:=root;
        for i:=1 to length(a[p]) do
            begin
                ch:=a[p][i];
                for rr:='_' to 'z' do if (rr<>ch)and(nod^.c[rr]<>nil) then
                    count[p][ch][rr] += nod^.c[rr]^.cnt;
                nod:=nod^.c[ch];
            end;
    end;
procedure Build();
var i:longint;
    begin
        spaw(root);
        for i:=1 to n do
            begin
                update(a[i]);
            end;
        for i:=1 to n do
            begin
                updateElement(i);
            end;
    end;
procedure doQuerry;
var i,j:longint;
    ans:longint;
    begin
        ans:=0;
        for i:=1 to 26 do
            for j:=1 to i-1 do ans += count[kth,s[i],s[j]];
        for i:=1 to 26 do ans += count[kth,s[i],'_'];
        ans+=1;
        writeln(ans);
    end;
procedure solve;
var i: integer;
    begin
        Build();
        for i:=1 to q do
            begin
                read(kth);
                readln(s); delete(s,1,1);
                doQuerry;
            end;
    end;
procedure print();
var i:longint;
    begin
    end;
begin
        enter(); solve(); print();
end.


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)



int main(void){

	int X, Y; cin >> X >> Y;
	cout << X + Y / 2 << endl;


	return 0;

}


Measured memory_bytes: 256
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE LambdaCase #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8

import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve = \case
  [0,_,_,_,_] -> 1
  [_,0,_,_,_] -> 2
  [_,_,0,_,_] -> 3
  [_,_,_,0,_] -> 4
  [_,_,_,_,0] -> 5

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n;
    cin>>n;
    lli x,y;
    lli a=0,b=0;
    for (int i=1;i<=n;i++)
    {
        a+=i*(n-i+1);
    }
    for(int i=0;i<n-1;i++)
    {
        cin>>x>>y;
        if (x>y) swap(x,y);
        b+=x*(n-y+1);
    }
    cout<<a-b;
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String sb = str;
        String sNum1 = sb.substring(0, 2);
        String sNum2 = sb.substring(2);
        int num1 = Integer.parseInt(sNum1);
        int num2 = Integer.parseInt(sNum2);

        //System.out.println(num1 + ":" + num2);

        if (0 < num1 && 0 < num2 && num1 <= 12 && num2 <= 12) {
            System.out.println("AMBIGUOUS");
        } else if (0 < num1 && num1 <= 12) {
            System.out.println("MMYY");
        } else if (0 < num2 && num2 <= 12) {
            System.out.println("YYMM");
        } else {
            System.out.println("NA");
        }
        
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){  
    long long int n;
    cin >> n;
    if(n % 2 == 0 || n % 5 == 0){
    	cout << -1;
    }
    else{
    	long long int ans = 1, number = 7;
    	while(1){
    		if(number % n == 0){
    			cout << ans;
    			return 0;
    		}
    		ans++;
    		number = (number * 10 + 7) % n;
    	}
    }
}

Measured memory_bytes: 3632
#include <stdio.h>

int binarySearch(int A[], int n, int x) {
    int left = 0, right = n, mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (x == A[mid]) {
            return mid;
        } else if (x > A[mid]) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return -1;
}

int main() {
    int S[100010], n, q, x, cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &x);
        if (binarySearch(S, n, x) != -1) {
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2956
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    size_t H;
    scanf("%zu", &H);

    vector<int> A(H+1);
    for (size_t i=1; i<=H; ++i)
        scanf("%d", &A[i]);

    for (size_t i=1; i<=H; ++i) {
        printf("node %zd: ", i);
        printf("key = %d, ", A[i]);
        if (i>>1)
            printf("parent key = %d, ", A[i>>1]);

        if ((i<<1) <= H)
            printf("left key = %d, ", A[i<<1]);

        if ((i<<1|1) <= H)
            printf("right key = %d, ", A[i<<1|1]);

        printf("\n");
    }

    return 0;
}

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

int main() {
    ll a,b,k;
    cin>>a>>b>>k;
    ll tak=a,aok=b;
    for (int i = 0; i < k; ++i)
    {
        if(i&1) {
            if(aok&1) aok--;
            ll tot=aok/2;
            aok-=tot;
            tak+=tot;
        } else {
            if(tak&1) tak--;
            ll tot=tak/2;
            tak-=tot;
            aok+=tot;
        }
    }
    cout<<tak<<" "<<aok;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int x, y;

  cin >> x >> y;

  cout << x + y / 2 << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k,mod=1e9+7,tmp;cin>>n>>k;
  vector<ll> a(n),b(n),c(n);rep(i,n) cin>>a[i];
  for(ll i=0;i<n;++i) {
    tmp=a[i];
    for(ll j=i+1;j<n;++j) {if(tmp>a[j]) b[i]++;}
    for(ll j=i-1;j>=0;--j) {if(tmp>a[j]) c[i]++;}
  }
  ll bs=accumulate(b.begin(),b.end(),0),cs=accumulate(c.begin(),c.end(),0);
  ll kk=(k*(k+1)/2)%mod,kk1=(k*(k-1)/2)%mod;
  ll ans=(bs*kk)%mod+(cs*kk1)%mod;
  print(ans%mod);
  return 0;
}

Measured memory_bytes: 256
object Main extends App {	
  val s = readLine.split("").toList.tail
  val t = readLine.split("").toList.tail
  
  def reverse(list: List[String]): String = list match {
  	case _ if list == t => "Yes"
    case l if list != s => reverse(l.last :: l.init)
    case _  => "No"
  }
  println(if(s == t) "Yes" else reverse(s.last :: s.init))
}

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

int main(void){
    int A,B;
    cin >> A >> B;
    int c[0];
    
    int counter = 0;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                c[0] = i,c[4] = i;
                c[1] = j,c[3] = j;
                c[2] = k;
                int total_c;
                total_c = 10000*c[0] + 1000*c[1] + 100*c[2] + 10*c[3] + c[4];
                if(total_c >= A && total_c <= B){
                    counter++;
                }
            }
        }
    }
    
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3156
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

N, W, H = map(int, raw_input().split())

E = [[] for i in range(N)]
lst = []
flag = True

for i in range(N):
    x, y = map(int, raw_input().split())
    if x == 1 or y == 1 or x == W or y == H:
        flag = False
    lst.append((x, y, i))

lst.sort()
for i in range(N):
    if lst[i][0] == lst[i - 1][0]:
        E[lst[i][2]].append(lst[i - 1][2])
        E[lst[i - 1][2]].append(lst[i][2])

lst2 = []

for i in range(N):
    x, y, index = lst[i]
    lst2.append((y, x, index))

lst = lst2
lst.sort()
for i in range(N):
    if lst[i][0] == lst[i - 1][0]:
        E[lst[i][2]].append(lst[i - 1][2])
        E[lst[i - 1][2]].append(lst[i][2])

used = [False for i in range(N)]

def func(num, pre):
    if used[num]:
        return
    used[num] = True
    for to in E[num]:
        if to != pre:
            func(to, num)

#print E

cnt = 0

for i in range(N):
    if not used[i]:
        func(i, -1)
        cnt += 1

if cnt > 1 and flag:
    cnt += 1
print N - 2 + cnt


Measured memory_bytes: 20496
while True:
    h,w = [int(x) for x in input().split()]
    if h == 0 and w ==0:
        break
    
    T = [  [0] * w  for x in range(h) ]
    M = []
    for _ in range(h):
        M.append(list(input()))
        
    i=0 
    j=0
    loop = 0
    while True:
        if T[i][j] > 0:
            loop += 1
            break
        else:
            T[i][j] += 1
        
        if M[i][j] ==".":
            break
        elif M[i][j] == ">":
            j += 1
        elif M[i][j] == "<":
            j -= 1
        elif M[i][j] == "^":
            i -= 1
        else:
            i += 1
    
    if loop > 0:
        print("LOOP")
    else:
        print(j,i)
    
        
    
        


Measured memory_bytes: 5852
import collections

N = int(input())

even = collections.defaultdict(lambda: 0)
odd = collections.defaultdict(lambda: 0)

for i, a in enumerate(map(int, input().split())):
    if i % 2 == 0:
        even[a] += 1
    else:
        odd[a] += 1

if len(even.keys()) == 1 and len(odd.keys()) == 1 and list(even.keys())[0] == list(odd.keys())[0]:
    print(N // 2)
else:
    m = 0
    for e_k, e_v in sorted(even.items(), key=lambda x: x[1], reverse=True)[:2]:
        for o_k, o_v in sorted(odd.items(), key=lambda x: x[1], reverse=True)[:2]:
            if e_k == o_k:
                continue
            m = max(m, e_v + o_v)

    print(N - m)


Measured memory_bytes: 21292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 998244353;
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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<vector<mint>> dp(c + 1, vector<mint>(d + 1, 0));
  dp[a][b] = 1;
  rep2(i, a, c + 1) rep2(j, b, d + 1) {
    dp[i][j] += dp[i - 1][j] * j + dp[i][j - 1] * i;
    dp[i][j] -= dp[i - 1][j - 1] * (i - 1) * (j - 1);
    // printf("dp[%d][%d]=%d\n", i, j, dp[i][j]);
  }
  cout << dp[c][d] << endl;
}

Measured memory_bytes: 73672
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int m = scanner.nextInt();
		for(int i = 0; i < m; i++)
		{
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b)
			{
				System.out.println("YES");
			}
			else
			{
				System.out.println("NO");
			}
		}
	}
}

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

int main() {
  int64_t n;
  cin >> n;
  
  int64_t ans = 0;
  
  for (int64_t x = 1; x <= n; x += 2) {
    int64_t num = 0;
    for (int64_t i = 1; i <= x; i++) {
      if (x % i == 0) {
        num++;
      }
    }
    
    if (num == 8) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
x,y = map(int, raw_input().split())
ans = 10**10
if x<=y:
    ans = min(ans, y-x)
if -x<=y:
    ans = min(ans, y+x+1)
if y<=x:
    ans = min(ans, x-y+2)
if -y>=x:
    ans = min(ans, -y-x+1)
print ans


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

using namespace std;

#define endl '\n'

typedef long long ll;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

#define _rep3(i,p,n) for(int i=(p),i##_counter=(n); i<i##_counter;++i)
#define _rep2(i,n,_) _rep3(i,0,n)
#define _rep_call(a, b, c, name, ...) name(a, b, c)
#define rep(...) _rep_call(__VA_ARGS__, _rep3, _rep2)

#define dump(x)  cerr << #x << " = " << (x) << '\n'
#define debug(x) cerr << #x << " = " << (x) << " (at line " << __LINE__ << ")" << " " << __FILE__ << '\n'

void Main() {
    int N, L; cin >> N >> L;
    vector<string> s(N);
    getline(cin, s[0]);
    rep(i, N) {
        getline(cin, s[i]);
    }
    sort(s.begin(), s.end());
    rep(i, N) {
        cout << s[i];
    }
    cout << '\n';
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main()
{
	int n;
	scanf("%d", &n);
	long long ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (i % 3 == 0 || i % 5 == 0)
		{
			continue;
		}
		ans += (long long)i;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1728
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
lis2=sorted(lis)
pm=[-1 for i in range(n)]
for i in range(n):
    if lis2[i]>=0:
        pm[i]=1
if pm[0]==1:
    pm[0]=-1
elif pm[-1]==-1:
    pm[-1]=1
ans=0
for i in range(n):
    ans=ans+pm[i]*lis2[i]
print(ans)
x=lis2[0]
for i in range(1,n-1):
    if pm[i]==1:
        print(x,lis2[i])
        x=x-lis2[i]
for i in range(1,n-1):
    if pm[i]==-1:
        print(lis2[-1],lis2[i])
        lis2[-1]=lis2[-1]-lis2[i]
print(lis2[-1],x)
    
        


            
        
        
            
    
            
            

    
    
            
            



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

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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int n, x, y, z, s;
vector<int> k;
int dp[41][1 << 17];

int add(int a, int b){
	return (a + b) % mod;
}
int sub(int a, int b){
	return (a - b + mod) % mod;
}
int mul(int a, int b){
	return ll(a) * b % mod;
}
int pow(int a, int k){
	int b = 1;
	while(k > 0){
		if(k & 1){
			b = mul(b, a);
		}
		a = mul(a, a);
		k >>= 1;
	}
	return b;
}

void enm(int p){
	if(p >= 1 << s - 1){
		vector<int> c;
		for(int i = 1; i <= s; ++i){
			if(p >> i - 1 & 1){
				c.push_back(i);
			}
		}
		if(
			binary_search(c.begin(), c.end(), x) &&
			binary_search(c.begin(), c.end(), x + y)
		){
			k.push_back(p);
		}
		return;
	}

	int q;
	for(int i = 1; (q = p << i | 1 << i - 1) < 1 << s; ++i){
		enm(q);
	}
}

int main(){
	cin >> n >> x >> y >> z;

	s = x + y + z;
	enm(0);

	dp[0][0] = 1;
	for(int i = 1; i <= n; ++i){
		rep(j, 1 << s){
			for(int k = 1; k <= 10; ++k){
				int& a = dp[i][(j << k | 1 << k - 1) & ((1 << s) - 1)];
				a = add(a, dp[i - 1][j]);
			}
		}
		for(int v: k){
			dp[i][v] = 0;
		}
	}

	int ans = 0;
	rep(i, 1 << s){
		ans = add(dp[n][i], ans);
	}
	cout << sub(pow(10, n), ans) << endl;
	return 0;
}

Measured memory_bytes: 20864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll H,W,M;
  ll maxh=0,maxw=0,h[300001],w[300001];
  vector<ll> listh,listw;
  map<pair<ll,ll>,int> mp; 
  cin >> H >> W >> M;
  ll datah[300001]={},dataw[300001]={};
  for(ll i = 0; i < M; ++i){
    cin >> h[i] >> w[i];//列と行受け取り
    datah[h[i]]++;//その列に含まれるボムの数
    dataw[w[i]]++;//その行に含まれるボムの数
    mp[make_pair(h[i],w[i])]=1;
    if(maxh<datah[h[i]]){
      maxh=datah[h[i]];
    }
    if(maxw<dataw[w[i]]){
      maxw=dataw[w[i]];
    }
  }
  for(ll i = 0; i < 300001; ++i){
    if(maxh==datah[i]){
      listh.push_back(i);
    }
    if(maxw==dataw[i]){
      listw.push_back(i);
    }
  }
  for(ll x:listh){
    for(ll y:listw){
      if(!mp.count(make_pair(x,y))){
        cout << maxh+maxw;
        return 0;
      }
    }
  }
  cout << maxh+maxw-1;
}

Measured memory_bytes: 37616
N = int(input())
S = input()
K = int(input())

S_list = list(S)
tmp_letter = S_list[K-1]
for i in range(N):
    if S_list[i] != tmp_letter:
        S_list[i] = '*'

S_changed = "".join(S_list)
print(S_changed)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  int a = 0, b = 0;
  for (int i = 0; i < s.size(); i++) {
    a += s[i] == '+';
    b += s[i] == '-';
  }
  cout << a - b << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=2005;
int n,m;
char s[max_n][max_n];
int h[max_n];
int l[max_n],r[max_n];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf(" %s",s[i]+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)s[i][j]=s[i][j]=='#';
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(i==1){
            for(int j=1;j<=m;j++)h[j]=1;
        }
        else{
            for(int j=1;j<=m;j++){
                if(j==1){
                    h[j]++;
                    continue;
                }
                int x=s[i][j]^s[i-1][j]^s[i][j-1]^s[i-1][j-1];
                if(x==1)h[j]=1;
                else h[j]++;
            }
        }
        stack<int> stk;
        for(int j=1;j<=m;j++){
            while(!stk.empty()&&h[stk.top()]>=h[j])stk.pop();
            l[j]=stk.empty()?0:stk.top();
            stk.push(j);
        }
        while(!stk.empty())stk.pop();
        for(int j=m;j>=1;j--){
            while(!stk.empty()&&h[stk.top()]>=h[j])stk.pop();
            r[j]=stk.empty()?m+1:stk.top();
            stk.push(j);
        }
        for(int j=1;j<=m;j++){
            if(l[j]==0)ans=max(ans,(r[j]-l[j]-1)*h[j]);
            else ans=max(ans,(r[j]-l[j])*h[j]);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll l=0,r=0;
int bj[500010] = {0};
bool playbfs(vector<int> nn[],int n)
{
	int t,t1;
	queue<int> bfs;
	bfs.push(1);
	bj[1] = 1;
	while(!bfs.empty())
	{
		int w;
		int t;
		w = bfs.front();
		bfs.pop();
		if(bj[w]&1)
			l++;
		else
			r++;
		for(t=0;t<nn[w].size();t++)
		{
			if(bj[nn[w][t]] == 0)
			{
				bj[nn[w][t]] = bj[w]+1;
				bfs.push(nn[w][t]);
			}
			else
			{
				if(bj[w]%2 == bj[nn[w][t]]%2)
					return 0;
			}
		}
	}
	return 1;
}
int main()
{
	ll n,m;
	scanf("%lld%lld",&n,&m);
	vector<int> nn[n+1];
	int t;
	for(t=0;t<m;t++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		nn[a].push_back(b);
		nn[b].push_back(a);
	}
	if(playbfs(nn,n))
		printf("%lld\n",l*r-m);
	else
		printf("%lld\n",n*(n-1)/2-m);
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <string.h>
using namespace std;

int n, m, q;
int a[501][501], b[501][501];

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

	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));

	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;

		a[l][r]++;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			b[i + 1][j + 1] = b[i + 1][j] + b[i][j + 1] + a[i + 1][j + 1] - b[i][j];
	}

	for (int i = 0; i < q; i++) {
		int p, w;

		cin >> p >> w;
		cout << b[w][w] - b[p - 1][w] - b[w][p - 1] + b[p - 1][p - 1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2944
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
//ll a[MAX],cnt[MAX];
ll ans = 0,sum = 0;

ll q;
vll z(11);
vll a(55),b(55),c(55),M(55);

void dfs(ll d, ll p)
{
	for(int i = p ; i <= m ; i++)
	{
		z[d] = i;
		if(d<n-1)
			dfs(d+1,i);
		if(d==n-1)
		{
			sum = 0;
			fr(j,0,q)
				if(z[b[j]-1] - z[a[j]-1] == c[j])
					sum+=M[j];
			ans = max(sum,ans);
		}
	}
}

int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast

cin >> n >> m >> q;
fr(i,0,q)
{
	cin >> a[i] >> b[i] >> c[i] >> M[i];
}

dfs(0,1);
cout << ans;


  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 3676
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            int c = cin.ReadInt;

            Console.WriteLine(a * b / 2);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <stdio.h>
#include <string>
#include <complex>
using namespace std;
int main(void) {
  long long int N, Y;
  long long int x=0, y=0, z=0;
  cin >> N >> Y;
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= (N - i); j++) {
      z = N - i - j < 0 ? 0 : N - i - j;
      if((10000 * i + 5000 * j + 1000 * z) == Y) {
        cout << i << ' ' << j << ' ' << z << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
//atcoder 176 C
#include<bits/stdc++.h>
typedef long long ll;
const int N = 2e5 + 10; 
using namespace std;
int a[N];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
    	cin >> a[i];
	}
	int x = a[0];
	ll sum = 0;
	for (int i = 1; i < n; ++i) {
		if (a[i] < x) sum += (x - a[i]);
		else x = a[i];
	}
	cout << sum << endl;
} 

Measured memory_bytes: 4412
#include<stdio.h>

typedef struct
{
  char card;
  int num;
  int p;
}card;

int main()
{
  int n;
  card t[36];
  card d[36];
  card temp;
  int i = 0;
  char card;
  int num;
  int p;
  int f = 1;
  
  scanf("%d", &n);
  
  for(int j = 0; j < n*2; j++)
    {
      scanf("%c %d", &card, &num);
      t[j/2].card = card;
      t[j/2].num = num;
      t[j/2].p = j;
      d[j/2].card = t[j/2].card;
      d[j/2].num = t[j/2].num;
      d[j/2].p = j;
    }
  while(1)
    {
      if(i == n-1)
	{
	  break;
	}
      if(d[i].num > d[i+1].num)
	{
	  temp.card = d[i].card;
	  temp.num = d[i].num;
	  d[i].card = d[i+1].card;
	  d[i].num = d[i+1].num;
	  d[i+1].card = temp.card;
	  d[i+1].num= temp.num;
	  i = 0;
	  continue;
	}
      i++;
    }
  
  for(int k = 0; k < n-1; k++)
    {
      p = k;
      for(int j = k; j < n; j++)
	{
	  if(t[j].num < t[p].num)
	    {
	      p = j;
	    }
	}
      if(p != k)
	{
	  temp = t[k];
	  t[k] = t[p];
	  t[p] = temp;
	}
    }
  for(int j = 0; j < n; j++)
    {
      printf("%c%d%c", d[j].card, d[j].num, " \n"[j == n-1]);
      if(j>0 && d[j].num == d[j-1].num && d[j].p < d[j-1].p)
	{
	  f = 0;
	}
    }
  printf((f ? "Stable\n" : "Not stable\n"));
  for(int j = 0; j < n; ++j)
    {
      printf("%c%d%c", t[j].card, t[j].num, " \n"[j==n-1]);
      if(j>0 && t[j].num == t[j-1].num && t[j].p < t[j-1].p)
	{
	  f = 0;
	}
    }
  printf((f ? "Stable\n" : "Not stable\n"));
}



Measured memory_bytes: 1924
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void) {

    int n;
    while (cin >> n, n) {
        vector<int> k(n);
        for (int i = 0; i < n; i++) cin >> k[i];
        string s; cin >> s;

        for (int i = 0; i < s.size(); i++) {
            for (int j = 0; j < k[i%n]; j++) {
                if (s[i] == 'a') {
                    s[i] = 'Z';
                } else if (s[i] == 'A') {
                    s[i] = 'z';
                } else {
                    s[i]--;
                }
            }
        }

        cout << s << endl;
    }

    return 0;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef unsigned int  UI;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;

template <typename T> using VT = vector<T>;
template <typename T> using VVT = VT<VT<T>>;
template <typename T> using VVVT = VT<VT<VT<T>>>;
template <typename T> using VVVVT = VT<VT<VT<VT<T>>>>;

#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    int a, b, x;
    cin >> a >> b >> x;
    cout << (a <= x && x <= a + b ? "YES" : "NO") << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int base_to_decimal(char ch){
	if('0' <= ch && ch <= '9'){
		return ch - '0';
	}else if(isupper(ch)){
		return ch - 'A' + 10;
	}else if(islower(ch)){
		return ch - 'a' + 36;
	}
}




int main(void){
	int n, i, j, base,dec, bit_count,ans;
	char ch;


	scanf("%d",&n);
	ans = 0;
	for(i = 0;i < n;i++){
		scanf("%d",&base);
		getchar();
		dec = 0;
		while((ch = getchar()) != '\n'){
			dec = dec * base + base_to_decimal(ch);
		}
		bit_count = 0;
		for(j = 0;j < 18;j++){
			if(((dec >> j) & 1) == 1){
				bit_count++;
			}
		}

		ans ^= bit_count;
	}
	if(ans != 0){
		printf("win\n");
	}else{
		printf("lose\n");
	}

	return 0;
}
		

Measured memory_bytes: 1012
# RL に淀む

s = input()
anslist = [0 for _ in range(len(s))]
stock = [0, 0]
evenodd = 0
for i, c in enumerate(s) :
    if c == "R" :
        stock[evenodd] += 1
    else :
        if evenodd :
            anslist[i-1] += stock[0]
            anslist[i] += stock[1]
        else :
            anslist[i-1] += stock[1]
            anslist[i] += stock[0]
        stock = [0, 0]
    evenodd ^= 1
evenodd = 0
for i, c in enumerate(s[::-1]) :
    if c == "L" :
        stock[evenodd] += 1
    else :
        if evenodd :
            anslist[-i-1] += stock[1]
            anslist[-i] += stock[0]
        else :
            anslist[-i-1] += stock[0]
            anslist[-i] += stock[1]
        stock = [0, 0]
    evenodd ^= 1
print(" ".join(map(str, anslist)))

Measured memory_bytes: 10492
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1232>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MAX_PRIME = 200000;
vector<int> primes;
vector<int> is_prime(MAX_PRIME + 1,true);
void init_primes(){
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= MAX_PRIME;i++){
        if(is_prime[i]){
            primes.push_back(i);
            for(int j = i*2; j <= MAX_PRIME; j+=i) is_prime[j] = false;
        }
    }
}
int m,a,b;
vector<int> solve(){
    vector<int> res{0,0};
    for(int i = 0; primes[i]*primes[i] <= m;i++){
        for(int j = i; primes[i]*primes[j] <= m;j++){
            if(a*primes[j] <= b*primes[i] && primes[j]*primes[i] >= *res.begin()**res.rbegin()){
                *res.begin() = primes[i]; *res.rbegin() = primes[j];
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    init_primes();
    while(cin >> m >> a >> b,m){
        cout << solve() << endl;
    }
    return 0;
}



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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , m;
   cin >> n >> m;
   string s;
   cin >> s;
   int cur = n , lst = -1 , ch = n - 1;
   vector <int> ans;
   while(cur != 0){
      for(int i = ch ; i >= max(0 , cur - m) ; i--){
         if(s[i] == '0')
            lst = i;
         ch = i - 1;
      }
      if(lst == -1)
         return cout << -1 , 0;
      ans.push_back(cur - lst);
      cur = lst;
      lst = -1;
   }
   reverse(ans.begin() , ans.end());
   for(int x : ans)
      cout << x << " ";
   return 0;
}


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

minimum = N

for i in range(1,N):
    total = 0
    A = i
    B = N-i
    a = str(A)
    b = str(B)
    for j in range(len(a)):
        total = total + int(a[j])
    for k in range(len(b)):
        total = total + int(b[k])
    minimum = min(minimum,total)

print(minimum)

Measured memory_bytes: 3064
#include <iostream>

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

    std::cin >> w >> h >> x >> y >> r;

    if (((x - r < 0) || (x + r > w)) || ((y - r < 0) || (y + r > h))) {
        std::cout << "No" << std::endl;
    }

    if (((x - r >= 0) && (x + r <= w)) && ((y - r >= 0) && (y + r <= h))) {
        std::cout << "Yes" << std::endl;
    }

}



Measured memory_bytes: 3120
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdlib.h>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
#include<cstdlib>
const int MAX=1e5+10;
long long n,m;
int a[MAX];
int main()
{
    cin>>n>>m;
    long long sum=0;
    if(m==0)
    {
        cout<<n*n<<endl;
        return 0;
    }
    for(int i=m+1;i<=n;i++)
    {
        int t=n/i;
        sum+=t*(i-m);
        int t1=n%i;
        //cout<<t1<<endl;
        if(t1>=m)
            sum+=t1-m+1;
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256