akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(n: i64);
    let x = match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => panic!(),
    };
    puts!("{}\n", x);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, M, A, B;
int D[1010];

int main() {
	cin >> N >> M >> A >> B;

	int now = 0;

	rep(i, N) cin >> D[i];

	while (now < N && D[now] >= A) ++now;

	if (N - now < M) {
		while (now > 0 && D[now-1] <= B) --now;
	}

	cout << now << endl;

	return 0;
}

Measured memory_bytes: 1168
from collections import defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
h = defaultdict(int)
for x in a:
    h[x] += 1
    if h[x]==3:
        h[x] = 1
y = sum([1 for x in h if h[x]==2])
print(len(h)-y%2)


Measured memory_bytes: 18656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans1=0,ans2=0;
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    vector<ll> WA(n,0);
    For(i,0,m){
        ll p;cin>>p;p--;
        string S;cin>>S;
        if(S=="AC"&WA[p]>-1){
            ans1++;
            ans2+=WA[p];
            WA[p]=-100000000;
        }
        else{
            WA[p]++;
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"io"
	"os"
	"strconv"
)

var pri = fmt.Println
var scan = fmt.Fscanln
var scanone = fmt.Fscan

func main() {
	solve(os.Stdin)
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] {
			res = a[i]
		}
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] {
			res = a[i]
		}
	}
	return res
}

func mustint(a string) int {
	i, _ := strconv.Atoi(a)
	return int(i)
}

type P struct {
	x, y int
}

func (p *P) add(q *P) *P {
	return &P{p.x + q.x, p.y + q.y}
}

const huge = 1e10

func get_around(i, j, h, w int) []P {
	res := make([]P, 0, 4)
	if i > 0 {
		res = append(res, P{i - 1, j})
	}
	if i < h-1 {
		res = append(res, P{i + 1, j})
	}
	if j > 0 {
		res = append(res, P{i, j - 1})
	}
	if j < w-1 {
		res = append(res, P{i, j + 1})
	}
	return res
}

func solve(rd io.Reader) {
	var h, w int
	scan(rd, &h, &w)
	board := make([][]int, h)
	for i := 0; i < h; i++ {
		board[i] = make([]int, w)
	}
	for i := 0; i < h; i++ {
		var s string
		scan(rd, &s)
		for j, ss := range s {
			if ss == '.' {
				board[i][j] = 1
			}
		}
	}

	all_pos := make([]P, 0, h*w)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if board[i][j] == 1 {
				all_pos = append(all_pos, P{i, j})
			}
		}
	}
	const MAX = 10000000000
	d := make([][][][]int, h)
	for i := 0; i < h; i++ {
		d[i] = make([][][]int, w)
		for j := 0; j < w; j++ {
			d[i][j] = make([][]int, h)
			for k := 0; k < h; k++ {
				d[i][j][k] = make([]int, w)
				for kl := 0; kl < w; kl++ {
					d[i][j][k][kl] = MAX
				}
			}
		}
	}
	for _, p := range all_pos {
		for _, q := range get_around(p.x, p.y, h, w) {
			d[p.x][p.y][q.x][q.y] = 1
		}
	}
	for _, p := range all_pos {
		d[p.x][p.y][p.x][p.y] = 0
	}
	for _, k := range all_pos {
		for _, i := range all_pos {
			for _, j := range all_pos {
				if d[i.x][i.y][j.x][j.y] > d[i.x][i.y][k.x][k.y]+d[j.x][j.y][k.x][k.y] {
					d[i.x][i.y][j.x][j.y] = d[i.x][i.y][k.x][k.y] + d[j.x][j.y][k.x][k.y]
				}
			}
		}
	}
	res := 0

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			for k := 0; k < h; k++ {
				for kl := 0; kl < w; kl++ {
					dd := d[i][j][k][kl]
					if dd != MAX && res < dd {
						res = dd
					}
				}
			}
		}
	}
	pri(res)
}


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

#define fi first
#define se second

using namespace std;

typedef pair<int, int> ii;

int n, a[100005][3], dp[100005][3];

