akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var list = new int[5];

            for (var i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                switch (s[0])
                {
                    case 'M':
                        list[0]++;
                        break;
                    case 'A':
                        list[1]++;
                        break;
                    case 'R':
                        list[2]++;
                        break;
                    case 'C':
                        list[3]++;
                        break;
                    case 'H':
                        list[4]++;
                        break;
                }
            }

            var result = 0L;
            for (var i = 0; i < 32; i++)
            {
                var r = 1L;
                var count = 0;
                for (var j = 0; j < 5; j++)
                {
                    if (((i >> j) & 1) == 1)
                    {
                        count++;
                        r *= list[j];
                    }
                }
                if (count == 3)
                {
                    result += r;
                }
            }
            Console.WriteLine(result);
        }
    }
}


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

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> m(N);
	for (int i = 0; i < N; i++) {
		cin >> m.at(i);
	}
	int minm = m.at(0);
	for (int i = 1; i < N; i++) {
		if (minm > m.at(i)) {
			minm = m.at(i);
		}
	}
	int counter = 0;
	X -= accumulate(m.begin(), m.end(), 0);
	counter += N;
	counter += X/minm;
	cout << counter << endl;
}

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

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var set = new Dictionary<int, int>();
		for(int i = 0; i < n; i++)
		{
			var a = int.Parse(ReadLine());
			if(!set.ContainsKey(a))
				set.Add(a, 0);
			set[a]++;
		}
		WriteLine(set.Count(x => x.Value % 2 == 1));
	}
}


Measured memory_bytes: 27164
using System;
using System.Linq;

namespace BBounding
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];
            var x = inputs[1];

            var lengths = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var boundCount = 1;
            var position = 0;
            for (var i = 0; i < n; i++)
            {
                position += lengths[i];

                if (position > x) break;
                boundCount++;
            }

            // 解答の出力
            Console.WriteLine(boundCount);
        }
    }
}


