akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1)%1000000007;
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    string s;
    cin>>s;
    for(ll i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1]){
            cout<<"Yes"<<endl;
            exit(0);
        }
    }
    cout<<"No"<<endl;
        
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ABC148E();

int main()
{
	ABC148E();
	fflush(stdout);
	return 0;
}

static void ABC148E()
{
	LLONG N;
	getint(N);

	if (N % 2){
		printf("0\n");
		return;
	}
	LLONG ans = 0;
	LLONG divider = 10;
	while (divider <= N) {
		ans += N / divider;
		divider *= 5LL;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
n = int(input())
lis = list(map(int, input().split()))

cnt = 0
nlis = []

for i in lis:
    if i % 2 == 0:
        nlis.append(i)

if nlis == []:
    print(0)
    exit()
else:
    for m in nlis:
        while m > 1:
            m //= 2
            cnt += 1
            if m % 2 == 1:
                break

print(cnt)

Measured memory_bytes: 10100
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def f(S, init):
    F = [init[0], init[1]]
    for i, s in enumerate(S):
        if i == 0:
            continue
        d = 1 if s == "o" else -1
        F.append(F[i - 1] * F[i] * d)
    
    if F[0] != F[-1]:
        return None
    
    d = 1 if S[0] == "o" else -1
    d *= F[0]
    N = len(S)
    if F[-2] * F[1] == d:
        # print(F)
        return F[:N]
    else:
        return None


def main():
    N = int(input())
    S = input().strip()

    for init in [(1, 1), (-1, 1), (1, -1), (-1, -1)]:
        F = f(S, init)
        if F is not None:
            F = map(lambda v: "S" if v == 1 else "W", F)
            print("".join(F))
            return 
    
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5480
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (X, Y, Z) = readInts() |> triple

printfn "%d %d %d" Z X Y

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

int main() {
  string s;
  getline(cin, s);
  for (int i = 0; i < s.size(); i++) {
    auto c = s.at(i);
    if ('a' <= c && 'z' >= c) {
      cout << (char)toupper(c);
    } else if ('A' <= c && 'Z' >= c) {
      cout << (char)tolower(c);
    } else {
      cout << c;
    }
  }
  cout << endl;
}



Measured memory_bytes: 3164
/*input
8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

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

#define ll long long
#define endl "\n"
#define pb push_back
#define all(c) c.begin(),c.end()
#define inf 100000000000001
#define F first
#define S second
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n,m,x;
ll cost[15],mat[15][15],dp[15];

vector<ll> hell(vector<ll>v,ll pos)
{
	vector<ll>s;
	for(ll j=0;j<m;j++)
		s.pb(v[j]+mat[pos][j]);
	return s;
}

ll fun(ll pos,vector<ll>v)
{
	// cout<<pos<<endl;
	// for(ll j=0;j<m;j++)
	// 	cout<<v[j]<<" ";
	// cout<<endl;
	if(pos==n)
	{
		for(ll j=0;j<m;j++)
		{
			if(v[j]<x)
				return inf;
		}
		return 0;
	}

	return min(fun(pos+1,v),fun(pos+1,hell(v,pos))+cost[pos]);
}

void solve()
{
	cin>>n>>m>>x;
	for(ll i=0;i<n;i++)
	{
		cin>>cost[i];
		for(ll j=0;j<m;j++)
			cin>>mat[i][j];
	}
	memset(dp,-1,sizeof(dp));
	vector<ll>v(15);
	ll ans=fun(0,v);
	if(ans==inf)
		ans=-1;
	cout<<ans;
}

int main() 
{
    off;
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3672
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let abh = io.readn::<i64>(3);

    io.writeln((abh[0] + abh[1]) * abh[2] / 2);
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
using ll=long long;
int main(){

  ll lucas[87]={};
  lucas[0]=2;
  lucas[1]=1;
  int N;
  cin>>N;
  for(int i=2;i<=N;i++){
  
    lucas[i]=lucas[i-1]+lucas[i-2];
  }
  cout<<lucas[N];
  return 0;
}

Measured memory_bytes: 3624
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe

main :: IO ()
main = do
    -- 文字列の入力
    sa <- filter (`elem` ['a'..'c']) <$> getLine
    sb <- filter (`elem` ['a'..'c']) <$> getLine
    sc <- filter (`elem` ['a'..'c']) <$> getLine
    -- 出力
    putStrLn $ solve sa sb sc "a"

solve :: String -> String -> String -> String -> String
solve [] _ _ "a" = "A"
solve _ [] _ "b" = "B"
solve _ _ [] "c" = "C"
solve sa sb sc "a" = solve (drop 1 sa) sb sc (take 1 sa)
solve sa sb sc "b" = solve sa (drop 1 sb) sc (take 1 sb)
solve sa sb sc "c" = solve sa sb (drop 1 sc) (take 1 sc)


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

void solve() {
    ll N, W;
    cin >> N >> W;
    vector<ll> weight, value;
    for (ll i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        weight.push_back(x);
        value.push_back(y);        
    } 
    vector<vector<ll> > dp(N + 1, vector<ll>(W + 1, 0));
    for (ll i = 1; i <= N; i++) {
        for (ll w = 1; w <= W; w++) {
            ll x = 0, y = 0;
            if (w - weight[i - 1] >= 0)
                x = dp[i - 1][w - weight[i - 1]] + value[i - 1];
            y = dp[i - 1][w];
            dp[i][w] = max(x, y);
        }
    }
    cout << dp[N][W] << endl;
}

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

Measured memory_bytes: 83036
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << ” ” << xxx.second << “\n”;}}

using LL = long long;

int main() {

    int N;
    cin >> N;

    int x;
    cin >> x;
    x--;

    int minV = 0;
    int maxV = 2 * (N - 1);

    if (x == minV || x == maxV) {
        cout << "No" << endl;
        return 0;
    }

    int sz = 2 * N - 1;
    vector<int> ans(sz, -1);
    set<int> S;
    for (int j = -1; j <= 1; j++) ans[sz / 2 + j] = x + j, S.insert(x + j);

    int d = 0;
    for (int i = 0; i < sz; i++) {
        while (true) {
            if (ans[i] != -1) break;
            if (S.find(d) == S.end()) {
                ans[i] = d;
                S.insert(d);
            } else {
                d++;
            }
        }
    }

    cout << "Yes" << endl;
 //   SHOW_VECTOR(ans);
    for (int i = 0; i < sz; i++) cout << ans[i] + 1 << endl;

    return 0;
}































Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;

int n,a[3001];
vint G[3001],G2[3001];
int shohai[3001];
int main(){
	cin>>n;
	FOR(i,0,n) cin>>a[i];
	FOR(i,0,n-1){
		int s,t; cin>>s>>t;
		s--; t--;
		G[s].PB(t);
		G[t].PB(s);
		if(a[s]>a[t]) G2[s].PB(t);
		if(a[s]<a[t]) G2[t].PB(s);
	}
	FOR(i,0,n){
		if(G2[i].empty()) shohai[i]=-1;
	}
	FOR(i,0,n){
		FOR(j,0,n){
			bool fl=true;
			if(shohai[j]!=0) continue;
			for(int k:G2[j]){
				if(shohai[k]!=1){
					fl=false;
				}
				if(shohai[k]==-1){
					shohai[j]=1;
					break;
				}
			}
			if(fl) shohai[j]=-1;
		}
	}
	//FOR(i,0,n) cout<<shohai[i]<<" \n"[i==n-1];
	FOR(i,0,n){
		if(shohai[i]==1) cout<<i+1<<" ";
	}
	cout<<endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			string ab = Console.ReadLine();
			string[] num = ab.Split(' ');

			int a = int.Parse(num[0]);
			int b = int.Parse(num[1]);
			
			int d = a / b;
			int r = a % b;
			double f =(1.0 * a) / (1.0 * b);
			
			Console.WriteLine("{0} {1} {2:f8} ", d, r, f);

			Console.ReadKey();

		}
	}
}



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

using ll = long long;

int main(void){
  ll N; cin >> N;
  vector<ll> A(N);
  for(ll i = 0; i < N; i++){
    ll a; cin >> a;
    A[i] = a - (i+1);
  }
  sort(A.begin(), A.end());
  ll B[2];
  if(N % 2 == 1){
    B[0] = B[1] = A[N/2];
  }else{
    B[0] = A[N/2-1];
    B[1] = A[N/2];
  }
  ll ans = LLONG_MAX;
  for(const auto& b: B){
    ll res = 0;
    for(ll i = 0; i < N; i++){
      res += abs(A[i] - b);
    }
    ans = min(res, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        boolean[] exist = new boolean[105];
        for (int i = 0; i < N; i++) {
            exist[sc.nextInt()] = true;
        }

        int minDiff = X+1;
        int minNum = -1;
        for (int i = 0; i < exist.length; i++) {
            if (exist[i]) continue;
            if (Math.abs(X-i) < minDiff) {
                minDiff = Math.abs(X-i);
                minNum = i;
            }
        }

        System.out.println(minNum);
    }
}


Measured memory_bytes: 35764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, ans, tmp;
  cin >> N >> A;
  
  ans = 0; 
  while (A % 2 == 0) {
    A /= 2;
    ans++;
  }

  for (int i = 1; i < N; i++) {
    cin >> A;
  
  	tmp = 0;
    while (A % 2 == 0) {
      A /= 2;
      tmp++;
    }

    if (tmp < ans)
      ans = tmp;
    
    if (ans == 0)
      break;
  }  

  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, n;
	cin >> h >> w >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int p = 0;
	vector<vector<int>> ans(h, vector<int>(w));
	rep(i,h){
		if(i%2 == 0){
			rep(j,w){
				if(a[p]-- > 0){
					ans[i][j] = p+1;
				}
				else{
					ans[i][j] = p+2;
					a[++p]--;
				}
			}
		}
		else{
			for(int j = w-1; j >= 0; --j){
				if(a[p]-- > 0){
					ans[i][j] = p+1;
				}
				else{
					ans[i][j] = p+2;
					a[++p]--;
				}
			}
		}
	}
	rep(i,h){
		rep(j,w){
			cout << ans[i][j];
			if(j < w-1) cout << " ";
		}
		cout << endl;
	}
	return 0;
}

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

int main() {

long long int N;
cin >> N;

long long int ans = -1000000000000000;

long long int m = 1000000000000000;

for ( long long int i = 0; i < N; i++ ) {
long long int in;
cin >> in;
if ( i != 0 ) {
ans = max( ans, in - m );
}
m = min( m, in );
}

cout << ans << endl;
return 0;

}

Measured memory_bytes: 1156
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int x = 0;
	int ans = x;
	rep(i, 0, n) {
		if (s[i] == 'I') x++;
		else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

ll n;
vector<vector<vector<double>>> dp;

/* Clut LaTeX とかに貼り付けて読む
\documentclass{jsarticle}
\usepackage{amsmath}
\begin{document}
\begin{align*}
p_{i,j,k}                   & = \frac{N-(i+j+k)}{N}p_{i,j,k} + \left( \frac{i}{N}p_{i-1,j,k} + \frac{j}{N}p_{i+1,j-1,k} + \frac{k}{N}p_{i,j+1,k-1} + 1 \right)             &                     \\
                            & = \left(1-\frac{i+j+k}{N}\right)p_{i,j,k} + \left(  \frac{i}{N}p_{i-1,j,k} + \frac{j}{N}p_{i+1,j-1,k} + \frac{k}{N}p_{i,j+1,k-1} + 1 \right) &                     \\
                            & = p_{i,j,k}-\frac{i+j+k}{N}p_{i,j,k} + \left(  \frac{i}{N}p_{i-1,j,k} + \frac{j}{N}p_{i+1,j-1,k} + \frac{k}{N}p_{i,j+1,k-1} + 1 \right)      &                     \\
\frac{i+j+k}{N}p_{i,j,k}    & = \frac{i}{N}p_{i-1,j,k} + \frac{j}{N}p_{i+1,j-1,k} + \frac{k}{N}p_{i,j+1,k-1} + 1                                                           & (移項)              \\
\left(i+j+k\right)p_{i,j,k} & = ip_{i-1,j,k} + jp_{i+1,j-1,k} + kp_{i,j+1,k-1} + N                                                                                         & (両辺 \times N)     \\
p_{i,j,k}                   & = \frac{ip_{i-1,j,k} + jp_{i+1,j-1,k} + kp_{i,j+1,k-1}+N}{i+j+k}                                                                             & (両辺 \div (i+j+k)) \\
\end{align*}
\end{document}*/
double f(ll i, ll j, ll k) {
	if(dp[i][j][k] >= 0.0) return dp[i][j][k];
	if(i == 0.0 && j == 0.0 && k == 0.0) return 0.0;

	double ret = (double)n;
	if(i > 0) ret += f(i-1, j  , k  ) * i;
	if(j > 0) ret += f(i+1, j-1, k  ) * j;
	if(k > 0) ret += f(i  , j+1, k-1) * k;
	ret /= (double)(i + j + k);

	return dp[i][j][k] = ret;
}

int main(int argc, const char* argv[]) {
	cin >> n;
	vector<ll> b(4); // i 個の寿司が置かれた皿が b[i] 枚ある。b[0] は永遠に無視
	rep(i, n) {
		ll a;
		cin >> a;
		++b[a];
	}

	dp = vector<vector<vector<double>>>(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1, -1.0)));

	cout << std::setprecision(11) << f(b[1], b[2], b[3]) << endl;

	return 0;
}


