akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <utility>
#include <cstring>

const int modulo = 1000000007;

int n;
std::pair<int,int> a[200020];
int b[200020];
std::pair<int,int> c[200020];
int d[200020];

inline void update(int &x,int y)
{
	x += y;
	x -= x >= modulo ? modulo : 0;
}

int main(void)
{
	int i,j,k;
	int x;
	
	scanf("%d",&n);
	for(i = 1;i <= n;++i)
		scanf("%d %d",&a[i].first,&a[i].second),d[i] = a[i].second;
	std::sort(d + 1,d + n + 1);
	d[0] = std::unique(d + 1,d + n + 1) - d - 1;
	for(i = 1;i <= n;++i)
		a[i].second = std::lower_bound(d + 1,d + d[0] + 1,a[i].second) - d;
	std::sort(a + 1,a + n + 1);

	c[n].first = a[n].second;
	c[1].second = a[1].second;
	for(i = 2;i <= n;++i)
		c[i].second = std::max(a[i].second,c[i - 1].second);
	for(i = n - 1;i >= 0;--i)
		c[i].first = std::min(a[i].second,c[i + 1].first);
	
	b[0] = 1;
	for(i = 1;i <= n;++i)
		update(b[i],b[i - 1] << 1);
	
	std::sort(c + 1,c + n + 1);
	d[n + 1] = 1;
	j = n;
	for(i = n;i >= 1;--i)
	{
		d[i] = 0;
		k = j;
		while(k && c[k].first == i)
			--k;
		for(x = 0,j = k++;k <= n && c[k].first == i;++x,++k)
			update(d[i],1ll * (d[i + 1] - d[c[k].second + 2] + modulo) * b[x] % modulo);
		update(d[i],d[i + 1]);
	}
	update(d[1],modulo - d[2]);
	printf("%d\n",d[1]);
	
	return 0;
}

Measured memory_bytes: 4864
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  int array[n];
  int ans[n];
  int i, j, k;
  for(i = 0; i < n; i++) {
    scanf("%d", &array[i]);
  }

  for(i = n - 1; i > n / 2; i--) {
    ans[i] = array[i];
  }

  for(i = n / 2; i >= 0; i--) {
    j = 2 * (i + 1);
    k = 0;
    while(j <= n) {
      k += ans[j - 1];
      j += i + 1;
    }
    if(k % 2 == array[i]) {
      ans[i] = 0;
    }
    else {
      ans[i] = 1;
    }
  }

  int num = 0;
  for(i = 0; i < n; i++) {
    num += ans[i];
  }

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

  for(i = 0; i < n; i++) {
    if(ans[i] == 1) {
      printf("%d ", i + 1);
    }
  }
  if(num > 0) {
    printf("\n");
  }

  return 0;
}


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

int main() {
    string a, b;
    cin >> a >> b;
    if (a[1] == b[1] && a[0] == b[2] && a[2] == b[0]) {
        cout << "YES" << endl;
    }

    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mn = min(b)
d = dd(list)
for _ in range(M):
  x, y, c = map(int, input().split())
  d[x - 1].append((y - 1, c))
res = float("inf")
for i in range(A):
  x = a[i]
  tt = mn + 0
  for t in d[i]:
    y, c = t
    tt = min(tt, b[y] - c)
  res = min(res, x + tt)
print(res)

Measured memory_bytes: 83984
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    S = input()
    temp = "114514"
    ans = "Good"
    for i in S:
        if temp == i:
            ans = "Bad" 
            break
        temp = i

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
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;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

int n,m;
int st[100010];
ll memo[100010];
ll calc(int x) {

	if (x == n) return 1;
	if (x > n) return 0;
	ll &res = memo[x];
	if (~res) return res;
	res = 0;
	if (st[x + 1] == 0) res += calc(x + 1);
	if (st[x + 2] == 0) res += calc(x + 2);
	res %= INF;
	return res;
}
void solv() {
	cin >> n >> m;
	memset(memo, -1, sizeof(memo));
	for (size_t i = 0; i < m; i++)
	{
		int v;
		cin >> v;
		st[v] = 1;
	}

	cout << calc(0) << endl;

}

int main() {
//	COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 4480
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e5 + 10;
int ans1[N], ans2[N];
piii a[N];
int rnk[N];
int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &a[i].fi.se, &a[i].fi.fi);
        a[i].se = i;
        ans1[i] = a[i].fi.se;
    }
    sort(a+1, a+1+m);
    for (int i = 1; i <= m; i++) {
        rnk[a[i].fi.se]++;
        ans2[a[i].se] = rnk[a[i].fi.se];
    }
    for (int i = 1; i <= m; i++) printf("%06d%06d\n", ans1[i], ans2[i]);
    return 0;
}