//int recur(int d, int last)
//{
//	if(d == n)
//	{
//		if(last == 0)
//			return max(a[d][1], a[d][2]);
//		else if(last == 1)
//			return max(a[d][0], a[d][2]);
//		else
//			return max(a[d][0], a[d][1]);
//	}
//	if(last == 0)
//		return max(a[d][1] + recur(d + 1, 1), a[d][2] + recur(d + 1, 2));
//	else if(last == 1)
//		return max(a[d][0] + recur(d + 1, 0), a[d][2] + recur(d + 1, 2));
//	else
//		return max(a[d][1] + recur(d + 1, 1), a[d][0] + recur(d + 1, 0));
//}
int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	dp[1][0] = a[1][0];
	dp[1][1] = a[1][1];
	dp[1][2] = a[1][2];
	for(int i = 2; i <= n; ++i)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + a[i][2];
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
using namespace std;

array<int64_t, 200010> bit{};
string S;

int64_t sum(int i){
    int64_t s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x){
    while(i <= S.size()){
        bit[i] += x;
        i += i & -i;
    }
}

int main(){
    cin >> S;

    array<int, 26> data{};
    for(size_t i = 0; i < S.size(); ++i){
        data[int(S[i] - 'a')]++;
    }
    
    int kisu = 0;
    for(int i = 0; i < 26; ++i){
        if(data[i] % 2 != 0){
            ++kisu;
        }
    }

    if(kisu > 1){
        cout << -1 << endl;
        return 0;
    }

    int num = 1;
    array<int, 26> data2{};
    vector<int> p(S.size(), 0);
    vector<vector<int>> pdata(26, vector<int>(0));
    for(size_t i = 0; i < S.size(); ++i){
        int n = int(S[i] - 'a');
        data2[n]++;
        if(data2[n] <= data[n] / 2){
            p[i] = num;
            pdata[n].push_back(num);
            ++num;
        }
        else if(data[n] % 2 != 0 && data2[n] == data[n] / 2 + 1){
            p[i] = S.size() / 2 + 1;
        }
        else {
            p[i] = S.size() - pdata[n][data[n] - data2[n]] + 1;
        }
    }

    int64_t ans = 0;
    for(size_t i = 0; i < S.size(); ++i){
        ans += i - sum(p[i]);
        add(p[i], 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

int main(void){
	int N;
	int a[100010],b[100010];
	priority_queue<int> Q_plus,Q_minus;	
	bool can=true;
	scanf("%d",&N);
	rep(i,N)scanf("%d",&a[i]);
	rep(i,N)scanf("%d",&b[i]);
	rep(i,N){
		if(b[i]-a[i]>0){
			Q_plus.push(b[i]-a[i]);
		}else if(b[i]-a[i]<0){
			Q_minus.push(a[i]-b[i]);
		}
	}
	while(!Q_minus.empty()){
		if(Q_plus.empty()){
			can=false;
			break;
		}
		int plus = Q_plus.top();Q_plus.pop();
		int minus = Q_minus.top();Q_minus.pop();
		if(plus>minus*2){
			Q_plus.push(plus-minus*2);
		}else{
			if(minus-plus/2 != 0)Q_minus.push(minus-plus/2);
		}
	}
	if(can){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 384
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int& x : a) cin >> x;
    int Xor = 0;
    for(int x : a) Xor ^= x;
    vector<bool> need(31, false);
    for(int i : in(31)) {
        int t = 1 << i;
        if(Xor & t)
          need[i] = true;
    }
    vector<bool> have(31, false);
    for(int x : a) {
        int aim = x ^ (x - 1);
        for(int i : in(30, -1)) {
            int t = 1 << i;
            if(aim & t) {
                have[i] = true;
                break;
            }
        }
    }
    int ans = 0;
    bool ok = [&]() {
        bool cur = false;
        for(int i : in(30, -1)) {
            if(need[i]) {
                if(cur == false) {
                    if(have[i] == false)
                      return false;
                    cur = true;
                    ++ans;
                }
                else {
                    continue;
                }
            }
            else {
                if(cur == true) {
                    if(have[i] == false)
                      return false;
                    cur = false;
                    ++ans;
                }
                else {
                    continue;
                }
            }
        }
        return true;
    }();
    cout << (ok ? ans : -1) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){

    int n;
    int a[200000];
    //input
    scanf("%d", &n);

    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }

    //calc

    int max =0;
    int semimax =0;
    for(int j=0; j<n; j++){
        if(max <a[j]){
            max =a[j];
        }else if(semimax < a[j]){
            semimax =a[j];
        }   
    }
    //output
    for(int i=0; i<n; i++){
        if(max ==a[i]){ //a[i] is biggest
            printf("%d\n", semimax);
        }else{        //a[i] is not biggest
            printf("%d\n", max);
        }
    }



    return 0;
}


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

const int MAX = 200010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

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

long long mdpow(long long a, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n % 2 == 1) ans = ans * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return ans;
}

long long modinv(long long a) {
  long long m = MOD;
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

int main()
{
  int N, A, B, C; cin >> N >> A >> B >> C;

  COMinit();
  long long ans = 0;
  for (int i = 0; i < N; i++)
  {
    long long tmp = mdpow(A, i) * mdpow(B, N) % MOD;
    tmp = (tmp + mdpow(A, N) * mdpow(B, i) % MOD) % MOD;
    tmp = tmp * COM(N - 1 + i, i) % MOD;
    tmp = tmp * mdpow(inv[A + B], N + i) % MOD;
    tmp = tmp * (N + i) % MOD;

    ans = (ans + tmp) % MOD;
  }
  
  ans = ans * 100 % MOD;
  ans = ans * inv[100 - C] % MOD;
  
  cout << ans <<endl;
}

Measured memory_bytes: 4992
//Lunch
#include <iostream>

using namespace std;

int main() {
    int p, j, minp = 10000, minj = 10000;
    for(int i = 0; i < 3; i++) {
        cin >> p;
        minp = min(minp, p);
    }
    for(int i = 0; i < 2; i++) {
        cin >> j;
        minj = min(minj, j);
    }

    cout << (minp + minj - 50) << endl;

    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#define PI acos(-1.0)
using namespace std;
int a[3][3];
int main() {
	int n;
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			scanf("%d",&a[i][j]);
		}
	}
	cin >> n;
	int b;
	while(n--) {
		cin >> b;
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				if(a[i][j] == b) {
					a[i][j] = 0;
					break;
				}
			}
		}
	}
	int flag = 0;
	int ans = 0;
	for(int i = 0; i < 3; i++) {
		ans = 0;
		for(int j = 0; j < 3; j++) {
			if(a[i][j] == 0) ans++;
			else break;
		}
		if(ans == 3) {
			flag = 1;
			break;
		}
	}
	if(flag) cout << "Yes" << endl;
	else {
		for(int i = 0; i < 3; i++) {
			ans = 0;
			for(int j = 0; j < 3; j++) {
				if(a[j][i] == 0) ans++;
				else break;
			}
			if(ans == 3) {
				flag = 1;
				break;
			}
		}
		if(flag) cout << "Yes" << endl;
		else{
			if((a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)||(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)){
				flag = 1;
			}
			if(flag) cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	}

	return 0;
}

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