Measured memory_bytes: 216960
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for a in range(n):
    s = input()
    if s == "AC":
        AC = AC + 1
    if s == "WA":
        WA = WA + 1
    if s == "TLE":
        TLE = TLE + 1
    if s == "RE":
        RE = RE + 1
print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)

Measured memory_bytes: 9088
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a, b ;
    cin >> a >> b ;
    double fa,fb ;
    fa = a ;
    fb = b ;
    printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb)) ;
    return 0 ;
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> T(N), A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &T[i], &A[i]);
  }
  ll a = T[0], b = A[0];
  for (int i = 1; i < N; ++i) {
    if (a <= T[i] and b <= A[i]) {
      a = T[i];
      b = A[i];
    }
    else if (a > T[i] and b > A[i]) {
      ll x = (a + T[i] - 1) / T[i];
      ll y = (b + A[i] - 1) / A[i];
      ll z = max(x, y);
      a = T[i] * z;
      b = A[i] * z;
    }
    else if (a <= T[i] and b > A[i]) {
      ll x = (b + A[i] - 1) / A[i];
      a = T[i] * x;
      b = A[i] * x;
    }
    else if (a > T[i] and b <= A[i]) {
      ll x = (a + T[i] - 1) / T[i];
      a = T[i] * x;
      b = A[i] * x;
    }
    // fprintf(stderr, "DEBUG: a=%lld, b=%lld\n", a, b);
  }

  ll ans = a + b;
  printf("%lld\n", ans);
  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-5;

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

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	int64 N, K;
	cin >> N >> K;
	vector<PLL> ab(N);
	REP(i, N) cin >> ab[i].fs >> ab[i].sc;
	sort(all(ab));
	REP(i, N) {
		if (ab[i].sc >= K) {
			cout << ab[i].fs << endl;
			return 0;
		}
		K -= ab[i].sc;
	}
}


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