Measured memory_bytes: 3840
N,M=map(int,raw_input().split())
X=map(int,raw_input().split())

X.sort()
G=[X[i+1]-X[i] for i in range(M-1)]
G.sort()
   
if M>N:
    Ans=sum(G[i] for i in range(M-N))
else:
    Ans=0
    
print Ans

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

using namespace std;
using ll = long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> p(n);
    for(auto &a : p) cin>>a;
    int cur = p[0];
    int ret = 1;
    for(int i=1;i<n;++i){
        if(cur > p[i]){
            cur = p[i];
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1024
use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }

    pub fn tokens<T: str::FromStr>(&mut self) -> Vec<T> {
        assert!(self.buffer.is_empty());
        let mut input = String::new();
        self.reader.read_line(&mut input).expect("Failed read");
        input
            .split_whitespace()
            .map(|x| x.parse().ok().expect("Failed parse"))
            .collect()
    }
}

fn upper_bound(arr: &[i64], target: i64) -> usize {
    let n = arr.len();
    let mut lo = 0;
    let mut hi = n;
    while lo < hi {
        let mid = lo + (hi - lo) / 2;
        if arr[mid] > target {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }
    lo
}

fn maximize_length_sum(a: &[i64], b: &[i64], target: i64) -> usize {
    let na = a.len();
    let nb = b.len();

    let mut ps_b = vec![0; nb + 1];
    for i in 0..nb {
        ps_b[i + 1] = ps_b[i] + b[i];
    }

    let mut sum_a = 0;
    let mut ans = 0;
    for i in 0..=na {
        if target - sum_a >= 0 {
            let ub = upper_bound(&ps_b, target - sum_a);
            ans = ans.max(i + ub - 1);
        }
        if i < na {
            sum_a += a[i];
        }
    }
    ans
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let _: usize = scan.token();
    let _: usize = scan.token();
    let k: i64 = scan.token();
    let a: Vec<i64> = scan.tokens();
    let b: Vec<i64> = scan.tokens();

    let ans = maximize_length_sum(&a, &b, k);

    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


Measured memory_bytes: 7512
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<ll, ll>;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n, ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2, mod) % mod);
	else
		return (x * pow(x, n - 1, mod) % mod);
}ll zero = 0;
signed main() {
	ll a, b,k; cin >> a >> b >> k;
	cout << max(zero, a - k) << " " << max(zero, b -(max(zero,k-a))) << endl;
}


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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int N;
vl a;
vector<vector<pair<ll, ll>>> dp;

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

    cin>>N;
    a.resize(N);
    fo(i,N)cin>>a[i];
    dp.resize(N+1, vector<pair<ll, ll>>(N+1));
    fo(i,N){
        if((N-1)%2)dp[i+1][i+1] = make_pair(0, a[i]);
        else dp[i+1][i+1] = make_pair(a[i], 0);
    }
    Fo(len, 2, N+1){
        for(int l=1; l+len-1<=N; l++){
            int r=l+len-1;
            if((N-len)%2){
                dp[l][r] = (dp[l][r-1].second+a[r-1])>(dp[l+1][r].second+a[l-1]) ? make_pair(dp[l][r-1].first, dp[l][r-1].second+a[r-1]) : make_pair(dp[l+1][r].first, dp[l+1][r].second+a[l-1]);
            }else{
                dp[l][r] = (dp[l][r-1].first+a[r-1])>(dp[l+1][r].first+a[l-1]) ? make_pair(dp[l][r-1].first+a[r-1], dp[l][r-1].second) : make_pair(dp[l+1][r].first+a[l-1], dp[l+1][r].second);
            }
        }
    }
    cout<<dp[1][N].first-dp[1][N].second<<endl;
    
    return 0;
}