Measured memory_bytes: 13268
fun main() {
  val N = readInt()
  val A = readInts()
  val B = readInts()
  val C = readInts()
  var sum = 0
  A.forEachIndexed { i, a ->
    sum += B[a - 1]
    if (A.getOrNull(i - 1) == a - 1) sum += C[a - 2]
  }
  println(sum)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 36372
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define ll long long
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
ll keta(ll num){ ll k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int h, w;
char g[1010][1010];

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

    queue<pair<int, int>> visit;

    cin >> h >> w;
    rep(y, h){
        rep(x, w){
            cin >> g[x][y];
            if(g[x][y] == '#') visit.push(make_pair(x, y));
        }
    }

    int res = 0;
    int cnt = visit.size(), cnt2 = 0;
    while(!visit.empty()){
        if(cnt == cnt2){
            res++;
            cnt = visit.size();
            cnt2 = 0;
        }
        pair<int, int> xy = visit.front();
        visit.pop();

        rep(i, 4){
            int x = xy.first + dx[i];
            int y = xy.second + dy[i];
            if(x < 0 || x >= w || y < 0 || y >= h) continue;
            if(g[x][y] == '#') continue;
            else g[x][y] = '#';
            visit.push(make_pair(x, y));
        }
        cnt2++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9488
#include <iostream>

using namespace std;

int main(void)
{
	int n, m, x;
	cin >> n >> m >> x;

	int a[110] = {};

	for (int i = 0; i < m; i++)
	{
		int num = 0;
		cin >> num;

		a[num] = 1;
	}

	int left = 0;
	int right = 0;

	for (int i = x - 1; i > 0; i--)
	{
		left += a[i];
	}

	for (int i = x + 1; i < n; i++)
	{
		right += a[i];
	}

	if (left < right)
		cout << left << endl;
	else
		cout << right << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define int long long
typedef long long ll;


int N, Q,_L,_R;
vector<int> a;
vector<__int128_t> x;
vector<__int128_t> s;
vector<__int128_t> t;
__int128_t B;
__int128_t calc(__int128_t X){
    for(int i=0;i<Q;i++){
        if(a[i] == 1)
        {
            if(X >= x[i]){
                X = (X + s[i]) * t[i];
            }
        }else{
            if(X <= x[i]){
                X = (X - s[i]) / t[i];
            }
        }
        X = min(X, B);
        X = max(X, -B);
    }
    return X;
}

signed main(){


    //cerr << (int) ( (__int128_t)-5 / 3) << endl;

    cin >> N >> Q >> _L >> _R;
    __int128_t L, R;
    L = _L;
    R = _R;
    vector<__int128_t> A(N);

    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        A[i] = a;
    }    
    sort(A.begin(),A.end());
    a.resize(Q);
    x.resize(Q);
    s.resize(Q);
    t.resize(Q);
    for(int i=0;i<Q;i++){
        int _x,_s,_t;
        cin >> a[i] >> _x >> _s >> _t;
        x[i] = _x;
        s[i] = _s;
        t[i] = _t;
    }

    B = ((int)1 << 62);
    B *= 4;
    //cerr << (int)(B / 8) << endl; 
    __int128_t lo, hi;

    lo = (__int128_t)-1e10;
    hi = (__int128_t)1e10;

    while(hi - lo > 1){
        __int128_t m = (hi + lo) / 2;
        __int128_t t = calc(m);
        if(t >= L){
            hi = m;
        }else{
            lo = m;
        }
    }

    __int128_t LL = hi;

    
    lo = (__int128_t)-1e10;
    hi = (__int128_t)1e10;

    while(hi - lo > 1){
        __int128_t m = (hi + lo) / 2;
        __int128_t t = calc(m);

        //cerr << (int)m << " " << (int)t << " " << (int)R << endl;
        if(t <= R){
            lo = m;
        }else{
          //  cerr << "A"<<endl;
            hi = m;
        }
    }

    __int128_t RR = lo;
    //cerr << (int)LL <<" " << (int)RR << endl;
    int res = upper_bound(A.begin(), A.end(), RR) - lower_bound(A.begin(), A.end(), LL);
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 16608
great_list = []
x,y,z,k = map(int,input().split(' '))
a = list(map(int,input().split(' ')))
b = list(map(int,input().split(' ')))
c = list(map(int,input().split(' ')))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

for i in range(min(k,len(a)))[:k]:
	for j in range(min(k // (i+1),len(b)))[:k]:
		for l in range(min(k // ((i+1) * (j+1)),len(c)))[:k]:
			great_list.append(a[i] + b[j] + c[l])

great_list.sort(reverse=True)
for i in great_list[:k]:
    print(i)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
// using mP = pair<modint, modint>;

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


// 拡張ユークリッドの互除法
ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

void solve() {
    ll a, b; cin >> a >> b;
    ll x, y;
    extgcd(a, b, x, y);
    cout << x << " " << y << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



Measured memory_bytes: 7324
N, M, X = map(int, input().split())
C = []
A = []
for i in range(N):
    y = list(map(int, input().split()))
    C.append(y[0])
    A.append(list(y[1:]))

ans = sum(C)+1
for i in range(1 << N):
    Q = [0] * M
    price = 0
    bits = format(i, 'b')
    for j in range(N):
        if i & (1 << j):
            for k in range(M):
                Q[k] += A[j][k]
            price += C[j]

    flg = True
    for j in range(M):
        if Q[j] < X:
            flg = False
    if flg:
        ans = min(ans, price)
print(ans if ans < sum(C) + 1 else -1)


Measured memory_bytes: 9196
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()
    val XY = rd.readListIntCols(N)

    val P = ArrayList<Int>()
    val M = ArrayList<Int>()
    val ms = mutableSetOf<IntPair>()
    for (i in 0 until N) {
        val pr = IntPair(XY[i][0], XY[i][1])
        if (ms.contains(pr)) continue
        ms.add(pr)

        val (x, y) = pr
        P.add(x + y)
        M.add(x - y)
    }
    if (ms.size <= 1) {
        println(0)
        return
    }

    val ans = max(P.max()!! - P.min()!!, M.max()!! - M.min()!!)
    println(ans)
}


//val rd = debug.Reader("abc", "178", "e", "rndsample-024")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readDouble: () -> Double = { br.readLine().toDouble() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readIntArray: () -> IntArray = { readListInt().toIntArray() }
    val readLongArray: () -> LongArray = { readListLong().toLongArray() }
    val readListStringCol: (Int) -> List<String> = { N -> (0 until N).map { readString() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { readListInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { readListLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


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

//#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
typedef pair <int, int> pii;
const int maxn = 1e5 + 5, mod = 1e9 + 7;
int fact[maxn], inv[maxn], A[maxn], p[maxn];

int P(int a, int b) {
	if (!b)
		return 1;
	int y = P(a, b / 2);
	y *= y;
	y %= mod;
	if (b % 2)
		return y * a % mod;
	return y;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	inv[0] = fact[0] = p[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = i * fact[i - 1] % mod;
		inv[i] = P(fact[i], mod - 2);
		p[i] = 2 * p[i - 1] % mod;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(A, A + n);
	for (int i = 0; i < n; i++) {
		if (i >= k - 1)
			ans += A[i] * fact[i] % mod * inv[k - 1] % mod * inv[i - k + 1] % mod;
		if (n - i - 1 >= k - 1) {
			ans -= A[i] * fact[n - i - 1] % mod * inv[k - 1] % mod * inv[n - i - k] % mod;
		}
		ans %= mod;
		ans += mod;
		ans %= mod;
	}
	cout << ans;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
//vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }
bool com(ll a,ll b,ll M){
    return abs(M-a)<abs(M-b);
}

int main(){
    ll N,M,m,ans;
    cin>>N;
    ll A[N];
    for(ll i=0;i<N;i++) cin>>A[i];
    sort(A,A+N);
    M=A[N-1];
    A[N-1]=A[0];
    ans=A[0];
    for(ll i=0;i<N;i++){
        if(ans<min(M-A[i],A[i])){
            ans=A[i];
        }
    }
    cout<<M<<" "<<ans<<endl;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt();
			System.out.println((0 == (x % f(x)) ? "Yes" : "No"));
		}
	}

	/**
	 * 整数xを十進法で表したときの各桁の数字の和を求める
	 * 
	 * @param x 入力数字
	 * @return 整数xを十進法で表したときの各桁の数字の和
	 */
	private static int f(int x) {
		int result = 0;
		while (x > 0) {
			result += x % 10;
			x /= 10;
		}
		return result;
	}
}


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


int main(){

	ll n,w;
	cin>>n>>w;
	ll arr[n],wt[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i]>>wt[i];
	}
	ll dp[n+1][w+1];

	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0||j==0)
				dp[i][j]=0;
			else
			{
				ll inc=0,exc=0;
				exc=dp[i-1][j];
				if(arr[i-1]<=j)
				{
					inc=dp[i-1][j-arr[i-1]]+wt[i-1];
				}
				dp[i][j]=max(inc,exc);
			}
		}
	}
	cout<<dp[n][w];
}

Measured memory_bytes: 82500
use proconio::{input, marker::Chars};

fn main() {
    input!(_: usize, c: Chars);

    let r = c.iter().filter(|&&c| c == 'R').count();
    let ans = c
        .iter()
        .scan((0, r), |(w, r), &c| {
            if c == 'W' {
                *w += 1;
            } else {
                *r -= 1;
            }
            Some((*r).max(*w))
        })
        .min()
        .unwrap()
        .min(r);

    println!("{}", ans);
}


Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Debug.Trace
trace _ a = a

solve :: Int -> [(String,Int)] -> Int
solve n cas = revNums VU.! n
  where

{--
k :: [0..2n-1]
i :: [0..n]
bwTbl ! (enc k col i)
  = # { p | k < p, (col,j) is located at p, i >= j }
--}    

  bwTbl :: VU.Vector Int
  bwTbl = trace ("bwTbl = " ++ show bwTbl0) bwTbl0

  bwTbl0 = VU.create $ do
    bwv <- VUM.new ((2*n+1)*2*(n+1))
    forM_ [0..n] $ \i -> do
      VUM.write bwv (enc 0 0 i) i
      VUM.write bwv (enc 0 1 i) i
    forM_ (zip [1..] cas) $ \(k, (c, a)) -> do
      forM_ [0..n] $ \i -> do
        forM_ [0,1] $ \col -> do
          x <- VUM.read bwv (enc (k-1) col i)
          let y | col == color c && i >= a = x-1
                | otherwise = x
          VUM.write bwv (enc k col i) y
    return bwv
  enc  k col i = k * (2*(n+1)) + col * (n+1) + i
  bwT k col i = trace ("bwT " ++ show (k,col,i,ans)) ans
    where ans = bwT0 k col i
  bwT0 k col i = bwTbl VU.! (enc (k+1) col i)

  posTbl :: VU.Vector Int
  posTbl = VU.create $ do
    vec <- VUM.new (2*(n+1))
    forM_ (zip [0..] cas) $ \(k, (c,a)) -> do
      VUM.write vec (encP (color c) a) k
    return vec
  encP col a = col * (n+1) + a
  posT col a = trace ("posT " ++ show (col,a,ans)) ans
    where ans = posT0 col a
  posT0 col a = posTbl VU.! (encP col a)
    
  revNums = foldl op (VU.replicate (n+1) 0) [1..2*n]
    where
    op prev m = trace ("op " ++ show (prev, m, a)) a
      where a = op0 prev m

    op0 prev m = VU.create $ do
      vec <- VUM.replicate (n+1) 0
      forM_ indices $ \i -> do
        VUM.write vec i (min (putBlack i) (putWhite i))
      when (m <= n) $ do
        VUM.write vec 0 (putWhite 0)
        VUM.write vec m (putBlack m)
      return vec
      where
        indices | m <= n = [1..m-1]
                | otherwise = [m-n..n]
        putBlack i = (prev VU.! (i-1)) + (right (posT 0 i) (i-1) (m-i))
        putWhite i = (prev VU.! i) + (right (posT 1 (m-i)) i (m-i-1))
        right k bn wn = bwT k 0 bn + bwT k 1 wn

color s | head s == 'B' = 0
        | otherwise     = 1

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      cas = map (\[x1,x2] -> (B.unpack x1,readBInt x2)) remLines1
  in solve n cas

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


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

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

    vector<ll> A(N);
    rep(i,N) cin >> A.at(i);

    vector<ll> B(N);
    copy(all(A), B.begin());

    sort(all(A));
    
    vector<P> data(1);
    auto it = A.begin();
    for(ll i=1; i<=N+1; i++){
        auto it_old = it;
        it = lower_bound(all(A),i);

        if(it!=it_old){
            P tmp;
            tmp.first = i-1;
            tmp.second = it - it_old;
            data.push_back(tmp);
        }        
    }

    ll M = data.size();
    
    ll ans = 0;
    rep(i,M){
        ans += data.at(i).second * (data.at(i).second-1)/2;
    }
    
    vector<ll> d(M);
    rep(i,M){
        d.at(i) = data.at(i).first;
    }
    /*
    rep(i,M){
        cout << data.at(i).first << " " << data.at(i).second << endl;
    }*/
    
    rep(k,N){
        ll ans2 = ans;
        auto i = lower_bound(all(d), B.at(k));
        ans2 -= data.at(i-d.begin()).second - 1;
        cout << ans2 << endl;
        //cout << data.at(i-d.begin()).second << endl;
    }

    return 0;
}


Measured memory_bytes: 7664
#include <iostream>

int count[26];

int main() {
	int h, w;
	std::cin >> h >> w;

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			char c;
			std::cin >> c;
			++count[c - 'a'];
		}
	}

	int odd = 0;
	int two = 0;
	for (auto&& e : count) {
		e %= 4;

		if (e % 2 == 1)
			++odd;
		else if (e == 2)
			++two;
	}

	bool ans = true;
	if (w % 2 == 1 && h % 2 == 1 && odd != 1)
		ans = false;
	else if ((w % 2 == 0 || h % 2 == 0) && odd != 0)
		ans = false;
	else if (w % 2 == 1 && h % 2 == 1 && two > h / 2 + w / 2)
		ans = false;
	else if (w % 2 == 1 && h % 2 == 0 && two > h / 2)
		ans = false;
	else if (h % 2 == 1 && w % 2 == 0 && two > w / 2)
		ans = false;
	else if (h % 2 == 0 && w % 2 == 0 && two != 0)
		ans = false;

	std::cout << (ans ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S);
  int ans = 0;
  char prev = S[0];
  each(x, S) {
    if (x != prev) {
      ans++;
    }
    prev = x;
  }
  print(ans);
}


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

namespace Aoj_Learning2
{
    class Program
    {
        static void Main(string[] args)
        {
            Aoj_Learning17();
        }

        static void Solve(ref int[] S, int i, int size, ref bool[] ans, int[] Sequence1, int[] Sequence2, int Size2)
        {
            if (size == i)
            {
                int sum = 0;
                for(int j = i-1; j >= 0; j--)
                {
                    if(1 == S[j])
                    {
                        sum += Sequence1[j];
                    }
                }
                // 数列内まとめて確認
                for (int j = 0; j < Size2; j++)
                {
                    if (Sequence2[j] == sum) ans[j] = true;
                }
                return;
            }

            Solve(ref S, i + 1, size, ref ans, Sequence1, Sequence2, Size2);
            S[i] = 1;
            Solve(ref S, i + 1, size, ref ans, Sequence1, Sequence2, Size2);
            S[i] = 0;
        }

        private static void Aoj_Learning17()
        {
            string[] str;
            int iSequenceCount1 = 0, iSequenceCount2 = 0;
            int[] iSequence1 = new int[20];
            int[] iSequence2 = new int[200];
            int[] iSelect = new int[20];

            // 数列を取得
            iSequenceCount1 = int.Parse(Console.ReadLine());
            str = Console.ReadLine().Split(' ');
            for(int i = 0; i < iSequenceCount1; i++)
            {
                iSequence1[i] = int.Parse(str[i]);
            }
            iSequenceCount2 = int.Parse(Console.ReadLine());
            str = Console.ReadLine().Split(' ');
            for (int i = 0; i < iSequenceCount2; i++)
            {
                iSequence2[i] = int.Parse(str[i]);
            }

            // 数列2内の数値を数列1内の数値の和で表現可能か探索
            bool[] b = new bool[iSequenceCount2];
            // 再起処理
            Solve(ref iSelect, 0, iSequenceCount1, ref b, iSequence1, iSequence2, iSequenceCount2);

            for (int i = 0; i < iSequenceCount2; i++)
            {
                if (true == b[i])
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }           
            
        }
    }
}


Measured memory_bytes: 15968
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (n, k) = listOfInt()
    val hh = listOfInt()
    hh.count { it >= k }.let(::println)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 48008
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b


from itertools import combinations
from collections import defaultdict

N = int(input())
points = [tuple(map(int, input().split())) for _ in range(N)]

if N == 1:
    print(1)
    exit()

# points.sort()  # 先にソートしておくと大小関係の処理が楽

cnts = defaultdict(lambda: 0)
for pa, pb in combinations(points, 2):
    dx = pa[0] - pb[0]
    dy = pa[1] - pb[1]
    if dx < 0:  # 事前にソートしておくとココらへんの処理がいらなくなるよ
        dx *= -1
        dy *= -1
    if dx == 0:
        dy = max(dy, -dy)
    if dy == 0:
        dx = max(dx, -dx)
    cnts[(dx, dy)] += 1

print(N - max(cnts.values()))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int H, W;

int main(void){
    
    scanf("%d %d", &H, &W);
    vector<string> c(H);
    for(int i = 0; i < H; ++i){
        string s; cin >> s;
        c[i] = s;
    }
    
    vector<string> ans;
    for(int i = 0; i < H; ++i) for(int j = 0; j < 2; ++j) ans.push_back(c[i]);
    
    for(int i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 384
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
          for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
         if(prime[i]==0)
           seve.pb(i);
       }
    }
    int main()
    {   
         IOS;
         ll n,m,i,j,k;
        cin>>n>>m;
        if(n<m)
          cout<<0;
        else
          cout<<10;

    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,d;
string s;
int cnt;
int main(){
	cin>>n;
	cin>>a>>b>>c>>d;
	cin>>s;
	if(c<d){
		cnt=0;
		for(int i=a-1;i<min(d-1,n-1);i++){
			if(s[i]==s[i+1]&&s[i]=='#'){
				cnt++;
				break;
			}
		}
		if(cnt>0) cout<<"No";
		else cout<<"Yes";
	}
	else{
		cnt=0;
		for(int i=a-1;i<min(c-1,n-1);i++){
			if(s[i]==s[i+1]&&s[i]=='#'){
				cnt++;
				break;
			}
		}
		if(cnt>0){
			cout<<"No";
		}
		else{
			cnt=0;
			for(int i=b-2;i<min(d-1,n-2);i++){
				if(s[i]==s[i+1]&&s[i+1]==s[i+2]&&s[i]=='.'){
					cnt++;
					break;
				}
			}
			if(cnt>0) cout<<"Yes";
			else cout<<"No";
		}
	}
}

Measured memory_bytes: 640
using System;

public class hello
{

    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var w = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            if (w == 0 && h == 0) break;
            var map = new string[h, w];
            for (int i = 0; i < h; i++)
            {
                var s = Console.ReadLine().Trim();
                for (int j = 0; j < w; j++)
                {
                    int t;
                    map[i, j] = int.TryParse(s[j].ToString(), out t) ? s[j].ToString() : "#";
                }
            }
            var dp = new string[h, w];
            goDp(map, h, w, dp);
        }
    }
    static void goDp(string[,] map, int h, int w, string[,] dp)
    {
        var ans = "0";
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (map[i, j] != "#")
                {
                    string t;
                    if ((i - 1 < 0) || (map[i - 1, j] == "#")) t = map[i, j];
                    else t = dp[i - 1, j] + map[i, j];
                    string t2;
                    if ((j - 1 < 0) || (map[i, j - 1] == "#")) t2 =  map[i, j];
                    else t2 = dp[i, j - 1] + map[i, j];
                    dp[i, j] = checkAB(t, t2) ?  delete0(  t) :delete0( t2);
                    if (((i + 1 >= h) || (map[i + 1, j] == "#")) &&( (j + 1 >= w) || map[i, j + 1] == "#"))
                        ans = checkAB(ans, dp[i, j]) ? ans : dp[i, j];
                }
            }
        }
        Console.WriteLine(ans);
        //print(ans);
    }
    static string delete0 (string s)
    {
        if (s.Replace("0", "").Length == 0) return "0";
        var ans = "";
        var p = 0;
        var first = true;
        while (p < s.Length)
        {
            if (first && s[p] != '0') { ans += s[p]; first = false; }
            else if (!first) ans += s[p];
            p++;
        }
        return ans;

    }
    static bool checkAB(string s, string t)
    {
        if (s == "") s = "0";
        if (t == "") t = "0";
        if (s.Length > t.Length) return true;
        else if (s.Length < t.Length) return false;
        return s.CompareTo(t) > 0;
    }
}



Measured memory_bytes: 30876
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int64_t n;
    cin>>n;
    int x,m;
    cin>>x>>m;
    int64_t a=x;
    vector<int> c(m,0);
    int64_t d=x;
    c[x]=1;
    queue<int> e;
    e.push(x);
    int f=-1;
    int g=-1;
    int h=0;
    for (int i = 1; i < n; i++)
    {
        d=(d*d)%m;
        a+=d;

        if (d==0)
        {
            break;
        }else if (c[d]==1)
        {
            e.push(d);
            while(f!=d){
                f=e.front();
                e.pop();
            }
            g=i;
            break;
            
        }else
        {
            c[d]=1;
            e.push(d);
        }  
    }

    int64_t aa,ab;
    int64_t ac=0;

    if (g==-1)
    {
        cout<<a<<endl;
    }else
    {
        aa=(n-g-1)/e.size();
        ab=(n-g-1)%e.size();
        while (!e.empty())
        {
            ac+=e.front();
            h++;
            e.pop();
            if (h==ab)
            {
                a+=ac;
            }
        }
        a+=aa*ac;
        cout<<a<<endl;
    }


    


    return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 200005;
const int MOD = 1000000007;

vector<int> g[MAXN];
int c[MAXN],mx[MAXN],v[MAXN],d[MAXN],cc[MAXN],cur;

void dfs(int a){
	if(c[a] == 0) c[a] = cc[cur];
	for(int i:g[a]) if(mx[i] < mx[a]-1){
		mx[i] = mx[a]-1;
		dfs(i);
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,m; cin >> n >> m;
	memset(mx,-1,sizeof mx);
	for(int i=0;i<m;i++){
		int a,b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int q; cin >> q; 
	for(int i=0;i<q;i++) cin >> v[i] >> d[i] >> cc[i];
	for(int i=q-1;i>=0;i--){
		if(mx[v[i]] < d[i]){
			mx[v[i]] = d[i];
			cur = i;
			dfs(v[i]);
		}
	}
	for(int i=1;i<=n;i++) cout << c[i] << '\n';
	return 0;
}


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

int main(void)
{
	int A, B, C;

	cin >> A>> B>> C;

	if ((A == B && B == C) || (A != B && B != C && C != A)) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int N,M;
set<string> S;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    string s; cin >> s; S.insert( s );
  }
  cin >> M;
  bool f = false;
  for(int i=0;i<M;i++){
    string s; cin >> s;
    if( S.find( s ) != S.end() ){
      if( !f ){
        cout << "Opened"; f = true;
      } else {
        cout << "Closed"; f = false;        
      }
      cout << " by ";
    } else
      cout << "Unknown ";
    cout << s << endl;
  }
}

Measured memory_bytes: 3236
n = gets.to_i
a = gets.split.map(&:to_i)
lcum = [0]
rcum = [0]
l = r = max = 0

(n - 1).times do |i|
  lcum << (l = a[i].gcd(l))
  rcum << (r = a[-1 - i].gcd((r)))
end

n.times do |i|
  tmp = lcum[i].gcd(rcum[n - 1 - i])
  max = tmp if max < tmp
end

puts max

Measured memory_bytes: 10264
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s >> s;
	cout << "A" << s[0] << "C" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int main()
{
	while(1) {
		int n, m;
		cin >> n >> m;
		if (!n && !m) break;
		Mii p;
		int len = 0;
		rep(i,0,n) {
			int a, b;
			cin >> a >> b;
			p[b] += a;
			len += a;
		}
		len -= m;
		int sum = 0;
		rep(i,0,11) {
			if (p[i]) {
				if (len > p[i]) {
					len -= p[i];
					sum += i * p[i];
					p[i] = 0;
				}
				else {
					sum += i * len;
					len = 0;
				}
			}
			if (len <= 0) break;
		}
		if (sum > 0) cout << sum << endl;
		else cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    string s;
    cin >> s;
    ll ans = 0;
    map<pair<string, string>, ll> m1, m2;
    for(ll i = 0; i < (1 << N); i++){
        string s1, s2, s3, s4;
        for(ll j = 0; j < N; j++){
            ((i >> j) & 1 ? s1 : s2) += s[j];
            ((i >> j) & 1 ? s3 : s4) += s[j + N];
        }
        m1[pair<string, string>(s1, s2)]++;
        m2[pair<string, string>(s3, s4)]++;
    }
    for(auto ite = m1.begin(); ite != m1.end(); ite++){
        string s1 = ite->first.first;
        string s2 = ite->first.second;
        reverse(s1.begin(), s1.end());
        reverse(s2.begin(), s2.end());
        ans += (ite->second) * m2[pair<string, string>(s2, s1)];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 132864
#include <stdio.h>

int main(void)
{
	int A, B, K;
	int i, n;
	int counter = 0;

	scanf("%d %d %d", &A, &B, &K);


	if(A<=B)
	{
		n = A;
	}
	else
	{
		n = B;
	}


	for(i=n; i>0; i--)
	{
		if(A%i == 0 && B%i == 0)
		{
			counter++;
			if(counter == K) printf("%d", i);
		}
	}	

	return 0;
}

Measured memory_bytes: 128
def dyn(n,d00,d01,d02,d03,d10,d11,d12,d13):
    D00 = d00 + d10*int(n != 0)
    D10 = d10*int(n==0)
    D01 = d00*9 + d10*(n-1+int(n==0)) + d01 + d11*int(n!=0)
    D11 = d10*(int(n!=0)) + d11*(int(n==0))
    D02 = d01*9 + d11*(n-1+int(n==0)) + d02 + d12*int(n!=0)
    D12 = d11*(int(n!=0)) + d12*(int(n==0))
    D03 = d02*9 + d12*(n-1+int(n==0)) + d03 + d13*int(n!=0)
    D13 = d12*(int(n!=0)) + d13*(int(n==0))
    return D00,D01,D02,D03,D10,D11,D12,D13

N = str(input())
K = int(input())
S = len(N)
D00=0
D01=0
D02=0
D03=0
D10=1
D11=0
D12=0
D13=0

for i in range(S):
    [D00,D01,D02,D03,D10,D11,D12,D13] = dyn(int(N[i]),D00,D01,D02,D03,D10,D11,D12,D13)

if K == 1:
    print(D01+D11)
elif K==2:
    print(D02+D12)
else:
    print(D03+D13)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define left  (2*idx)+1
#define right (2*idx)+2
#define pb push_back
#define ll long long
#define all(x) x.begin(),x.end()
 

const ll MOD = (ll)(1e9 + 7); 
const ll N = 1000001;

bool sieve[N];

void fun()
{
	for(ll i=2; i<N; i++) {
		if(sieve[i]) {
			continue;
		}
		ll j = i*i;
		while(j < N) {
			sieve[j] = true;
			j+=i;
		}
	}
}

int main()
{
	FIO;
	fun();
	ll a, b;
	cin >> a >> b;
	a = __gcd(a, b);
	ll cnt = 0;
	for(int i=2; i<N; i++) {
		if(!sieve[i] && (a%i == 0)) {
			cnt+=1;
			while(a%i==0) {
				a/=i;
			}
		}
	}
	if(a!=1) {
		cnt+=1;
	}
	cout << cnt+1 << "\n";
	return 0;	
}	

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main() {

int N;
cin >>N;

float T;
cin >>T;

float A;
cin >>A;

float val=10000;//暫定のAとの気温差

int ans;//暫定の建設地点

int h;

for( int i=1; i<=N ;i++ ){

cin >>h;

if( val > abs( T-h*0.006-A ) ){
ans=i;
val = abs( T-h*0.006-A );}

}

cout <<ans;


}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


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

int main(){
	ll n;cin >> n;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	
	ll ans = 0;
	if(v[0] != 0){
		cout << -1 << endl;
		return 0;
	}
	for(ll i = 1;i < n;i++){
		if(v[i] > v[i-1] + 1){
			cout << -1 << endl;
			return 0;
		}
		else if(v[i] == v[i-1] + 1){
			ans++;
		}
		else{
			ans += v[i];
		}
		DBG(cout << i << ' ' << ans << endl;);
	}
	
	cout << ans << endl;	
	
	return 0;
}


Measured memory_bytes: 1792
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()

print(N**3)

Measured memory_bytes: 12252
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	//入力を受け取る
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	//計算する
	int board[100][100];

	//白く塗る
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			board[i][j] = 1;
		}
	}

	//黒く塗る
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (i < h || j < w) board[i][j] = 0;
		}
	}

	//白を数える
	int ans = 0;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (board[i][j] == 1) ans++;
		}
	}

	//答えを出力する
	cout << ans << endl;
}



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