void print_number(int a[], int N){
	
	if(N==1){
		cout << a[0] <<endl;
		return;
	}
	
	for(int i=0; i<N-1; i++){
		cout << a[i] << " ";
	}
	cout << a[N-1] << endl;
}


int main() {
	int N, count=0;
	const int MAX_N = 100;
	int a[MAX_N];
	
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> a[i];
	}
	
	int tmp, mini;
	for(int i=0; i<N; i++){
		mini = i;
		for(int j=i; j<N; j++){
			if(a[mini] > a[j]){
				mini = j;
			}
		}
		if(mini != i){
			tmp = a[mini];
			a[mini] = a[i];
			a[i] = tmp;
			count++;
		}
	}
	
	
	print_number(a, N);
	cout << count << endl;
}

Measured memory_bytes: 1160
p = int(input())
a = list(map(int, input().split()))

MAX = 3000
fact = [1]*(MAX+1)
for i in range(1, MAX+1):
    fact[i] = (fact[i-1]*i) % p

inv = [1]*(MAX+1)
for i in range(2, MAX+1):
    inv[i] = inv[p % i]*(p-p//i) % p

fact_inv = [1]*(MAX+1)
for i in range(1, MAX+1):
    fact_inv[i] = fact_inv[i-1] * inv[i] % p

def comb(n, k):
    if n < k:
        return 0
    return fact[n] * fact_inv[n-k] * fact_inv[k] % p

ans = [0]*p
for i,ai in enumerate(a):
  if ai == 1:
    ans[-1] += 1
    for j in range(p):
      ans[j] -= pow(-i,j,p)*comb(p-1,j)
      ans[j] %= p
print(*ans[::-1])

Measured memory_bytes: 74416
# 入力
N, A, B, C, D = map(int, input().split())
S = input()

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[(A - 1):D]) and (
        C < D or
        '...' in S[(B - 2):(D + 1)]
    ) else
    'No'
)