Measured memory_bytes: 141184
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, long long M, long long X, long long Y, std::vector<long long> x, std::vector<long long> y){
    sort(x.begin(), x.end(), greater<long long>());
    sort(y.begin(), y.end());
    if (x[0] >= y[0] || x[0] >= Y || y[0] <= X) cout << "War" << '\n';
    else cout << "No War" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&y[i]);
    }
    solve(N, M, X, Y, std::move(x), std::move(y));
    return 0;
}


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

ans=0
for i in range(n-2):
    if p[i]<p[i+1] and p[i+1]<p[i+2]:
        ans+=1
    elif p[i]>p[i+1] and p[i+1]>p[i+2]:
        ans+=1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int d[10000];
int main()
{
	int T,N,A,B,C;
	int maxk=0;
	int K;	//????????????
	int M;	//??????
	cin >> N;
	cin >> A >> B;
	cin >> C;
	K = C;
	M = A;
	
	for(int i=0;i<N;i++)
		cin >> d[i];
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			if(d[i] < d[j]){
				T = d[i];
				d[i] = d[j];
				d[j] = T;
			}
		}
	}
	
	maxk = K / M;
	for(int i=0;i<N;i++){
		K += d[i];
		M += B; 
		if(maxk < K/M)
			maxk = K/M;
	}
	cout << maxk << endl;
	return 0;
}

Measured memory_bytes: 3088
package main

import (
	"fmt"
)

type Node struct {
	Id int
	Left int
	Right int
	Parent int
}

func main() {
	var n int
	fmt.Scan(&n)

	nodes := make([]Node, n)
	for i := 0; i < n; i++ {
		nodes[i].Parent = -1
	}
	
	for i := 0; i < n; i++ {
		var id int
		fmt.Scan(&id)
		nodes[id].Id = id
		fmt.Scan(&nodes[id].Left)
		fmt.Scan(&nodes[id].Right)

		if nodes[id].Left >= 0 {
			nodes[nodes[id].Left].Parent = nodes[id].Id
		}
		if nodes[id].Right >= 0 {
			nodes[nodes[id].Right].Parent = nodes[id].Id
		}
	}

	parent := -1
	for i := 0; i < n; i++ {
		if nodes[i].Parent == -1 {
			parent = nodes[i].Id
		}
	}
	fmt.Println("Preorder")
	printPreorder(&nodes, parent)
	fmt.Println()

	fmt.Println("Inorder")
	printInorder(&nodes, parent)
	fmt.Println()
	
	fmt.Println("Postorder")
	printPostorder(&nodes, parent)
	fmt.Println()
}

func printPreorder(nodes *[]Node, id int) {
	if id < 0 {
		return
	}
	fmt.Printf(" %d", id)
	printPreorder(nodes, (*nodes)[id].Left)
	printPreorder(nodes, (*nodes)[id].Right)
}

func printInorder(nodes *[]Node, id int) {
	if id < 0 {
		return
	}
	printInorder(nodes, (*nodes)[id].Left)
	fmt.Printf(" %d", id)
	printInorder(nodes, (*nodes)[id].Right)
}

func printPostorder(nodes *[]Node, id int) {
	if id < 0 {
		return
	}
	printPostorder(nodes, (*nodes)[id].Left)
	printPostorder(nodes, (*nodes)[id].Right)
	fmt.Printf(" %d", id)
}



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

//a== 0のときが問題

int main() {
    unsigned long long a, b, x;
    cin >> a >> b >> x;
    if (a == 0) {
        cout << (b/x+1) << endl;
        return 0;
    }
    else;
        cout << (b/x - (a-1)/x) << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){

	int d;

	while(std::cin >> d){
		
		int squ;
		int sum_heights = 0;

		for(int i = 0; i < 600; i = i + d){
			sum_heights = sum_heights + (i * i);
		}

		squ = d * sum_heights;

		std::cout << squ << std::endl;
	}

	return 0;
}

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

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

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

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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        t: f64,
        x: f64,
    }

    println!("{}", t / x);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  if (a==25){
    cout << "Christmas" << endl;
  }else if (a==24){
    cout << "Christmas Eve" << endl;
  }else if (a==23){
    cout << "Christmas Eve Eve" << endl;
  }else{
    cout << "Christmas Eve Eve Eve" << endl;
  }


  
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

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

  vector<int> p(n);
  rep(i, n) cin >> p[i];

  sort(p.begin(), p.end());
  int sum = 0;
  rep(i, k) { sum += p[i]; }
  cout << sum;
  return 0;
}


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