int main(void){

    int N; cin>>N;
    set<string> S;
    string tmp; cin>>tmp;
    S.insert(tmp);
    string past = tmp;

    for (int i = 1; i < N; ++i) {
         string tmp;cin >> tmp;
         if(S.find(tmp) != S.end() || past[past.length()-1] != tmp[0]){
             cout<<"No"<<endl;
             return 0;
         }
         S.insert(tmp);
         past = tmp;
    }
    cout<<"Yes"<<endl;

    return 0;
}

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

const int maxn = 1e6 + 10;

int N;
int p[maxn];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) {
		int x; scanf("%d", &x);
		p[x] = i;
	}
	int temp = 1;
	for (int i = 1, cur = 1; i <= N; ++i) {
		if (i == N) temp = max(temp, cur);
		else {
			if (p[i] < p[i + 1]) cur++;
			else {
				temp = max(temp, cur);
				cur = 1;
			}
		}
	}
	printf("%d\n", N - temp);
	return 0;
}

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

using namespace std;

const int MAX_N = 100010;
int dp[MAX_N];

int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; pow(6, i) <= N; i++) A.push_back(pow(6, i));
  for (int i = 0; pow(9, i) <= N; i++) A.push_back(pow(9, i));
  fill(dp, dp + MAX_N, numeric_limits<int>::max());
  dp[0] = 0;

  for (int i = 1; i <= N; i++) {
    for (int a : A) {
      if (i - a >= 0) dp[i] = min(dp[i], dp[i - a] + 1);
    }
  }

  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(){

  int n,i,j,change_times=0,x;

  scanf("%d",&n);

  int num[n];

  for(i=0;i<n;i++) scanf("%d",&num[i]);

  for(i=0;i<n;i++){

    for(j=n-1;j>i;j--){

      if(num[j-1]>num[j]){
	
	x=num[j];
	
	num[j]=num[j-1];
	
	num[j-1]=x;

	change_times++;
      }
    }
  }

    for(i=0;i<n;i++){
      
      printf("%d",num[i]);

      if(i<n-1)printf(" ");
    }

    printf("\n%d\n",change_times);

    return 0;
  }



Measured memory_bytes: 2100
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        }
                }
        }
}



Measured memory_bytes: 26232
N,K=map(int, raw_input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print len(str(Base_10_to_n(N,K)))

Measured memory_bytes: 27884
#include<bits/stdc++.h>
using namespace std;
int N, Y;
#define _for(i,a ,b) for(int i = a; i < b; i++)
#define _rep(i, a, b) for(int i = a; i <= b; i++)

bool solve() {
    cin >> N >> Y;
    Y /= 1000;
    _rep(i, 0, N) {
        _rep(j, 0, N - i)
            if(i * 10 + j * 5 + N - i - j == Y) {
                cout << i << ' ' << j << ' ' << N - i - j << endl;
                return true;
            }
    }
    return false;
}

int main() {
    if(!solve()) cout << "-1 -1 -1" << endl;
    return 0;
}

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

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> a(n + 2);
    for(int i = 0;i < m;i++){
        int l,r;
        cin >> l >> r;
        a[l]++;
        a[r + 1]--;
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        a[i] += a[i - 1];
        if(a[i] == m) ans++;;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int r ;
	cin >> r ;
	cout << r * r << endl;
}


Measured memory_bytes: 256