akhauriyash/Code-Regression huggingface dataset:
#![allow(unused)]

use std::{cell, cmp, collections, fmt, ops};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use fmt::{Debug, Display};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        _input_inner!(iter, $($r)*)
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        _input_inner!(iter, $($r)*)
    };
}

macro_rules! _input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = _read_value!($iter, $t);
        _input_inner!($iter $($r)*)
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = _read_value!($iter, $t);
        _input_inner!($iter $($r)*)
    };
}

macro_rules! _read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(_read_value!($iter, $t)),* )
    };

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

    ($iter:expr, chars) => {
        _read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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

#[cfg(feature = "debug")]
macro_rules! d {
    ($val:expr) => {
        match $val {
            tmp => {
                eprintln!("[{}] {} = {:#?}", line!(), stringify!($val), &tmp);
                tmp
            }
        }
    };
}

#[cfg(not(feature = "debug"))]
macro_rules! d {
    ($val:expr) => {
        $val
    };
}

mod num {
    //
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

mod bits {
    pub fn is_high(bits: u64, pos: u64) -> bool {
        bits & (1 << pos) != 0
    }

    /// len(0b1010) = 4
    /// len(0b1) = 1
    /// len(0b0) = 0
    pub fn len(bits: u64) -> usize {
        for b in 0..64 {
            if is_high(bits, 63 - b) {
                return (64 - b) as usize;
            }
        }

        return 0;
    }
}

fn main() {
    input!(n: usize, hps: [i32; n]);
    println!("{:?}", gcd_list(&hps));
}

fn gcd(a: i32, b: i32) -> i32 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn gcd_list(a: &[i32]) -> i32 {
    a.iter().fold(a[0], |a, b| gcd(a, *b))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	s := nextStr()
	m := map[string]int{}
	for i := 0; i < len(s); i++ {
		m[string(s[i])] = 1
	}

	if m["E"] != m["W"] {
		fmt.Println("No")
		return
	}
	if m["S"] != m["N"] {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
	return
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> F(H);
    for (int i = 0; i < H; i++)
        cin >> F[i];

    vector<vector<int>> L(H, vector<int>(W)), R(H, vector<int>(W)), U(H, vector<int>(W)), D(H, vector<int>(W));

    for (int i = 0; i < H; i++) {
        int cnt = 0;
        for (int j = 0; j < W; j++) {
            if (F[i][j] == '#') cnt = 0;
            else cnt++;
            L[i][j] = cnt;
        }
    }

    for (int i = 0; i < H; i++) {
        int cnt = 0;
        for (int j = W - 1; j >= 0; j--) {
            if (F[i][j] == '#') cnt = 0;
            else cnt++;
            R[i][j] = cnt;
        }
    }

    for (int j = 0; j < W; j++) {
        int cnt = 0;
        for (int i = 0; i < H; i++) {
            if (F[i][j] == '#') cnt = 0;
            else cnt++;
            U[i][j] = cnt;
        }
    }

    for (int j = 0; j < W; j++) {
        int cnt = 0;
        for (int i = H - 1; i >= 0; i--) {
            if (F[i][j] == '#') cnt = 0;
            else cnt++;
            D[i][j] = cnt;
        }
    }

    int res = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 67200
# -*- coding: utf-8 -*-

N = int(input())
W = list(map(int, input().split()))

s1 = 0
s2 = sum(W)
for w in W:
    former_sub = abs(s1 - s2)
    s1 += w
    s2 -= w
    new_sub = abs(s1 - s2)
    if former_sub <= new_sub:
        print(former_sub)
        break


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

class Node {
public:
  int value;
  Node *parent;
  Node *left;
  Node *right;
  Node (int value) {
    this->value = value;
    this->parent = NULL;
    this->left = NULL;
    this->right = NULL;
  }
};

Node *insert(Node *root, Node *toInsert) {
  Node *parent = NULL;
  Node *current = root;
  while (current != NULL) {
    parent = current;
    if (toInsert->value < current->value)
      current = current->left;
    else
      current = current->right;
  }
  toInsert->parent = parent;
  if (parent == NULL) {
    root = toInsert;
  }
  else if (toInsert->value < parent->value)
    parent->left = toInsert;
  else
    parent->right = toInsert;
  return root;
}

void printInorder(Node *current) {
  if (current != NULL) {
    printInorder(current->left);
    cout << ' ' << current->value;
    printInorder(current->right);
  }
  return;
}

void printPreorder(Node *current) {
  if (current != NULL) {
    cout << ' ' << current->value;
    printPreorder(current->left);
    printPreorder(current->right);
  }
  return;
}

void find(Node *current, int value) {
  if (current == NULL) {
    cout << "no" << endl;
    return;
  }
  if (current->value == value) {
    cout << "yes" << endl;
    return;
  }
  if (value < current->value)
    find(current->left, value);
  else
    find(current->right, value);
  return;
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  Node *root = NULL;
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    string holder;
    cin >> holder;
    if (holder == "print") {
      printInorder(root);
      cout << endl;
      printPreorder(root);
      cout << endl;
    } else if (holder == "find") {
      int value;
      cin >> value;
      find(root, value);
    } else {
      int value;
      cin >> value;
      root = insert(root, new Node(value));
    }
  }
  return 0;
}



Measured memory_bytes: 22016
def check(word):
    l = 0
    step = 0
    for w in word:
        l += len(w)
        if step == 0 or step == 2:
            if l == 5:
                step += 1
                l = 0
            elif l > 5:
                return False
        elif step == 1 or step == 3:
            if l == 7:
                step += 1
                l = 0
            elif l > 7:
                return False
        elif step == 4:
            if l == 7:
                return True
    return False


while 1:
    n = int(input())
    if n == 0:
        break

    word = []
    for _ in range(n):
        word.append(input())

    cnt = 0
    while word != []:
        cnt += 1
        if check(word):
            break
        word.pop(0)

    print(cnt)



Measured memory_bytes: 5604
from collections import deque


def main():
    sequence = [e for e in input().split(' ')]
    stack = deque()
    for e in sequence:
        if '+' == e:
            a = stack.pop()
            b = stack.pop()
            stack.append(a + b)
        elif '-' == e:
            a = stack.pop()
            b = stack.pop()
            stack.append(b - a)
        elif '*' == e:
            a = stack.pop()
            b = stack.pop()
            stack.append(a * b)
        else:
            stack.append(int(e))
    print(stack.pop())


if __name__ == '__main__':
    main()



Measured memory_bytes: 6008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

vector<int> tate;
vector<int> yoko;

bool dpTate[10000][20000];
bool dpYoko[10000][20000];

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

  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;

  int isTate = false;
  int len = 0;
  rep(i, s.size()) {
    if (s[i] == 'F') {
      len++;
    } else {
      if (isTate) {
        tate.push_back(len);
      } else {
        yoko.push_back(len);
      }
      len = 0;
      isTate = !isTate;
    }
  }
  if (isTate) {
    tate.push_back(len);
  } else {
    yoko.push_back(len);
  }

  dpTate[0][10000] = true;
  dpYoko[0][10000] = true;

  rep(i, tate.size()) {
    rep(j, 20000) {
      if (dpTate[i][j]) {
        dpTate[i+1][j+tate[i]] = true;
        dpTate[i+1][j-tate[i]] = true;
      }
    }
  }

  rep(i, yoko.size()) {
    rep(j, 20000) {
      if (dpYoko[i][j]) {
        dpYoko[i+1][j+yoko[i]] = true;
        if (i != 0) {
          dpYoko[i+1][j-yoko[i]] = true;
        }
      }
    }
  }

  cout << (dpTate[tate.size()][10000+y] && dpYoko[yoko.size()][10000+x]?"Yes":"No") << endl;
}

Measured memory_bytes: 156416
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 100000000000000000;

int main() {
  int n,k;
  cin>>n>>k;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  ll dp[n];
  dp[0]=0;
  for(int i=1;i<n;i++) {
    dp[i]=MAX;
  	for(int j=i-1;j>=i-k && j>=0;j--) {
    	dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
  }
  cout<<dp[n-1]<<endl;
}
  

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
using namespace std;
int k;
bool isgood(int n,int d[])
{
	int dig;
	while(n!=0)
	{
		dig=n%10;
		n=n/10;
		for(int i=0;i<k;i++)
			if(dig==d[i])
				return false;
	}
	return true;
}

int main()
{
	int n;
	scanf("%d%d",&n,&k);
	int d[k];
	for(int i=0;i<k;i++)
		scanf("%d",&d[i]);
	while(!isgood(n,d))
		n++;
	printf("%d",n);
	return 0;
	
}

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

int main(){
  
  int n, x, m[100], mi = 10000, ans = 0;
  
  cin >> n >> x;
  ans = n;
  for(int i = 0;i < n;i++){
    cin >> m[i];
    mi = min(mi, m[i]);
    x -= m[i];
  }
  
  ans += x / mi;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $n, $m, $x);

$books = array();
for ($i=0; $i < $n; $i++) {
  $book = explode(' ', trim(fgets(STDIN)));
  $books[] = $book;
}

$ans = 10000000;
dfs(array());
if ($ans == 10000000) {
  echo -1;
} else {
  echo $ans;
}

function dfs($bag)
{
  global $n;
  if (count($bag) == $n) {
    $cost = 10000000;
    $koumoku = array();
    foreach ($bag as $k => $bool) {
      if ($bool) {
        global $books;
        foreach ($books[$k] as $key => $value) {
          if ($key == 0) {
            if ($cost == 10000000) {
              $cost = $value;
            } else {
              $cost += $value;
            }
            continue;
          }
          if (isset($koumoku[$key])) {
            $koumoku[$key] += $value;
          } else {
            $koumoku[$key] = $value;
          }
        }
      }
    }

    global $x;
    $bool = true;
    foreach ($koumoku as $key => $value) {
      if ($value < $x) {
        $bool = false;
      }
    }

    if ($bool) {
      global $ans;
      $ans = min($ans, $cost);
    }

    return;
  }

  $bag[] = 0;
  while($bag[count($bag)-1] <= 1) {
    dfs($bag);
    $bag[count($bag)-1]++;
  }
}


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //cout << "Fi Amanillah" << endl;

    int n,k;
    cin >> n >> k;

    vector < ll >v(n);
    f0(i,n){
        cin >> v[i];
    }

    sort(all(v));

    ll ans = MOD;
    //10 11 12 14 15
    for(int i= 0 ; (i+k-1)<n ; i++){
        //cout << v[i] << " " << v[i+k-1];
        ans = min(ans , v[i+k-1]-v[i]);
    }

    cout << ans << endl;



    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int n,x,cnt;
int a[105];
main(){
    cin>>n>>x;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0; i<n;i++){
        if(a[i]>x){
            cout<<cnt<<endl;
            return 0;
        }
        x-=a[i];
        cnt++;
    }
    cout<<(x>0?cnt-1:cnt)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define inf 100000000000000000
#define llint long long

using namespace std;

llint N, K;
llint a[100005];
llint asum;

int main(void)
{
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> a[i];
		if(a[i] >= 0) asum += a[i];
	}
	
	llint sum, ans = -inf;
	llint psum = 0, nsum = 0;
	for(int i = 0; i < K; i++){
		if(a[i] >= 0) psum += a[i];
		else nsum += a[i];
	}
	for(int i = 0; i <= N-K; i++){
		sum = asum - psum;
		if(psum + nsum >= 0) sum += psum + nsum;
		ans = max(ans, sum);
		
		if(a[i+K] >= 0) psum += a[i+K];
		else nsum += a[i+K];
		if(a[i] >= 0) psum -= a[i];
		else nsum -= a[i];
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>

int main()
{
    char str[99];
    gets(str);
    int n=0;
    n=strlen(str);
    int i,j,x,y=0,z=0;
    x=(n-1)/2;
    for (i=0,j=n-1;i<n/2;i++,j--)
    {
        if (str[i]==str[j])
            z++;
        else
        {
            printf("No\n");
           break;
        }
    }
    if (z==(n/2))
    {
        for (i=0,j=x-1;i<x/2;i++,j--)
        {
            if (str[i]==str[j])
                y++;
            else
            {
                printf("No\n");
                break;
            }
        }
    }

    if (y==(x/2))
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {

    val inputs = readLine()!!.split(" ").map { it.toInt() }
    var conbiNum = 0

    for (i in 0..inputs[0])
        for (j in 0..inputs[0]) {
            var z = inputs[1] - i - j
            if (0 <= z && z <= inputs[0])
                conbiNum += 1
        }

    println(conbiNum)
}

Measured memory_bytes: 35996
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/\s/);

const main = input => {
  const [a, b, c] = input.map(x => Number(x));
  const ans = (a + b) >= c ? 'Yes' : 'No';
  console.log(ans);
};

main(receive);

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

using namespace std;

int gcd(int a, int b){
   if(b == 0) return a;
   return gcd(b, a % b);
}

int main(int argc, char *argv[])
{
  int N, X;

  cin >> N >> X;

  vector<int> x(N+1);

  for (int i = 0; i < N; i++)
    cin >> x.at(i);
  x.at(N) = X;

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

  vector<int> diffs;
  for(int i = 0; i < N; i++)
  {
    int diff = x.at(i+1) - x.at(i);
    diffs.push_back(diff);
  }

  int g = diffs.at(0);

  for(int i = 1; i < N; i++)
    g = gcd(g, diffs.at(i));

  cout << g << endl;

  return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
int n;
int x[10],y[10];
double dist(int i,int j){
	double dx=x[i]-x[j];
	double dy=y[i]-y[j];
	return sqrt(dx*dx+dy*dy);
}
void solve(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i]>>y[i];
	double sum=0.0;
	vector<int> v(n);
	for(int i=0;i<n;i++)v[i]=i+1;
	do{
		for(int i=0;i<n-1;i++)sum+=dist(v[i],v[i+1]);
	}while(next_permutation(v.begin(),v.end()));	
	int Factiorial=1;
	for(int i=2;i<=n;i++)Factiorial*=i;
	cout<<fixed<< setprecision(10)<<sum/Factiorial<<endl;
	return;
}
signed main(){
	solve();
	return 0;
}	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double ans = 0;
        for (int i = 0; i < n; i++) {
            double x = sc.nextDouble();
            String u = sc.next();
            if (u.equals("JPY")) {
                ans += x;
            } else {
                ans += x * 380000.0;
            }
        }
        sc.close();

        System.out.println(ans);
    }

}


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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //int n = int.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            //var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();


            if (s.Length <= k)
            {
                Console.WriteLine(s);
            }

            else
            {
                string result = s.Substring(0, k);
                result = result + "...";
                Console.WriteLine(result);
            }


            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27464
import sys
input = sys.stdin.readline
n,a,b = map(int,input().split())
hls = [int(input()) for i in range(n)]
l = 0
r = sum(hls)
while l<r:
  x = (l+r)//2
  cnt = 0
  for hp in hls:
    if hp-x*b>0:
      cnt += (hp-x*b+(a-b)-1)//(a-b)
  if cnt>x:
    l = x+1
  elif cnt<x:
    r = x
  else:
    ans = x
    break
if l == r:
  ans = l
print(ans)

Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  cin>>N>>K;
  if(log10(N)*8-2<=K){
    for(int i=0;i<N;i++){
      cout<<N;
      if(i==N-1)
        cout<<endl;
      else
        cout<<' ';
    }
    return 0;
  }
  vector<vector<int>> A(K+1,vector<int>(N,0));
  for(int &i:A[0])
    cin>>i;
  for(int i=0;i<K;i++){
    for(int j=0;j<N;j++){
      A[i+1][max(0,j-A[i][j])]++;
      A[i+1][min(N-1,j+A[i][j])+1]--;
    }
    for(int j=1;j<N;j++){
      A[i+1][j]+=A[i+1][j-1];
    }
  }
  for(int i=0;i<N;i++){
    cout<<A[K][i];
    if(i==N-1)
      cout<<endl;
    else
      cout<<' ';
  }
}

Measured memory_bytes: 35472
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
ans = 0
List = [a,b,c,d,e]
wait = []
for i in List:
    tmp = 10-i%10
    if tmp ==10:
        tmp = 0
    wait.append(tmp)

for i in range(5):
    ans += List[i]+wait[i]
print(ans-max(wait))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110000],b[110000];
int main(){
    ll n,k,q,l,ans=0,tmp=0;
    cin>>n>>k>>q;
    rep(i,0,q)cin>>a[i];
    rep(i,0,q)b[a[i]]++;
    rep(i,1,n+1){
      if(b[i]+k-q<=0)cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 2176
#include <iostream>

typedef long long ll;

ll N;

int main() {
  std::cin >> N;
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ans += (N - i) * (N - i + 1) / 2;
    //std::cout << (N - i) * (N - i + 1) / 2 << "\n";
  }
  for (int i = 0; i < N-1; ++i) {
    ll u, v;  std::cin >> u >> v;
    if (u > v)  std::swap(u, v);
    ans -= u * (N - v + 1);
  }
  std::cout << ans << "\n";

  return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 300010
const int MOD = 1000000007;

int pref[maxn][2], suf[maxn][2];

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'E')pref[i + 1][0] = 1;
        else pref[i + 1][1] = 1;
        pref[i + 1][0] += pref[i][0];
        pref[i + 1][1] += pref[i][1];
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'E')suf[i + 1][0] = 1;
        else suf[i + 1][1] = 1;
        suf[i + 1][0] += suf[i + 2][0];
        suf[i + 1][1] += suf[i + 2][1];
    }

    int ans = 1e10;
    for (int i = 1; i <= n; i++) {
        ans = min(ans, pref[i - 1][1] + suf[i + 1][0]);
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 10004
function Main(input) {
    input = input.split(" ");
    var a = parseInt(input[0]);
    var b = parseInt(input[1]);

    if (a < b) {
        console.log("a < b");
    }else if (b < a) {
        console.log("a > b");
    }else if (a == b) {
        console.log("a == b");
    }
   }
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug() {
    var input = document.getElementById("input").value;
    Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17136
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		String str=sc.nextLine();
		
		boolean jubge=false;
		
		if((str.charAt(2))==(str.charAt(3))
				&&(str.charAt(4))==(str.charAt(5))){
				System.out.println("Yes");	
		}
		
		else System.out.println("No");
	}
}

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