# 出力
print(ans)


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int A[200001] = { 0, };
int _count[200001] = { 0, };

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		_count[A[i]]++;
	}
	int first=-1, second=-1;
	int value = 200000;
	while (_count[value] == 0) {
		value--;
	}
	first = value; _count[value]--;
	while (_count[value] == 0) {
		value--;
	}
	second = value; _count[value]--;

	for (int i = 0; i < n; i++) {
		if (A[i] == first) {
			printf("%d\n", second);
		}
		else {
			printf("%d\n", first);
		}
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l,num,ans,sum,ok,ng,mid;
ll x[500005],y[500005],z[500005];
bool used[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;
//string s;

int main(){
	cin >> k >> a >> b;
	if(b - a >= 2){
		k -= (a - 1);
		ans = a;
		ll times = k / 2;
		ans += times * (b - a);
		if(k % 2 == 1){
			ans ++;
		}
		p(ans);
	}else{
		p(k+1);
	}
	return 0;
}

Measured memory_bytes: 25088
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















vector<vector<ll>> g;
vector<bool> used;

void dfs(ll now){
    used[now] = true;
    for(auto &c : g[now]){
        if(!used[c]) dfs(c);
    }
}

int main(){
    ll n, m;
    cin >> n >> m;
    g.resize(n);
    REP(i, m){
        ll x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    ll ans = 0;
    used.resize(n);
    REP(i, n){
        if(!used[i]){
            dfs(i);
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8832
#include <iostream>
#include <queue>

using namespace std;

int main() {
    priority_queue<int, deque<int>, std::greater<int> > pq;
    long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    pq.push(a*x+b*y);
    pq.push(2*c*x+b*y);
    pq.push(a*x+2*c*y);
    pq.push(2*c*max(x,y));
    if (x >= y) pq.push(a*(x-y)+2*c*y);
    else pq.push(2*c*x+b*(y-x));
    cout << pq.top() << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int last = n%10;
		switch (last) {
			case 0:
			case 1:
			case 6:
			case 8:
				System.out.println("pon");
				return;
			case 2:
			case 4:
			case 5:
			case 7:
			case 9:
				System.out.println("hon");
				return;
			default:
				System.out.println("bon");
				return;
		}
	}

}


Measured memory_bytes: 35708
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const a = input[1].split(" ").map(n => Number(n));
  const gcd = (a, b) => {
    if (b === 0) return a;
    return gcd(b, a % b);
  }
  let result = a[0];
  for (let i = 1; i < n; i++) {
  	result = gcd(result, a[i]);
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17484
n,q=map(int,input().split())
s=[0]*-~n
w=m=0
for _ in[0]*q:
 a,v=map(int,input().split())
 s[a]+=v
 if v<0 and a==w:m=max(s);w=s.index(m)
 elif s[a]>m:w,m=a,s[a]
 elif s[a]==m and a<w:w=a
 print(w,m)


Measured memory_bytes: 13960
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
int main(){
    int n,a,b;
    cin>>n;
    if(n==1)cout<<"Hello World";
    else {
    	cin>>a>>b;
    	cout<<a+b;
	}
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict

INF = 10 ** 18

N, *A = map(int, read().split())
dp_not = defaultdict(lambda: -INF)
dp_take = defaultdict(lambda: -INF)
dp_not[(0, 0)] = 0

for i, x in enumerate(A, 1):
    j = (i - 1) // 2
    for n in (j, j + 1):
        dp_not[(i, n)] = max(dp_not[(i - 1, n)], dp_take[(i - 1, n)])
        dp_take[(i, n)] = dp_not[(i - 1, n - 1)] + x

print(max(dp_not[(N, N // 2)], dp_take[(N, N // 2)]))


Measured memory_bytes: 192592
#include <stdio.h>

int main(int argc, char *argv[]){
  int prise,num;
  long long int sum = 0;
  long long int num_sum = 0;
  int times = 0;
  
  while(scanf("%d,%d",&prise,&num) != EOF){
    sum += (long long int)(prise)*(long long int)(num);
    num_sum += num;
    ++times;
  }

  printf("%lld\n%d\n",sum,(int)((num_sum)/(double)(times) + 0.5));
  
  return 0;    
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << max({ a,b,c }) - min({ a,b,c }) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	string s;
	cin>>s;
	if(s=="SUN")cout<<7<<endl;
	if(s=="MON")cout<<6<<endl;
	if(s=="TUE")cout<<5<<endl;
	if(s=="WED")cout<<4<<endl;
	if(s=="THU")cout<<3<<endl;
	if(s=="FRI")cout<<2<<endl;
	if(s=="SAT")cout<<1<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 1000000
#define md 1000000007
 
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/

int main()
{
	IOS;
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int p=n/i;
		if(n%i==0)p--;
		ans+=p;
	}
	cout<<ans;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define MOD 1000000007LL

int main() {
    int N, K; cin >> N >> K;
    vector<int> A;
    vector<int> B;
    rep(i, N) {
        int j; cin >> j;
        ((j < 0) ? B : A).push_back(j);
    }
    if (N == K) {
        ll res = 1;
        if (A.size()) rep(i, A.size()) res = res * A.at(i) % MOD;
        if (B.size()) rep(i, B.size()) res = res * B.at(i) % MOD;
        if (res < 0) res += MOD;
        cout << res << endl;
        return 0;
    }
    sort(A.begin(), A.end()); // ASC
    sort(B.begin(), B.end(), greater<int>()); // DSC
    vector<int> C;
    if (B.size() < 2) { // All positive
        rep(i, K) C.emplace_back(A.back()), A.pop_back();
    } else if (A.size() == 0) { // All negative
        if (K % 2 == 0) { // Result must be positive
            rep(i, K) C.emplace_back(B.back()), B.pop_back();
        } else { // Result must be negative or zero
            rep(i, K) C.emplace_back(B[i]);
        }
    } else { // Use both positve and negative
        while (K > 0) {
            ll p1, p2;
            // There must be at least two elements of B
            ll n1, n2;
            if (K > 1 && B.size() > 1) {
                n1 = B.back();
                n2 = B.at(B.size() - 2);
                int AS = A.size();
                if (AS > 1) p1 = A.back(), p2 = A.at(AS - 2);
                if (AS < 2 || (p1 * p2 <= n1 * n2)) {
                    C.emplace_back(n1); B.pop_back();
                    C.emplace_back(n2); B.pop_back();
                    K -= 2;
                    continue;
                }
            } // Fall through
            p1 = A.back(); A.pop_back();
            C.emplace_back(p1);
            K--;
        }
    }

    ll res = 1;
    rep(i, C.size()) {
        res *= (ll)C[i];
        res %= MOD;
        if (res < 0) res += MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 5528
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int h,w,n;
  cin>>h>>w>>n;
  int sr,sc;
  cin>>sr>>sc;
  string s,t;
  cin>>s>>t;
  reverse(ALL(s));
  reverse(ALL(t));
  int hu = h, hl = 1;
  int wu = w, wl = 1;
  bool ok = true;
  REP(i,n) {
    switch(t[i]) {
      case 'L':
        wu = min(w, wu+1);
        break;
      case 'R':
        wl = max(1, wl-1);
        break;
      case 'U':
        hu = min(h, hu+1);
        break;
      case 'D':
        hl = max(1, hl-1);
        break;
    }
    switch(s[i]) {
      case 'L':
        wl = wl+1;
        break;
      case 'R':
        wu = wu-1;
        break;
      case 'U':
        hl = hl+1;
        break;
      case 'D':
        hu = hu-1;
        break;
    }
    if (wl > wu || hl > hu) ok = false;
  }
  ok = ok && hl <= sr && sr <= hu && wl <= sc && sc <= wu;
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 776
#include<stdio.h>
int main(){
  int i=0,n;
 
  while(1){
    scanf("%d",&n);
    if(n == 0){ 
      break;
    }
    else {
      i++;
      printf("Case %d: %d\n",i,n);
    }
  }
  return 0;
}


Measured memory_bytes: 2044
N=int(input())
A=list(map(int,input().split()))
ans=0
a=True

while a==True:
    for i in range(N):
        if A[i]%2==0:
            A[i]=A[i]//2
        else:
            a=False
    ans+=1
    
ans-=1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int N, n, d;
	
	while (cin >> N, N)
	{
		map<int, pair<int, int> > tbl;
		int minx = 0, maxx = 0, miny = 0, maxy = 0;
		int dx[] = {-1, 0, 1, 0};
		int dy[] = {0, 1, 0, -1};
		
		tbl[0] = mp(0, 0);
		rep(i, N - 1)
		{
			cin >> n >> d;
			int nowx = tbl[n].first;
			int nowy = tbl[n].second;
			int nx = nowx + dx[d];
			int ny = nowy + dy[d];
			tbl[i + 1] = mp(nx, ny);
			minx = min(minx, nx);
			maxx = max(maxx, nx);
			miny = min(miny, ny);
			maxy = max(maxy, ny);
		}
		
		cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
    int key;
    struct Node *right, *left, *parent;
};

struct Node *root, *NIL;

struct Node* treeMinimum(struct Node *x){
  while(x->left != NIL) x = x->left;
  return x;
}

struct Node *find(struct Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key)  u = u->left;
    else  u = u->right;
  }
  return u;
}

struct Node *treeSuccessor(struct Node *x){
  if(x->right != NIL) return treeMinimum(x->right);
  struct Node *y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(struct Node *z){
  struct Node *y;
  struct Node *x;

  if(z->left == NIL || z->right == NIL) y = z;
  else  y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }
  else{
    if(y == y->parent->left){
      y->parent->left = x;
    }
    else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }
  free(y);
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x =root;
  struct Node *z;

  z = malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else  x = x->right;
  }
  z->parent = y;
  if(y == NIL)  root = z;
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(struct Node *u){
  if(u == NIL)  return ;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u == NIL)  return ;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(void){
  int n, i, x;
  char s[20];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s", s);
    if(s[0] == 'f'){
      scanf("%d", &x);
      struct Node *t = find(root,x);
      if(t != NIL)  printf("yes\n");
      else  printf("no\n");
    }
    else if(strcmp(s, "insert")==0){
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp(s ,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(s, "delete")==0){
      scanf("%d", &x);
      treeDelete(find(root,x));
    }
  }
  return 0;
}



Measured memory_bytes: 20480
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N, K;
    cin >> N >> K;
    vector<int> vec(N);
    REP(i, N) cin >> vec.at(i);
    
    // calculation
    int sum = 0;
    REP(i, K) {
        auto iter = MAX(vec);
        sum += *iter;
        vec.erase(iter);
    }
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 888
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int h,w,n,a[10010];
int c[101][101];

int main(){
    I(h); I(w); I(n);
    REP(i,n) { I(a[i]); }

    int idx = 0;
    REP(i,h){
        if (i&1){
            REPN(j,w-1){
                c[i][j] = idx;
                a[idx]--;
                if(!a[idx]) idx++;
            }
        } else {
            REP(j,w) {
                c[i][j] = idx;
                a[idx]--;
                if(!a[idx]) idx++;
            }
        }
    }
    REP(i,h) {
        REP(j,w) {
            cout << c[i][j]+1 << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

for ti, ai in zip(t, a):
    if ti == ai == t[-1] == a[0]:
        break
else:
    print(0)
    exit()

ans = 1
for i in range(1, n - 1):
    if t[i - 1] == t[i] and a[i] == a[i + 1]:
        ans = ans * min(t[i], a[i]) % mod
print(ans)


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int W, H;
    cin >> W >> H;
    vector<ll> P(W), Q(H);
    for (int i = 0; i < W; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < H; i++) {
        cin >> Q[i];
    }
    sort(all(P));
    sort(all(Q));
    int p = 0, q = 0;
    ll ans = 0;
    while(p < W && q < H) {
        if (P[p] < Q[q]) {
            ans += P[p] * (1 + H - q);
            p++;
        } else {
            ans += Q[q] * (1 + W - p);
            q++;
        }
    }
    while(p < W) {
        ans += P[p] * (1 + H - q);
        p++;
    }
    while(q < H) {
        ans += Q[q] * (1 + W - p);
        q++;
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int solve(vector<int> A) {
	int N = A.size();
	int res = 0;
	for (int i = 0; i < N - 1; i++) {
		if (i % 2 == 0) {
			if (A[i] < A[i + 1]) {
				if (i + 2 < N && A[i + 1] > A[i + 2] && A[i] > A[i + 2]) {
					swap(A[i + 1], A[i + 2]);
				}
				else {
					swap(A[i], A[i + 1]);
				}
				res++;
			}
		}
		else {
			if (A[i] > A[i + 1]) {
				if (i + 2 < N && A[i + 1] < A[i + 2] && A[i] < A[i + 2]) {
					swap(A[i + 1], A[i + 2]);
				}
				else {
					swap(A[i], A[i + 1]);
				}
				res++;
			}
		}
	}
	/*for (int i = 0; i < N; i++) {
		cerr << A[i] << " ";
	}
	cerr << endl;*/
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int res = solve(A);
	for (int i = 0; i < N; i++) {
		A[i] = -A[i];
	}
	res = min(res, solve(A));
	cout << res << endl;
}


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

void fnInput(int& rnMaxNum, int& rnWinPnt)
{
  cin >> rnMaxNum >> rnWinPnt;
}

double fnWinRate(int nMaxNum, int nWinPnt)
{
  vector<int> vnBorder;

  int nBorder = nWinPnt;
  vnBorder.push_back( nBorder );

  while (nBorder > 1)
  {
    nBorder = (nBorder + 1) / 2;
    vnBorder.push_back( nBorder );
  }
  double nWinRate = 0.0;

  for (int nPower = vnBorder.size() - 1; nPower > 0; nPower--)
  {
    double nOneRate = 0.0;
    int nNum = vnBorder[nPower];

    while (nNum < min(vnBorder[nPower - 1], nMaxNum + 1))
    {
      nOneRate += 1.0 / nMaxNum;
      nNum++;
    }
    for (int n = 0; n < nPower; n++)
      nOneRate *= 1 / 2.0;

    nWinRate += nOneRate;
  }
  if (nMaxNum >= vnBorder[0])
  {
    int nDiff = nMaxNum - vnBorder[0] + 1;
    nWinRate += (double)nDiff / nMaxNum;
  }
  return nWinRate;
}
  
int main()
{
  int nMaxNum, nWinPnt;
  fnInput(nMaxNum, nWinPnt);
  cout << fixed << setprecision(10) << fnWinRate(nMaxNum, nWinPnt) << endl;

  return 0;
}

Measured memory_bytes: 3716
//
//  main.cpp
//  ABC175C
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main(int argc, const char * argv[]) {
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll ans=0;
    if(x/d>=k){
        ans=x-d*k;
    } else {
        ll e=x/d;
        k-=e;
        x-=e*d;
        if(k%2==1) x=abs(x-d);
        ans=x;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<long long int> adj[200001];
bool vis[200001];
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,x;
    cin>>n>>m>>x;
    ll c[n],a[n][m];
    for(ll i=0;i<n;i++){
        cin>>c[i];
        for(ll j=0;j<m;j++) cin>>a[i][j];
    }
    ll minn=10000000000;
    ll level[m];
    for(ll i=0;i<(1<<n);i++){
        bool ok=true;
        memset(level,0,sizeof level);
        ll sum=0;
        for(ll j=0;j<n;j++){
            if(i&(1<<j)){
                sum+=c[j];
                for(ll k=0;k<m;k++) level[k]+=a[j][k];
            }
        }
        /*
        cout<<sum<<" ";
        for(ll j=0;j<m;j++) cout<<level[j]<<" ";
        cout<<"\n";
        */
        for(ll j=0;j<m;j++) if(level[j]<x) {ok=false;break;}
        if(ok){
            //cout<<minn<<"\n";
            minn=min(minn,sum);
        }
    }
    if(minn==10000000000) cout<<-1;
    else cout<<minn;
    return(0);
}

Measured memory_bytes: 8324
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////
struct UnionFind {
	vector<int>par;

	UnionFind(int N) :par(N) {
		for (int i = 0; i < N; ++i) {
			par[i] = i;
		}
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	for (int i = 0; i < m; ++i) {
		int u, v, z;
		cin >> u >> v >> z;
		--u, --v;
		uf.unite(u, v);
	}
	set<int>par;
	for (int i = 0; i < n; ++i) {
		par.insert(uf.root(i));
	}
	cout << par.size() << endl;
	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
  	for(int i = 1;i < 10;i++){
  	  	for(int o = 1;o < 10;o++){
  	  		int res = i * o;
  			System.out.println(i + "x" + o + "=" + res);
  		}	
  	}
  }
}

Measured memory_bytes: 23816
#include <iostream>
using namespace std;
int main(void){
  for(;;){
    int n;
    cin >> n;
    if(n == 0){return 0;}
    string f[n];
    for(int i = 0 ; i < n ; i++){
      cin >> f[i];
    }
    int lstate = 0;
    int rstate = 0;
    int count  = 0;
    int next   = 1;
    for(int i = 0 ; i < n ; i++){
      if(f[i] == "lu"){
	lstate = 1;
      }else if(f[i] == "ru"){
	rstate = 1;
      }else if(f[i] == "ld"){
	lstate = 0;
      }else{
	rstate = 0;
      }
      if(lstate == next && rstate == next){
	count++;
	next = (next == 0)?(1):(0);
      }
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3132
(defvar N (read))
(defvar M (read))

(defparameter arr (make-array (1+ N) :initial-element t))

(loop repeat M do
      (setf (aref arr (read)) nil))

(loop for i from 1 to N with ci = 1 and ci-1 = 0
      do (if (aref arr i) 
             (shiftf ci-1 ci (+ ci ci-1))
             (shiftf ci-1 ci 0))
      finally (princ (mod ci 1000000007)))

Measured memory_bytes: 69984
#include <iostream>
#include <cstring>
#include <cstdio>
#define M 100010

using namespace std;

long long num[M];
long long n,a,b;

bool cheak(long long x)
{
    long long cn=a-b;
    long long gl=0;
    for(int i=0; i<n; i++)
    {
        long long re=num[i]-b*x;
        if(re<=0)
            continue;
        else
        {
            gl+=re/cn;
            gl+=(re%cn!=0);
            if(gl>x)
                return false;
        }
    }
    if(gl>x)
        return false;
    return true;
}
int main()
{
    long long l=0,r=1e9;
    long long ans=r;
    scanf("%lld%lld%lld",&n,&a,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&num[i]);
    }
    while(l<=r)
    {
        long long mid=(l+r)/2;
        if(cheak(mid))
        {
            r=mid-1;
            ans=min(mid,ans);
        }
        else
            l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] s1 = scn.nextLine().toCharArray();
		char[] s2 = scn.nextLine().toCharArray();
		int ans = 0;
		for(int i = 0;i < 3;i++) {
			if(s1[i] == s2[i])ans++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23636
n = int(input())
s = input()

A = [[0] * 10 for i in range(n)]
B = [[0] * 10 for i in range(n)]
for i in range(n):
    A[i][int(s[i])] += 1
    B[i][int(s[i])] += 1
for i in range(1,n):
    for j in range(10):
        A[i][j] += A[i-1][j]
for i in range(n-2,-1,-1):
    for j in range(10):
        B[i][j] += B[i+1][j]

C = [[[0] * 10 for i in range(10)] for j in range(10)]

for i in range(1,n-1):
    for j in range(10):
        for k in range(10):
            if A[i-1][j] > 0 and B[i+1][k] > 0:
                C[j][int(s[i])][k] = 1
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            ans += C[i][j][k]
print(ans)

Measured memory_bytes: 53468
#include <stdio.h>

int main(void) {

	int a,b;
	
	
	scanf("%d %d",&a,&b);
	
	
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}	

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

int main() {
  int a, b;
  int k;
  cin >> a >> b;
  k = a + b;
  // k_ = a + (b - a) / 2 = (a + b) / 2
  if (k % 2 == 0){
    cout << k / 2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}


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

int main() {
    ll a;
    double b;
    cin >> a >> b;
    b = b*100 + 0.5;
    ll B = (ll)b;
    cout << a*B/100 << endl;
}

Measured memory_bytes: 3692