using namespace std;
using ll = long long;
#define REP(i,N) for(ll i=0;i<N;++i)

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N+1,0);
	REP(i,N) cin >> A[i+1];// 1-origin
	// sum_i abs(A[i] - b - i) を最小にする
	vector<ll> X(N);
	REP(i,N) X[i] = A[i+1] - (i+1);
	// sum_i abs(X[i] - b) を最小にする.
	// Xの"中心"にbを置けばよい.
	sort(X.begin(), X.end());// ascending order
	ll sum = 0;
	ll b = X[N/2];
	REP(i,N) sum += abs(X[i]-b);
	// Nが偶数の場合, どちらが最小化調べる
	if (N % 2 == 0) {
		ll temp = 0;
		b = X[N/2-1];
		REP(i,N) temp += abs(X[i]-b);
		sum = min(sum, temp);
	}
	cout << sum << endl;
	return 0;
}



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

int main()
{
    int x;
    cin >> x;
    int d = 0;
    int n = x;
    while (n > 0) {
        d += n % 10;
        n /= 10;
    }
    if (x % d == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
int main() {
string S;
	cin>>S;
	if(S=="Sunny"){
		cout<<"Cloudy"<<endl;
	}else if(S=="Cloudy"){
		cout<<"Rainy"<<endl;
	}else{
		cout<<"Sunny"<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
package main
import (
    "fmt"
    "sort"
)
func main(){
    var n int
    fmt.Scan(&n)
    city := map[string][]int{}
    citys := []string{}
    score  := [100]int{}
    for i:=0;i<n;i++{
        var sco int
        var str string
        fmt.Scan(&str, &sco)
        if len(city[str]) == 0 {
            citys = append(citys, str)   
        }
        city[str] = append(city[str], i)
        score[i] = sco
    }
    sort.Strings(citys)
    for _, val := range citys {
        scores := []int{}
        for _, va := range city[val]{
            scores = append(scores ,score[va])
        }
        for i, now, index, k :=0, scores[0], city[val][0], 0; i < len(scores);i++{
            for j:=1;j<len(scores);j++{
                if now < scores[j]{
                    now = scores[j]
                    index = city[val][j]
                    k = j
                }
            }
            fmt.Println(index+1)
            scores[k], index = -1, city[val][0]
            now, k = scores[0], 0
        }
    }
    
}


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

using namespace std;

int main()
{
  int n, t;
  cin >> n >> t;
  vector<int> tt(n);
  for (int i = 0; i < n; i++)
    cin >> tt[i];
  int ans = t;
  for (int i = 0; i < n - 1; i++)
    ans += min(t, tt[i + 1] - tt[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  vector<int> c(26);
  rep(i,0,25) cin >> c[i];

  vector<vector<int>> s(D);
  rep(i,0,D-1) {
    vector<int> tmp(26);
    rep(j,0,25) cin >> tmp[j];
    s[i] = tmp;
  }

  vector<int> t(D);
  rep(i,0,D-1) cin >> t[i];

  int score = 0;
  map<int, int> last;
  rep(i,0,D-1) {
    int C = 0;
    rep(j,1,26) {
      if (t[i] == j) last[j] = 0;
      else last[j]++;
      C += c[j-1] * last[j];
    }
    score -= C;
    score += s[i][t[i]-1];
    cout << score << endl;
  }

  return 0;
}


Measured memory_bytes: 3652
N = int(input())
a_list = list(map(int, input().split()))

mon = 1000
stock = 0

lim_a = [a_list[0]]
for i in range(1, N-1):
    if lim_a[-1] == a_list[i]:
        continue
    if a_list[i] <= a_list[i+1] and a_list[i] <= a_list[i-1]:
        lim_a.append(a_list[i])
    elif a_list[i] >= a_list[i+1] and a_list[i] >= a_list[i-1]:
        lim_a.append(a_list[i])

if len(lim_a) >= 2:
    if lim_a[-2] <= lim_a[-1] <= a_list[-1]:
        lim_a[-1] = a_list[-1]
    elif lim_a[-2] >= lim_a[-1] >= a_list[-1]:
        lim_a[-1] = a_list[-1]
    else:
        lim_a.append(a_list[-1])
else:
    lim_a.append(a_list[-1])


for i in range(1, len(lim_a)):
    if lim_a[i-1] <= lim_a[i]:
        stock = mon // lim_a[i-1]
        mon += stock*(lim_a[i] - lim_a[i-1])
    
print(max(mon, 1000))



Measured memory_bytes: 9244
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int n;
Int a[108000];
Int b[108000];
Int ans, need;
Int suma, sumb;
vector<int> pplus;
int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    suma += a[i];
  }
  
  for(int i = 0;i < n;i++){
    cin >> b[i];
    sumb += b[i];
    if(a[i] < b[i]){
      need += b[i] - a[i];
      ans++;
    }
    else{
    pplus.push_back(a[i] - b[i]);
    }
  }

  if(suma < sumb){
    cout << -1 << endl;
    return 0;
  }

  sort(pplus.begin(), pplus.end());

  while(need){
    need -= pplus.back();
    need = max(need, 0);
    pplus.pop_back();
    ans++;
  }
  cout << ans << endl;  
  return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
 
#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
 
using namespace std;
const int N=2e5+1, mod= 1e9+7;

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

	int n;
	cin>>n;
	cout<<n/2-!(n&1);
	
    yogeshk972();
}


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

int main()
{
	long N;
	std::cin >> N;
	std::vector<long> v( N );

	long negCounter = 0;
	for ( long i = 0; i < N; i++ )
	{
		std::cin >> v[i];
		if ( v[i] <= 0 )
		{
			++negCounter;	//	負の値（と0）の個数をカウントしておく
		}
	}

	// 絶対値に変換した入力列を作る
	std::vector<long> vv( N );
	for ( int i = 0; i < v.size(); i++ )
	{
		if ( v[i] <= 0 )
		{
			vv[i] = -v[i];
		}
		else
		{
			vv[i] = v[i];
		}
	}

	long long result = 0;
	if ( negCounter % 2 )
	{
		// 負の値が奇数個なら、どこかが必ず負の値として残ってしまう
		// 入力の絶対値を昇順ソートして、一番小さいものだけを負の数にする
		std::sort( vv.begin(), vv.end() );

		for ( auto &&it : vv )
		{
			result += it;
		}

		// 先頭要素だけ減算する
		result -= vv[0] * 2;	//	1回余分に足してるので
	}
	else
	{
		// 負の値が偶数個なら、全部正の数にできるので、入力の絶対値を足して終わり
		for ( auto &&it : vv )
		{
			result += it;
		}
	}

	std::cout << result << std::endl;

	return ( 0 );
}


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

using namespace std;

long long int dp[3005][3005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0 ; i < n ; i++)
		cin >> a[i];
 	for (int L = n ; L >= 0 ; L--)
 	{
 		for (int R = L ; R < n ; R++)
 		{
 			if (L == R)
 				dp[L][R] = a[L];
 			else
 				dp[L][R] = max(a[L] - dp[L+1][R], a[R] - dp[L][R-1]);			
 		}		
 	}
	cout << dp[0][n-1] << "\n" ;
	return 0;
}

/*
 	My thoughts and explained for this problem:
 	There is an O(n) solution for this problem in Looking for a challenge problem Termites
    Example for the test case:
    3
    10 80 90
	Answer will be dp[0][2]
	dp[0][2] = max (10 - dp[1][2], 90 - dp[0][1])
	dp[1][2] = max (80 - dp[2][2], 90 - dp[1][1])
	dp[0][1] = max (10 - dp[1][1], 80 - dp[0][0])
	=> dp[0][1] and dp[1][2] must be calculated first => We should loop backward 
 */

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

struct node
{
    int parent = -1;
    int right = -1; // 右隣の兄弟のid
    int left = -1;  // 一番左の子
    int depth = 0;
};

void printNodes(vector<node> &T, int u)
{
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << T[u].depth << ", ";
    if (T[u].parent == -1)
    {
        cout << "root, ";
    }
    else if (T[u].left == -1)
    {
        cout << "leaf, ";
    }
    else
    {
        cout << "internal node, ";
    }
    cout << "[";
    int i, c;
    for (i = 0, c = T[u].left; c != -1; i++, c = T[c].right)
    {
        if (i)
        {
            cout << ", ";
        }
        cout << c;
    }
    cout << "]" << endl;
}

void calcDepth(vector<node> &T, int u)
{
    int child = T[u].left;
    while (child != -1)
    {
        T[child].depth = T[u].depth + 1;
        calcDepth(T, child);
        child = T[child].right;
    }
}

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

    vector<node> T(n);
    int id, degree;
    for (int i = 0; i < n; i++)
    {
        cin >> id >> degree;
        int child_id, now_child;
        for (int j = 0; j < degree; j++)
        {
            cin >> child_id;
            if (j == 0)
            {
                T[id].left = child_id;
            }
            else
            {
                T[now_child].right = child_id;
            }
            now_child = child_id;
            T[child_id].parent = id;
        }
    }

    // check root id
    int root_id;
    for (int i = 0; i < n; i++)
    {
        if (T[i].parent == -1)
        {
            root_id = i;
            break;
        }
    }

    calcDepth(T, root_id);

    for (int i = 0; i < n; i++)
    {
        printNodes(T, i);
    }

    return 0;
}


Measured memory_bytes: 4408
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
import fractions
A,B = map(int,input().split())
if A == 1 or B == 1:
    print(1)
else:
    def factorization(n): #2以上の整数n => [[素因数, 指数], ...]の2次元リストを返す
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
        if temp!=1:
            arr.append([temp, 1])
        if arr==[]:
            arr.append([n, 1])
        return arr
    c = fractions.gcd(A,B)
    arr = factorization(c)
    print(len(arr)+1)

Measured memory_bytes: 5048
S = input()
N = len(S)-1

total = 0
for i in range(2**N):
    sign = [""] * N
    for j in range(N):
        if ((i >> j) & 1):
            sign[j] = "+"
    
    formula = ""
    for k in range(N):
        formula += S[k] + sign[k]
    formula += S[N]
    total += eval(formula)
print(total)
    
    


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

long long a[200010], b[200010];

int main(){
	int n; scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < n; i++){
		scanf("%lld", &b[i]);
	}
	int ans = 0;
	for (int k = 0; k < 29; k++){
		vector <int> v;
		for (int i = 0; i < n; i++){
			v.push_back(b[i] & ((1 << k + 1) - 1));
		}
		sort(v.begin(), v.end());
		long long tot = 0;
		for (int i = 0; i < n; i++){
			int x = a[i] & ((1 << k + 1) - 1);
			int pos1 = lower_bound(v.begin(), v.end(), (1 << k) - x) - v.begin();
			int pos2 = lower_bound(v.begin(), v.end(), 2 * (1 << k) - x) - v.begin();
			int pos3 = lower_bound(v.begin(), v.end(), 3 * (1 << k) - x) - v.begin();
			int pos4 = lower_bound(v.begin(), v.end(), 4 * (1 << k) - x) - v.begin();
			tot += pos2 - pos1 + pos4 - pos3;
		}
		if (tot & 1) ans += 1 << k;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 5232
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  
    n,c,k = map(int,input().split())
    t=[]
    for i in range(n):
        t.append(int(input()))
    t.sort()
    ans=1
    x=[0,t[0]+k]
    for i in range(n):
        if x[0]==c:
            ans+=1
            x=[1,t[i]+k]
        elif t[i]<=x[1]:
            x[0]+=1
            if x[1]>t[i]+k:
                x[1]=t[i]+k
        else:
            ans+=1
            x=[1,t[i]+k]
    print(ans)
main()

Measured memory_bytes: 50520
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,n;
  cin>>a;
  cin>>n;
  int flag=0;
  for(int i=0;i<=a;i++)
  {
    int temp=(2*i)+((a-i)*4);
    if(temp==n)
    {
      flag=1;
      break;
    }
  }
  if(flag==0)
    cout<<"No";
  else
    cout<<"Yes";
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main(void){
  ll  a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ma = max(a*c,b*d);
  ma = max(ma,a*d);
  ma = max(ma,b*c);
  cout << ma;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    ll N;
    cin >> N;
    vector<ll>A(N);
    for (int i=0; i<N; i++)cin >> A[i];
    ll money = 1000;
    for (int i=0; i<N-1; i++){
        ll stocks = 0;
        if (A[i+1] > A[i]){
            stocks = money / A[i];
        }
        money += stocks*(A[i+1] - A[i]);
    }
    //最終日に下がる場合を考える必要がありそう
    cout << money << endl;
}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var W, H, x, y float64
	fmt.Scan(&W, &H, &x, &y)

	ans := W * H / 2
	e := 0
	if x*2 == W && y*2 == H {
		e = 1
	}

	fmt.Printf("%f %d\n", ans, e)
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main () {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (r <= x && x <= W - r && r <= y && y <= H - r) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }   
    return 0;
}

Measured memory_bytes: 1160
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string n;cin>>n;
  ll sum=0;
  if(n=="10"||n=="100"||n=="1000"||n=="10000"||n=="100000"){
    cout<<10<<endl;
    return 0;
  }
  rep(i,n.size())sum+=n[i]-'0';
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    if (s.size() == 3) {
        reverse(s.begin(), s.end());
    }

    cout << s << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int w,num,count,sum,a[600];
    while(cin>>w){
       num=600/w;
       count=0;
       sum=0;
       for(int i=0;i<=600;i+=w){
          a[count++]=w*i*i;        
       }
       for(int i=0;i<num;i++){
          sum+=a[i];        
       }
       cout<<sum<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#define PI acos(-1)
#define fs first
#define sc second
#define debug freopen("1.in","r",stdin),freopen("1.out","w",stdout);
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll maxn = 1e6 + 10;

int arr[30][maxn], n, res, T, test;
string s;
int cnt, l , r;
int lbt(int x) {
    return x & -x;
}
int xxxx(int x,int a[]) {
    res = 0;
    for(int i = x;i >= 1;i -= lbt(i))
        res += a[i];
    return res;
}
void date(int tmp,int tmpp,int a[]) {
    for(int i = tmp;i <= n; i += lbt(i)) 
		a[i] += tmpp;
}

int main() {
    ios;
    cin >> n;
    cin >> s;
    for(int i = 0;i < n; ++i) 
		date(i + 1,1,arr[s[i] - 'a']);
	cin >> T;
    while(T --) {
    	cnt = 0;
        cin >> test;
        if(test == 1) {
            int i;
            char c;
            cin >> i >> c;
            date(i, -1, arr[s[i - 1] - 'a']);
            date(i, 1, arr[c - 'a']);
			s[i - 1] = c;
        }
        else {
            cin >> l >> r;
            for(int i = 0;i < 26; i ++) 
                if(xxxx(r, arr[i]) - xxxx(l - 1, arr[i]) > 0)
					cnt ++;
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 101148
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

odd = 0
even = 0
for a in A:
	if a%2 == 1:
		odd += 1
	else:
		even += 1

if (even == 0 and odd == 1) or odd%2 == 0:
	print("YES")
else:
	print("NO")


Measured memory_bytes: 16944
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	bool a[3]={true};
	char x,y;
	while(cin>>x){
		cin.ignore();
		cin>>y;
		swap(a[x-'A'],a[y-'A']);
	}
	cout<<(char)(find(a,a+3,true)-a+'A')<<endl;
	return 0;
}

Measured memory_bytes: 1132
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int i, j = 0, X, Y, a = 0;
	string s;
	cin >> s >> X >> Y;
	vector<int> x, y;
	for (i = 0; i <= s.size(); i++) {
		if (i == s.size() || s[i] == 'T') {
			if (j & 1)
				y.push_back(a);
			else
				x.push_back(a);
			a = 0;
			j++;
		}
		else
			a++;
	}
	X = -abs(X - x[0]);
	Y = -abs(Y);
	vector<vector<int>> dpx(x.size() + 1, vector<int>(s.size() + 1, false)), dpy(y.size() + 1, vector<int>(s.size() + 1, false));
	dpx[1][0] = true;
	dpy[0][0] = true;
	for (i = 1; i < x.size(); i++) {
		for (j = 0; j <= s.size(); j++) {
			if (dpx[i][j]) {
				dpx[i + 1][j] = true;
				if (j + x[i] <= s.size())
					dpx[i + 1][j + x[i]] = true;
			}
		}
		X += x[i];
	}
	for (i = 0; i < y.size(); i++) {
		for (j = 0; j <= s.size(); j++) {
			if (dpy[i][j]) {
				dpy[i + 1][j] = true;
				if (j + y[i] <= s.size())
					dpy[i + 1][j + y[i]] = true;
			}
		}
		Y += y[i];
	}
	if (X < 0 || Y < 0)
		printf("No\n");
	else if (!(X & 1) && !(Y & 1) && dpx[x.size()][X >> 1] && dpy[y.size()][Y >> 1])
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

const vector<pair<ll, ll>> lis = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int main(void) {
    ll H, W;
    ll maxi = 0;
    vector<string> A;
    vector<vector<ll>> D;
    queue<pair<ll, ll>> Q;
    cin >> H >> W;
    A.resize(H);
    D.resize(H, vector<ll>(W));
    rep(h, H) {
        cin >> A[h];
        rep(w, W) if(A[h][w] == '#') Q.emplace(h, w);
    }
    while(!Q.empty()) {
        auto current = Q.front();
        Q.pop();
        iter(i, lis) {
            auto next = i;
            next.first += current.first;
            next.second += current.second;
            if(0 > next.first || H <= next.first || 0 > next.second || W <= next.second) continue;
            if(A[next.first][next.second] == '.') {
                D[next.first][next.second] = D[current.first][current.second] + 1;
                A[next.first][next.second] = '#';
                Q.push(next);
            }
        }
    }
    rep(h, H) rep(w, W) maxi = max(maxi, D[h][w]);
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 25524
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int n, m; cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005,mod=998244353;
int n,k,l[N],r[N],dp[N]={1},s[N]={1};
int main()
{
	scanf("%d%d",&n,&k);
	n--;
	for(int i=1;i<=k;i++)
		scanf("%d%d",&l[i],&r[i]);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(l[j]>i)
				continue;
			int x=max(0,i-r[j]),y=i-l[j];
			int v=(s[y]+mod-s[x-1])%mod;
			dp[i]=(dp[i]+v)%mod;
		}
		s[i]=(s[i-1]+dp[i])%mod;
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 5328
max_num = 1000000
min_num = -1000000
k,x = map(int, input().split())
if x + k > 1000000:
    min_num = x - k + 1
elif x - k < -1000000:
    max_num = x + k - 1
else:
    min_num = x - k + 1
    max_num = x + k - 1

ans = ""
for i in range( min_num, max_num + 1 ):
    ans = ans + str(i) + " "

print( ans )


Measured memory_bytes: 38412
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;

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

    vector<int> osr;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W') osr.push_back(1);
        else osr.push_back(0);
    }
    int ct=0;
    ll ans=0;
    for(int i=0;i<s.size();i++){
        if(osr[i]==1){
            ans+=i-ct;
            ct++;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n, k, cnt = 0; string s; cin >> n >> k >> s;
    for (auto i = 1; i < n; i++) if (s[i] != s[i - 1]) cnt++;
    cout << min(n - cnt + 2 * k - 1, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 3704
def solve():
  k, a, b = map(int, input().split())

  # 交換しても得しない、地道に増やす
  if b - a <= 2: return 1 + k

  # 交換できる数まで増えずに終了 (終了2回前にa個に到達していること)
  if 1 + (k - 2) < a: return 1 + k

  # 交換できる数まで増えたら、交換し続ける
  # 最初1個あるので a-1 回で最初の交換可能へ到達
  # k-(a-1)//2 回は交換できて、毎回 b-a が増える
  exchange_times, last = divmod(k-(a-1), 2)
  profit = b - a
  ans = a + exchange_times * profit + last
  return ans

ans = solve()
print(ans)

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

int main() {
  
  int  n;
  long d;
  cin >> n >> d;
  long dd = d*d;
  int total = 0;
  
  for (int i = 0; i < n; i++){
    
    long x, y;
    cin >> x >> y;
    
    long aa = (x*x) + (y*y);
    if(aa <= dd){
      total += 1;
    }
    
  }
  
  cout << total << endl;

  
}

Measured memory_bytes: 3604
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool mainmain(){
	vint v(3);
	string s;
	cin>>s;
	rep(i,s.size()){
		v[s[i]-'a']++;
	}
	sort(ALL(v));
	if(v[0]){
		return v[2]-v[0]<=1;
	}
	else{
		return v[2]==1;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    cout<<(mainmain()?"YES":"NO")<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    bool t=true;
    vector<int>v;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);
    }
    for(int i=0;i<n-1;i++)
    {
        if(v[i]<v[i+1])
        {
            v[i+1]=v[i+1]-1;
        }
    }
    for(int i=0;i<n-1;i++)
    {
        if(v[i]>v[i+1])
        {
            t=false;
        }
    }
    if(t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 892