long long N;
vector<long long> a;
set<long long> memo;

bool check(long long N){
	//cout << "N = " << N << endl;

	long long nnum = 0;
	long long nonenum = 0;
	for(long long i = 0; i < a.size(); i++){
		if(a[i] == N-1){
			nonenum++;
		}else if(a[i] == N){
			nnum++;
		}else{
			exit(1);
		}
	}
	//cout << "n - 1 = " << nonenum << " nnum = " << nnum << endl;
	if(nnum == 1){
		return false;
	}

	long long mini;
	long long maxi;
	if(nnum > 1){
		mini = nonenum + 1;
		maxi = nonenum + nnum/2;
	}else{
		mini = nonenum;
		maxi = nonenum + nnum/2;
	}
	return mini <= N && N <= maxi;
}

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		a.push_back(tmp);
		memo.insert(tmp);
	}
	sort(a.begin(), a.end());

	if(memo.size() != 1 && memo.size() != 2){
		cout << "No" << endl;
		return 0;
	}

	if(a[a.size() - 1] - a[0] >= 2){
		cout << "No" << endl;
		return 0;
	}

	if(memo.size() == 1){
		if(check(a[0]) || check(a[0] + 1)){
			cout << "Yes" << endl;
			return 0;
		}else{
			cout << "No" << endl;
			return 0;
		}
	}else{
		if(check(a[a.size() - 1])){
			cout << "Yes" << endl;
			return 0;
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 5748
#include <iostream>

using namespace std;

int main () {
  int a,b;
  std::cin >> a >> b;
  if ((a + b) == 15) {
    std::cout << "+" << std::endl;  
  }  
  else {
    if ((a * b) == 15) {
      std::cout << "*" << std::endl;  
    }  
    else {
      std::cout << "x" << std::endl;  
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

const int INF = 1001001001;

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vi c(n,0);
  vvi a(n,vi(m,0));
  rep(i,n) {
    cin >> c.at(i);
    rep(j,m) {
    cin  >> a.at(i).at(j);
  }
}

  int ans = INF;
  vi b(m,0);

  rep(i,1<<n) {
    int cost = 0;
    bool flag = true;
    rep(j,m) b.at(j) = 0;
    rep(j,n) if(i>>j&1) {
      rep(k,m) {
        b.at(k) += a.at(j).at(k);
      }
      cost += c.at(j);
    }
    rep(j,m) if(b.at(j)<x) flag=false;
    if(flag) ans=min(ans,cost);
  }
  if(ans==INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

 
signed main(void) {
    int N;
    cin >> N;
    string str_N = to_string(N);
    int Sn = 0;
    rep(i, str_N.size()) {
        Sn += (str_N[i] - '0');
    }
    if (N % Sn == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = list(range(n + 1))
        self.ranks = [0 for _ in range(n + 1)]

    def get_root(self, x):
        if self.parents[x] == x:
            return x
        self.parents[x] = self.get_root(self.parents[x])
        return self.parents[x]

    def merge(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)
        if x != y:
            if self.ranks[x] < self.ranks[y]:
                self.parents[x] = y
            else:
                self.parents[y] = x
                if self.ranks[x] == self.ranks[y]:
                    self.ranks[x] += 1


n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    x, y, z = map(int, input().split())
    uf.merge(x - 1, y - 1)
res = set()
for i in range(n):
    res.add(uf.get_root(i))
print(len(res))

Measured memory_bytes: 16784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int a[n],b[n],k=0;
    for(i=0;i<n;i++)
        cin>>a[i]>>b[i];
    for(i=0;i<=n-3;i++)
    {
        if((a[i]==b[i])&&(a[i+1]==b[i+1])&&(a[i+2]==b[i+2]))
        {
           k=1;
           break;
        }
    }
    if(k==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3632
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=100005;

struct Node
{int a,b,c;};

int X,Y,Z,N;
Node P[MAXN];

bool cmpab(const Node &x,const Node &y)
{return x.a-x.b>y.a-y.b;}
struct cmpbc
{
	bool operator () (const Node &x,const Node &y)const
	{return x.b-x.c>y.b-y.c;}
}BC;
struct cmpac
{
	bool operator () (const Node &x,const Node &y)const
	{return x.a-x.c>y.a-y.c;}
}AC;

priority_queue<Node,vector<Node>,cmpac> Q1;
priority_queue<Node,vector<Node>,cmpbc> Q2;
long long l[MAXN],r[MAXN];

int main()
{
	scanf("%d%d%d",&X,&Y,&Z);
	N=X+Y+Z;
	for(int i=1;i<=N;i++)
		scanf("%d%d%d",&P[i].a,&P[i].b,&P[i].c);
	sort(P+1,P+N+1,cmpab);
	long long sum=0;
	for(int i=1;i<=X;i++)
	{
		sum+=P[i].a;
		Q1.push(P[i]);
	}
	l[X]=sum;
	for(int i=X+1;i<=X+Z;i++)
	{
		if(Q1.empty()||AC(Q1.top(),P[i]))
			sum+=P[i].c;
		else
		{
			sum+=-Q1.top().a+Q1.top().c+P[i].a;
			Q1.pop();
			Q1.push(P[i]);
		}
		l[i]=sum;
	}
	sum=0;
	for(int i=N;i>N-Y;i--)
	{
		sum+=P[i].b;
		Q2.push(P[i]);
	}
	r[N-Y+1]=sum;
	for(int i=N-Y;i>X;i--)
	{
		if(Q2.empty()||BC(Q2.top(),P[i]))
			sum+=P[i].c;
		else
		{
			sum+=-Q2.top().b+Q2.top().c+P[i].b;
			Q2.pop();
			Q2.push(P[i]);
		}
		r[i]=sum;
	}
	long long ans=0;
	for(int i=0;i<=N;i++)
		ans=max(ans,l[i]+r[i+1]);
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 3368
using System;
using System.Linq;
class A
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(a);
        if (a[0] == a[1] && a[2] == a[1] && a[3] == a[2])
        {
            if (a[4] == a[5] && a[5] == a[6] && a[7] == a[6])
            {
                if (a[8] == a[9] && a[9] == a[10] && a[10] == a[11])
                {
                    Console.WriteLine("yes"); return;
                }
            }
        }
        Console.WriteLine("no");
        Console.ReadLine();
    }

}

Measured memory_bytes: 9468
#include<stdio.h>
#include<stdlib.h>
#define PI 3.141592653589793
int main(void){
	double r,S,s;
	scanf("%lf",&r);
	S=PI*r*r;
	s=2*PI*r;
	printf("%lf %lf\n",S,s);
    
	return 0;
}


Measured memory_bytes: 2100
//53
#include<iostream>
#include<vector>
#include<cctype>
#include<map>
#include<set>

using namespace std;

map<char,int> f;
set<char> ap;
int c;
vector<int> vc;
vector<bool> va;
int cn[10];
int n;

int pow10(int x){
  int r=1;
  while(x--){
    r*=10;
  }
  return r;
}

int dfs(int s,int u){
  if(s==vc.size()){
    int r=0;
    for(int i=0;i<vc.size();i++){
      r+=cn[i]*vc[i];
    }
    return r+c==0;
  }else{
    int r=0;
    for(int i=0;i<=9;i++){
      if(!(u&1<<i)&&(i||!va[s])){
	cn[s]=i;
	r+=dfs(s+1,u|1<<i);
      }
    }
    return r;
  }
}

int main(){
  while(cin>>n,n){
    c=0;
    vc.clear();
    va.clear();
    f.clear();
    ap.clear();
    for(int j=0;j<n;j++){
      string s;
      cin>>s;
      if(isalpha(s[0])&&s.size()!=1){
	ap.insert(s[0]);
      }
      for(int i=0;i<s.size();i++){
	if(isdigit(s[i])){
	  c+=(s[i]-'0')*pow10(s.size()-i-1)*((j==n-1)?-1:1);
	}else{
	  f[s[i]]+=pow10(s.size()-i-1)*((j==n-1)?-1:1);
	}
      }
    }
    for(map<char,int>::iterator it=f.begin();it!=f.end();it++){
      vc.push_back(it->second);
      va.push_back(ap.count(it->first)==1);
    }
    cout<<dfs(0,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;



int main() {

	int r, g, b;
	cin >> r >> g >> b;

	int a = 10 * g + b;

	if (a % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}




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

#define ll long long
#define endl "\n"
ll INF = 1e9 + 7;

int main(){
	ll n, w, sum = 0, ans = 0; cin>>n>>w;
	vector<pair<ll, ll>> v(n);
	for(auto &i : v){
		cin>>i.second>>i.first;
		sum += i.first;
	}
	vector<vector<ll>> dp(n+1, vector<ll>(sum+1, INF));
	dp[0][0] = 0;
	for(ll i = 1; i<=n; i++){
		dp[i][0] = 0;
		for(ll j = 1; j <= sum; j++){
			if(j - v[i-1].first >= 0){
				dp[i][j] = min(dp[i-1][j], v[i-1].second + dp[i-1][j-v[i-1].first]);
			}else{
				dp[i][j] = dp[i-1][j];
			}
			if(dp[i][j] <= w){
				ans = max(ans, j);
			}
		}
	}
	cout<<ans<<endl;
	
}


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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(min((x-a)*(x-a), (x-b)*(x-b))==(x-a)*(x-a)){
    cout << "A" << endl;}
  else{
    cout << "B" << endl;}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

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

if(a>c&&b==c){
printf("%d %d %d\n",b,b,a);
}
if(c>a&&b==c){
printf("%d %d %d\n",a,b,b);
}
if(a<b&&a==c)
{
  printf ("%d %d %d\n",a,a,b);
}

return 0;
}

Measured memory_bytes: 596
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



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

	vector<int> imosL(n), imosR(n), posL, posR;
	REP(i, n) {
		if (s[i] == '>') {
			imosR[i]++;
			posR.push_back(i);
		}
		else {
			imosL[i]++;
			posL.push_back(i);
		}
	}
	REP(i, n - 1) {
		imosL[i + 1] += imosL[i];
		imosR[i + 1] += imosR[i];
	}

	int res = 0;
	REP(i, n) {
		int leftR = i == 0 ? 0 : imosR[i - 1];
		int rightL = imosL.back() - imosL[i];
		if (s[i] == '>') {
			if (leftR < rightL) {
				res = max(res, posL[i] + 1);
			}
			else {
				int cnt = n - 1 - i;
				res = max(res, n - posR[posR.size() - 1 - cnt] );
			}
		}
		else {
			if (leftR > rightL) {
				int cnt = n - 1 - i;
				res = max(res, n - posR[posR.size() - 1 - cnt] );
			}
			else {
				res = max(res, posL[i] + 1);
			}
		}
	}
	cout << res << endl;
	return 0;
}



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

int main() {
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  }
  if (L == R) {
    cout << "Balanced" << endl;
  }
  if (L < R) {
    cout << "Right" << endl;
  }
  
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    //vector<int> a(N);
    vector<int> a;
    int num;
    //for(int i=0; i<N; i++)cin >> a.at(i);
    //↓最速
    //for(int i=0; i<N; i++)scanf("%d", &a.at(i));
    for(int i=0; i<N;i++){
        scanf("%d", &num);
        a.push_back(num);
    }
    int push = 1;
    
    for(int i=0; i<N; i++){
        int next_push = a.at(push - 1);
        
        //if finished
        if(next_push == 2){
            cout << i + 1 << endl;
            exit(0);
        }
        push = next_push;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 892
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    vector<pair<int,int>> HW;
    while(true){
        int H, W;
        cin >> H >> W;
        if(H == 0 and W == 0) break;
        HW.emplace_back(H, W);
    }
    for(auto p : HW){
        int H = p.fi, W = p.se;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(i == 0 or i == H - 1 or j == 0 or j == W - 1) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	a := scanInts(n)

	for _, v := range a {
		if v%2 == 0 && v%3 != 0 && v%5 != 0 {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int ave = ( a + b ) / 2;
		int ans = 0;

		if ( ( a + b ) % 2 == 0) {
			ans = ave;
		} else {
			ans = ave + 1;
		}

		System.out.println( ans );
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <pii> arr(k);
  for (auto& pp: arr) cin >> pp.first >> pp.second;
  const int mod = 998244353;
  vi acc(n + 1, 0);
  acc[1] = 1;
  acc[2] = mod - 1;
  for (int pos = 1; pos <= n; pos++) {
    acc[pos] += acc[pos - 1];
    if (acc[pos] >= mod) acc[pos] -= mod;
    int dp_pos = acc[pos];
//    cout << pos << ' ' << dp_pos << endl;
    for (auto pp: arr) {
      int l = pos + pp.first;
      int r = pos + pp.second;
      if (l <= n) {
        acc[l] += dp_pos;
        if (acc[l] >= mod) acc[l] -= mod;
      }
      if (r + 1 <= n) {
        acc[r + 1] += mod - dp_pos;
        if (acc[r + 1] >= mod) acc[r + 1] -= mod;
      }
    }
  }
  cout << acc[n] << '\n';
  return (0);
}


Measured memory_bytes: 3976
#include <iostream>

using namespace std;

void selectionSort(int A[], int N) {
    int minj;
    int count = 0;

    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (A[minj] > A[j]) {
                minj = j;
            }
        }
        if (!(minj == i)) {
            swap(A[minj], A[i]);
            count++;
        }

    }


    for (int i = 0; i < N; i++) {
        if (i) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl << count << endl;

}

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    selectionSort(A, N);
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

// template<typename T>
// void print(T &arr){
//     ll sz = sizeof(arr)/sizeof(arr[0]);
//     for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
//     cout << arr[sz-1] << endl;
// }

int main(){
    int n; cin >> n;
    auto is_prime = [](ll x) -> bool{
        bool ok = true;
        rep(i,sqrt(x+1)){
            if(i <= 1)continue;
            if(x%i == 0){ok = false;break;}
        }
        return ok;
    };

    int count = 0;
    vector<ll> res;
    ll temp_prime = 31;
    // res.push_back(temp_prime);
    while (count < n){
        // if(temp_prime == 1)continue;
        while(!is_prime(temp_prime))temp_prime += 30;
        res.push_back(temp_prime);
        ++count;
        temp_prime += 30;
    }

    print(res);
    return 0;

    // // 乱択で検証
    // vector<int> rand(5);
    // random_device rnd;
    // bool ok = true;
    // rep(i,100){
    //     int sum = 0;
    //     rep(j,5){
    //         int temp = rnd() % n;
    //         rand[j] = res[temp];
    //         sum += rand[j];
    //     }
    //     if(is_prime(sum)){
    //         ok = false;
    //         print(rand);
    //     }
    // }
    // print(ok);

}

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

using namespace std;

typedef long long ll;

const ll INF = 1e9;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll sx, sy, fx, fy;
    long double pi = -1;
    pi = acos(pi);
    cin >> sx >> sy >> fx >> fy;
    if (sx > fx) {
        ll t = sx;
        sx = fx;
        fx = t;
        t = sy;
        sy = fy;
        fy = t;
    }
    int k = 1;
    if (sy > fy) {
        k = -1;
    }
    sy *= k;
    fy *= k;
    ll n;
    cin >> n;
    vector<pair<ll, ll>> f(n), g(n);
    for (int i = 0; i < n; ++i) {
        cin >> f[i].first >> f[i].second;
        f[i].second *= k;
        g[i].first = f[i].second;
        g[i].second = f[i].first;
    }
    sort(f.begin(), f.end());
    sort(g.begin(), g.end());
    vector<ll> a, b;
    for (int i = 0; i < n; ++i) {
        if (f[i].first < sx || f[i].first > fx || f[i].second < sy || f[i].second > fy) {
            continue;
        }
        a.push_back(f[i].second);
        b.push_back(g[i].second);
    }
    int m = a.size();
    vector<ll> t(m + 1, INF);
    t[0] = -INF;
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        int p = upper_bound(t.begin(), t.end(), a[i]) - t.begin();
        t[p] = min(t[p], a[i]);
        ans = max(ans, p);
    }
    t.assign(m + 1, INF);
    t[0] = -INF;
    for (int i = 0; i < m; ++i) {
        int p = upper_bound(t.begin(), t.end(), b[i]) - t.begin();
        t[p] = min(t[p], b[i]);
        ans = max(ans, p);
    }
    long double dist = abs(fx - sx + fy - sy) * 100;
    if (ans - 1 == min(fx - sx, fy - sy)) {
        --ans;
        dist += pi * 10 - 20;
    }
    cout << fixed << setprecision(30) << dist - (20.0 - 5 * pi) * ans;
    return 0;
}

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

#define Bye return 0
#define ll long long
const int MAX = 1e9+7;
const int SIZE = 1e5+1;

void solve(){
    int n; cin>>n;
    
    int a[n+1];
    memset(a, 0, sizeof a);
    bool no_solution = false; 
    for (int i=1; i<=n; i++){
        int e; cin>>e; a[e]++;
    }

    int counter = (n%2^0) ? (n-1)/2 :  n/2;

    int res = 1;
    for (int i=1; i<=counter; i++)
        res = (res*2)%MAX;

    if(n%2^0){
        for (int i=2; i<n; i+=2)
            if(a[i]^2) {res = 0; break;}
    } else 
        for (int i=1; i<=n-1; i+=2)
            if(a[i]^2) {res = 0; break;}
    
    cout<<res<<endl;
}

int main()
{
    solve();
    Bye;
}

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

typedef long long LL;

const int MAXN = 200005;

int n;
LL a[MAXN];

multiset<LL> s;

int main() {

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

		s.insert(a[i]);
	}

	sort(a, a + n);

	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s.find(a[i]) == s.end())
			continue;

		s.erase(s.find(a[i]));
		for (int j = 31; j > 0; j--) {
			// cout << " " << j << endl;
			LL pow2 = (1LL << j);
			auto target = s.find(pow2 - a[i]);

			if (target != s.end()) {
				s.erase(target);
				ans++;
				break;
			}
		}

		// cout << ans << endl;
	}

	cout << ans << endl;

	return 0;
}

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

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

int main() {
  LL h, w, n;
  cin >> h >> w >> n;
  vector<pair<int, int>> a;
  for (int i = 0; i < n; i ++) {
    int x, y;
    cin >> x >> y;
    x --, y --;
    for (int j = 0; j < 9; j ++) {
      int nx = x + dx[j];
      int ny = y + dy[j];
      if (nx >= 0 && ny >= 0 && nx < h - 2 && ny < w - 2) a.push_back(make_pair(nx, ny));
    }
  }

  sort(a.begin(), a.end());
  LL cnt[10] = {};
  LL t = 1, sum = 0;
  for (int i = 0; i < max(0, (int)a.size() - 1); i ++) {
    if (a[i].first == a[i + 1].first && a[i].second == a[i + 1].second) t ++;
    else cnt[t] ++, t = 1, sum ++;
  }
  cnt[t] ++, sum ++;
  if (a.size() == 0) cnt[t] = 0, sum = 0;

  for (int i = 0; i < 10; i ++) {
    if (i) cout << cnt[i] << endl;
    else cout << (h - 2) * (w - 2) - sum << endl;
  }
}

Measured memory_bytes: 10476