int main() {
	int K,sum=0;
	cin >> K;
	for (int A = 1; A<= K; A++) {
		for (int B = 1; B <= K; B++) {
			for (int C = 1; C <= K; C++) {
				int n, m, a = A, b = B, c = C;
				while (1) {
					n = a % b;
					a = b;
					b = n;
					if (n == 0) break;
				}
				while (1) {
					n = a % c;
					a = c;
					c = n;
					if (n == 0) break;
				}
				sum = sum + a;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
long long N, M, a[100009][3],maxn = -(10000000000);

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}
	for (int i = 0; i < 8; i++) {
		long long b[10000];
		for (int j = 1; j <= N; j++) {
			long long S = 0;
			for (int k = 0; k < 3; k++) { 
                if ((i / (1 << k)) % 2 == 0) 
                    S += a[j][k]; 
                else S -= a[j][k]; 
			}
			b[j] = S;
		}
		sort(b+1,b+N+1); 
		long long ans = 0;
		for (int j = N; j >= N-M+1; j--) 
            ans += b[j];
        cout<<endl;
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;

  double ans;
  if (x >= a*a*b/2) {
    ans = atan2(2*b-2*x/a/a, a) * 180 / M_PI;
  }
  else {
    ans = 90 - atan(2*x/a/b/b) * 180 / M_PI;
  }

  cout << setprecision(12) << ans << endl;
}

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

int main() {
int n,temp;
cin>>n;
while(n>0)
{
	temp=n%10;
	n/=10;
	if(temp==7)
	{
		cout<<"Yes";
		return 0;
	}
}
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;

class node
{
    public:
      vector<int>rank,p;
      node(){}
      node(int size)
      {
          rank.resize(size,0);
          p.resize(size,0);
          for(int i=0;i<size;i++)
            makeset(i);
      }
      void makeset(int x)
      {
          p[x]=x;
          rank[x]=x;
      }

      bool same(int x,int y)
      {
          return findset(x)==findset(y);
      }

      void unite(int x,int y)
      {
          link(findset(x),findset(y));
      }

      int findset(int x)
      {
          if(x!=p[x])
          {
              p[x]=findset(p[x]);
          }
          return p[x];
      }

      void link(int x,int y)
      {
          if(rank[x]>rank[y])
          {
              p[y]=x;
          }
          else
          {
              p[x]=y;
              if(rank[x]==rank[y])
              {
                  rank[y]++;
              }
          }
      }
};

int main()
{
    int a,n,b,q,t;
    scanf("%d%d",&n,&q);
    node ds=node(n);

    for(int i=0;i<q;i++)
    {
        scanf("%d%d%d",&t,&a,&b);
        if(t==0) ds.unite(a,b);
        else if(t==1)
        {
            if(ds.same(a,b)) printf("1\n");
            else printf("0\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int h;
		cin >> h;
		if(h >= k) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Bitset 2 - Enumeration of Subsets 2


def subset(n, mask):
    for i in range(2**n):
        if i & mask == mask:
            yield i, [v for v in range(n) if i & (1 << v) > 0]


def run():
    n = int(input())
    mask = 0 & 2**n
    for i in input().split()[1:]:
        mask |= 1 << int(i)

    for i, vs in subset(n, mask):
        print("{}:{}".format(i, "".join([" {}".format(v) for v in vs])))


if __name__ == '__main__':
    run()



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

#define int long long

signed main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if ( k % 2 == 0 ) cout << a-b << endl;
  else cout << b-a << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

int main(){
  ll n;cin>>n;
  ll p=pow(2*n,0.5)+1;
  while((p*(p-1))/2>n){
    p--;
  }
  rep(i,1,p+1){
    if(i==(p*(p+1))/2-n)continue;
    cout<<i<<endl;
  }
}







Measured memory_bytes: 4024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1000005;
const ll mod=1e9+7;
ll m,ans=0,f[maxn],s[maxn];
int n;
int main(){
	scanf("%d",&n);
	m=1ll*(n-1)*(n-1)%mod;
	ans=m+1+(n>2);
	f[0]=s[0]=1;
	for(int i=1;i<n;i++){
		f[i]=f[i-1]+(i>2?s[i-3]:0);
		s[i]=s[i-1]+f[i];
		f[i]%=mod;
		s[i]%=mod;
		if(i!=n-1)ans=(ans+1ll*f[i]*(m+min(n-1,i+2))%mod)%mod;
		else ans=(ans+1ll*f[i]*n%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

namespace AtCoder.ABC067
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ')
                        .Select(long.Parse)
                        .ToArray();
            long sum1 = a[0], sum2 = a.Sum() - a[0], diff = 0, minDiff = Math.Abs(sum2 - sum1);
            for (int i = 1; i < n - 1; i++)
            {
                sum1 += a[i];
                sum2 -= a[i];
                diff = Math.Abs(sum2 - sum1);
                if (minDiff > diff) minDiff = diff;
            }
            Console.WriteLine(minDiff);
        }
    }
}

Measured memory_bytes: 32452
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;

//<--------------------------------------------typo section--------------------------------------------->
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
typedef priority_queue<int>piwi;
typedef queue<int>kiwi;
typedef map<int,int>mi;
typedef map<string,int>mis;
typedef multimap<int,int>muli;
typedef multimap<string,int>muls;
typedef multiset<int>si;

//<----------------------------------------------------Narcos----------------------------------------------->
#define endl "\n"
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sp " "
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define ki 1LL
#define MOD 1000000007
#define over return 0;
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define test int t;cin>>t;while(t--)


//<-----------------------------------------------------Const--------------------------------------------------->
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


//<--------------------------------------------------------------------------------------------------->
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for(int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
int man_seive(int n){ manipulated_seive(n); for(int i=0;i<prime.size() && prime[i]<=n;i++)
cout<<prime[i]<<endl;
}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

//continue;

//-----------------------------> YOUR JOURNEY STARTS HERE ------------------------------------>>

int main(){
    optimize();
    int n;
    cin>>n;int sum=1;
    for(int i=0;i<3;i++){
        sum*=n;
    }
    cout<<sum<<endl;
over
}


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define pi 3.14159265358979323846

using namespace std;

int main(){
	int x, n;	cin >> x >> n;
	vector<int> p;
	p.push_back(-1);
	if( n != 0 ){
		for( int i = 0; i < n; i++ ){
			int tmp;
			cin >> tmp;
			p.push_back(tmp);
		}
	}else{
		getchar();
		getchar();
	}
	int cnt = 0;
	int ans = 0;

	sort( all(p) );

	if( n != 0 )	cnt++;

	for( int i = 0; i <= 101; i++ ){
		if( i != p[cnt] ){
			if( abs( x - i ) < abs( x - ans ) ){
				ans = i;
			}
		}else{
			cnt++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
ll mod = 1e+9 + 7;

int main(){
    ll S;
    cin >> S;
    
    ll A[S+1] = {0};
    A[0] = 1;
    A[1] = 0;
    A[2] = 0;

    FOR(i, 3, S){
        A[i] = A[i-1] + A[i-3];
        A[i] %= mod;
    }

    int ans = A[S];
    //ans = (ans + mod)%mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"APPROVED":"DENIED")<<"\n";
using namespace std;
//-------------------------------------------

int main(void){
  ll N;cin>>N;
  ll A;
  bool APPROVED=true;
  REP(i,N){
    cin>>A;
    if(A%2==1)continue;
    if(A%3==0||A%5==0){
      continue;
    }
    APPROVED=false;
  }
  ifYN(APPROVED);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	int64 h,w;
	cin>>h>>w;
	if(h==1 || w==1)
		cout<<1<<endl;
	else{
		cout<<(h*w+1)/2<<endl;
	}
	return 0;
}


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

using namespace std;

#define int long long

int n;
int a[200001], b[200001];

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

	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);	
	if (n % 2 == 1)
	{
		int me_a = a[(n + 1) / 2], me_b = b[(n + 1) / 2];
		cout << (me_b - me_a + 1) << '\n';
	}
	else
	{
		int me_a = (a[n / 2] + a[n / 2 + 1]) / 2, me_b = (b[n / 2] + b[n / 2 + 1]) / 2;
		if ((a[n / 2] + a[n / 2 + 1]) % 2 && (b[n / 2] + b[n / 2 + 1]) % 2)
			cout << (me_b - me_a) * 2 + 1 << '\n';
		else if ((a[n / 2] + a[n / 2 + 1]) % 2)	
			cout << (me_b - me_a) * 2 << '\n';
		else if ((b[n / 2] + b[n / 2 + 1]) % 2)
			cout << (me_b - me_a) * 2 + 2 << '\n';
		else
			cout << (me_b - me_a) * 2 + 1 << '\n';				
	}
}

Measured memory_bytes: 6780
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,
        v: [usize; n]
    }
    let mut c = vec![v[0]];
    for &a in &v[1..] {
        if a > c[0] {
            c[0] = a;
            continue;
        }
        let mut l = 0;
        let mut r = c.len();
        while l + 1 < r {
            let m = (l + r) / 2;
            if c[m] >= a {
                l = m;
            } else {
                r = m;
            }
        }
        if r == c.len() {
            c.push(a);
        } else {
            c[r] = a;
        }
    }
    println!("{}", c.len());
}


Measured memory_bytes: 6396
#include <stdio.h>

#define N 101

int color[N];
int n, G[N][N],f[N],d[N],time;

void visit(int);

int main(){
  int i,j,v,vnext,k;
 
  scanf("%d",&n);

  for(i=0;i<n;i++){
    color[i] = 0;
    for(j=0;j<n;j++) {
      G[i][j] = 0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d %d",&v,&k);
    for(j=0; j<k; j++){
      scanf("%d",&vnext);
      G[v-1][vnext-1] = 1; 
    }
  }

  for(i=0; i<n; i++){
    if(color[i]==0) visit(i);
  }

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

void visit(int u){

  int i; 
  color[u]=1;
  d[u]= ++time;
  for(i=0; i<n; i++){
    if(G[u][i] == 1){
      if(color[i] == 0)visit(i);
    }
  }

  color[u]= 2;
  f[u]=++time;
}

Measured memory_bytes: 636
from bisect import bisect_left

while True:
    line = input()
    if line == '0':
        break

    d = int(line)  # 環状線の全長
    n = int(input())  # ピザの店舗の個数
    m = int(input())  # 注文の個数
    D = []

    for i in range(n - 1):
        D.append(int(input()))

    D += [0, d]
    D.sort()

    ans = 0

    for i in range(m):
        k = int(input())
        j = bisect_left(D, k)
        ans += min(abs(k - D[j - 1]), abs(k - D[j]))

    print(ans)


Measured memory_bytes: 9952
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll n,p;

void input(){
    cin >> n >> p;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    map<ll, ll> cnt;
    for(ll i=2;i*i<=p;i++){
        while(p % i == 0){
            cnt[i]++;
            p /= i;
        }
    }
    if(p > 1) cnt[p]++;
    ll ans = 1;
    for(auto e:cnt) ans *= pow(e.first, (e.second / n));
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	int height[20003]={0},current=0,max=0,sum=0;
	vector<int> top_left,top_right,ans_left,ans_right;
	string input="";
	getline(cin,input);
	input="/"+input+"\\";
	int sz=input.size();
	for(int i=0;i<sz;i++){
		switch(input[i]){
		case '/':
			height[i+1]=height[i]+1;break;
		case '\\':
			height[i+1]=height[i]-1;break;
		case '_':
			height[i+1]=height[i];break;
		}
	}
	for(int i=0;i<sz;i++){
		if(height[i]>height[i+1] && height[i]>=current){
			current=height[i];
			top_left.push_back(i);
		}
	}

	max=top_left.back();
	top_left.pop_back();
	current=height[sz-1];

	for(int i=sz-1;i>max;i--){
		if(height[i]>height[i-1] && height[i]>=current){
			current=height[i];
			top_right.push_back(i);
		}
	}

	for(int i=0;i<top_left.size();i++){
		int area=0,top=top_left[i];
		for(int j=top;;j++){
			area+=(height[top]-height[j])+(height[top]-height[j+1]);
			if(height[j+1]==height[top]){break;}
		}
		area>>=1;
		ans_left.push_back(area);
		sum+=area;
	}

	for(int i=0;i<top_right.size();i++){
		int area=0,top=top_right[i];
		for(int j=top;;j--){
			area+=(height[top]-height[j])+(height[top]-height[j-1]);
			if(height[j-1]==height[top]){break;}
		}
		area>>=1;
		ans_right.push_back(area);
		sum+=area;
	}
	cout<<sum<<'\n'<<top_left.size()+top_right.size();
	for(int i=0;i<ans_left.size();i++){
		cout<<' '<<ans_left[i];
	}
	for(int i=ans_right.size()-1;i>=0;i--){
		cout<<' '<<ans_right[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, v[20], c[20];

int main() {
	cin >> n;
	inc(i, n) { cin >> v[i]; }
	inc(i, n) { cin >> c[i]; }
	
	int ans = 0;
	inc(i, n) { ans += max(0, v[i] - c[i]); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int number[] = new int[3];
        for(int i = 0; i < 3; i++){
            number[i] = scan.nextInt();
        }

        Arrays.sort(number);

        int a = number[2] - number[0];
        int b = number[2] - number[1];

        if(a%2 == 0 && b%2 == 0){

            System.out.println((a/2)+(b/2));

        }else if(a%2 != 0 && b%2 == 0){

            System.out.println((a/2)+(b/2) + 2);

        }else if(a%2 == 0 && b%2 != 0){

            System.out.println((a/2)+(b/2) + 2);

        }else{

            System.out.println((a/2)+(b/2) + 1);
        }
    }
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define PI 3.141592653589793

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	string A, B, C;
	cin >> A >> B >> C;
	cout << (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0] ? "YES" : "NO") << endl;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int answer = 0;
  
  for(int j = 0;j < K;j++) {
    answer = answer + vec.at(j);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
SIZE=10**5+1; MOD=10**9+7 #998244353 #ここを変更する
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
 
def chofuku(ball,box): # nHk mod MOD の計算
    return choose(box+ball-1,box)


N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

smax=0
smin=0
for i in range(N):
    smax+=A[i]*choose(i,K-1)
    smax%=MOD
    smin+=A[i]*choose(N-i-1,K-1)
    smin%=MOD

print((smax-smin)%MOD)


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

using namespace std;


int main(){
	int N;
	long total;
	cin >>N;
	int B[N];
	for(int i=0;i<N-1;i++){
		cin >>B[i];
	}
	total=B[0];
	if(N==2){
		total+=B[0];
	}
	else{
		total+=B[N-2];
	}
	for(int i=1;i<N-1;i++){
		total+=min(B[i-1],B[i]);
	}
	cout <<total<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int x = 10;
  int keta = 1;
  int sum = N % 10;
  while(N >= x){
    sum += N / x % 10;
    x *= 10;
    keta++;
  }
  if(N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256