akhauriyash/Code-Regression huggingface dataset:
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,
        mut hs:[i64;n]
    }

    let mut ok = true;
    let mut l = 0;
    while l < n {
        let mut r = l + 1;
        while r < n && hs[l] > hs[r] {
            if hs[l] - hs[r] > 1 {
                ok = false;
            }
            r += 1;
        }
        l = r;
    }
    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned) 1e9 + 7>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  Mint res;
  int c = 0;
  for (int i = 0; i < n; ++i) if (s[i] == '1') {
    res += Mint(2).pow(c) * Mint(3).pow(n - i - 1);
    c += s[i] == '1';
  }
  res += Mint(2).pow(c);
  cout << res << '\n';
}

Measured memory_bytes: 512
package main

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

func main() {
	sc := NewScanner()
	R, G, B, N := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()

	count := 0
	for r := 0; r*R <= N; r++ {
		a := r * R
		for g := 0; a+g*G <= N; g++ {
			q := a + g*G
			if (N-q)%B == 0 {
				count++
			}
		}
	}
	fmt.Println(count)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int R;

int main () {
	cin >> R;
	if (R < 1200) {
		cout << "ABC" << endl;
	} else if (R < 2800){
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
	int N;
	cin >> N;
	vector<tuple<string,int,int>> a;
	for(int i=1;i<=N;i++){
		string s;
		int n;
		cin >> s >> n;
		n = -n;
		a.push_back(tie(s,n,i));
	}
	sort(a.begin(),a.end());
	for(int i=0;i<N;i++)cout<< get<2>(a[i])<<endl;
	}


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

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

int arr[100005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

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

    sort(arr, arr + n);

    cout << arr[n / 2] - arr[n / 2 - 1];

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, ll> cnt;
    ll tot = 0;
    ll freq;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        cnt[v[i]]++;
    }
    tr(cnt, it) {
        tot += (it->second * (it->second - 1)) / 2;
    }
    for (int i = 0; i < n; i++) {
        freq = cnt[v[i]];
        cout << tot - (freq * (freq - 1) / 2) + ((freq - 1) * (freq - 2) / 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<LL,LL>u,x,y;
V<pair<LL,LL> >v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
   string a;
   cin>>a;
   k=0;
   for(i=0;a[i];i++)
   {
       if(a[i]=='7')
       {
           k=1;
           break;
       }
   }
   if(k==1)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
    return 0;
}


Measured memory_bytes: 3656
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int c1, c5, c10, c50, c100, c500;

int main() {
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	LL sum = c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;
	if (sum >= 1000) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(ll, n);
  out(n * (n + 1) / 2 - n);
}


Measured memory_bytes: 256
#
# abc083 b
#
n, a, b = map(int, input().split())
ret = 0
for i in range(n+1):
    x = 0
    s = str(i)
    for j in range(len(s)):
        x += int(s[j])
    if x >= a and x <= b:
        ret += i
print(ret)


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scn = new Scanner(System.in);
    char[] str = scn.nextLine().toCharArray();
    if (str[0]<str[2])System.out.println("<");
    else if (str[0]>str[2])System.out.println(">");
    else System.out.println("=");
  }
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int32_t main(){
	IOS;
	int tt = 1; 
	//cin >> tt;
  const int mod = 1e9 + 7;
	while(tt--){
    int n; cin >> n;
    int A[n];
    int pre[n + 1] = {};
    for(int i = 0; i < n; i++){
      cin >> A[i];
      pre[i + 1] += pre[i] + A[i];
    }
    int ans = 0;
    
    for(int i = 0; i < n; i++){
      ans += (pre[i] % mod * A[i] % mod) % mod;
      ans %= mod;
    }
    cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 6736
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e9],A[m:r]+[1e9]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1;c+=j
  else:A[k]=R[j];j+=1
def s(A,l,r):
 if l+1<r:m=(l+r)//2;s(A,l,m);s(A,m,r);g(A,l,m,r)
c=0
n=int(input())
A=list(map(int,input().split()))
s(A,0,n)
print(c)


Measured memory_bytes: 27480
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Sarray();
            WriteLine(Ceiling((double)(N - 1) / (K - 1)));
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 21088
def pre_cmb(N, MOD):
    FACT = [1, 1]  # 階乗
    INV = [0, 1]  # 各iの逆元
    FACTINV = [1, 1]  # 階乗の逆元

    for i in range(2, N + 1):
        FACT.append((FACT[-1] * i) % MOD)
        INV.append(pow(i,MOD-2,MOD))
        FACTINV.append((FACTINV[-1] * INV[-1]) % MOD)
    PRELIST = FACT, FACTINV
    return PRELIST


def cmb(N, R, MOD, PRELIST):
    FACT, FACTINV = PRELIST
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    return FACT[N] * FACTINV[R] * FACTINV[N-R] % MOD


n, m, k = map(int, input().split())
mod = 998244353

prelist = pre_cmb(n, mod)

cnt = 0
for i in range(k + 1):
    cnt += (m * pow(m - 1, n - i - 1, mod) * cmb(n - 1, i, mod, prelist)) % mod

print(cnt % mod)


Measured memory_bytes: 32844
fun main(args:Array<String>) {
    println(f(readLine()!!.toLong()))
}

fun f(num:Long):Long {
    if(num%2!=0L) {
        return 0
    }
    var tmp = num/10
    var cur = 50L
    for(i in (0..num)) {
        if(num < cur) {
            break
        }
        tmp += ((num/cur))
        cur *= 5
    }
    return tmp
}

Measured memory_bytes: 29908
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
  
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
const int mxn=200005;

int main()
{
  fastio;
  
  int n;
  cin>>n;
  vector<ll> a(n);
  range(i,0,n)cin>>a[i];
  ll ans=0;
  int curr=a[0];
  int i=1;
  while(i<n)
  {
    if(i<n&&a[i]<curr)
    {
      while(i<n&&a[i]<curr)
      {
        ans+=(curr-a[i]);
        i++;
      }
      curr=a[i];
    }
    else
    {
      curr=a[i];
      i++;
    }

  }
  cout<<ans;
}


Measured memory_bytes: 4780
import java.util.Scanner;

public class Main {

	public static int[][] dropBig (int[][] paper, int x, int y) {
		paper = dropMid(paper,x,y);
		paper[y - 2][x] += 1;
		paper[y][x - 2] += 1;
		paper[y + 2][x] += 1;
		paper[y][x + 2] += 1;
		return paper;
	}

	public static int[][] dropMid (int[][] paper, int x, int y) {
		paper = dropSmall(paper,x,y);
		paper[y + 1][x + 1] += 1;
		paper[y + 1][x - 1] += 1;
		paper[y - 1][x + 1] += 1;
		paper[y - 1][x - 1] += 1;
		return paper;
	}

	public static int[][] dropSmall (int[][] paper, int x, int y) {
		paper[y][x] += 1;
		paper[y + 1][x] += 1;
		paper[y - 1][x] += 1;
		paper[y][x + 1] += 1;
		paper[y][x - 1] += 1;
		return paper;
	}

	public static int[][] sol (int[][] paper, String[] str) {
		int x = Integer.parseInt(str[0]) + 2;
		int y = Integer.parseInt(str[1]) + 2;
		int op = Integer.parseInt(str[2]);
		switch (op) {
			case 1 : paper = dropSmall(paper,x,y); break;
			case 2 : paper = dropMid(paper,x,y); break;
			case 3 : paper = dropBig(paper,x,y); break;
		}
		return paper;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int size = 10;
		int[][] paper = new int[size + 4][size + 4];

		while (sc.hasNextLine()) {
			String[] str = sc.nextLine().split(",");
			paper = sol(paper, str);
		}

		int countZero = 0, max = 0;
		for (int i = 2; i < paper.length - 2; i++) {
			for (int j = 2; j < paper[i].length - 2; j++) {
				if (paper[i][j] == 0) countZero++;
				max = Math.max(max, paper[i][j]);
			}
		}

		System.out.println(countZero + "\n" + max);

	}

}

Measured memory_bytes: 17188
//
//  main.cpp
//  test
//
//  Created by kanebako on 2017/09/10.
//  Copyright © 2017 kanebako. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>


using namespace std;

int main(int argc, const char * argv[]) {
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if (a == b){
        cout << c << endl;
    } else if (b == c){
        cout << a << endl;
    } else {
        cout << b << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool a=false;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      a=true;
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

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

    int a, b, c;
    std::cin >> a >> b >> c;
    int r = 100 * a + 10 * b + c;
    std::cout << (((r % 4) == 0) ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pll = pair < ll, ll >;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
 
int main(){   
    ll n, m, k; cin >> n >> m >> k;
    ll a[n+1], b[m+1];
    a[0] = 0; b[0] = 0;
    for(ll i = 1; i <= n; i++) cin >> a[i];
    for(ll i = 1; i <= m; i++) cin >> b[i];

    for(ll i = 1; i <= n; i++) a[i] = a[i] + a[i-1];
    for(ll i = 1; i <= m; i++) b[i] = b[i] + b[i-1];

    ll i = 0, j = m, ans = 0;
    for(ll i = 0; i <= n; i++) {
        if(a[i] > k)
            break;
        while(b[j] > k - a[i]) {
            --j;
        } 
        ans = max(ans, i + j);
    }
    cout << ans << endl;
}
    


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

#define INF 1e9
#define MAX 100005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

long long a[MAX];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	long long sum=0,cnt=0,mn=INF;
	for(int i=0;i<n;i++){
		if(a[i]<0)cnt++;
		sum+=abs(a[i]);
		mn=min(mn,abs(a[i]));
	}
	if(cnt%2==0)cout << sum;
	else cout << sum-2*mn;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x,long long y){
	if(max(x,y)%min(x,y)==0) return min(x,y);
	else return gcd(min(x,y),max(x,y)%min(x,y));
}
int main(){
	int n;
	cin>>n;
	long long t[n];
	for(int i=0;i<n;i++) cin>>t[i];
	for(int i=0;i<n-1;i++) t[i+1]=t[i]/gcd(t[i],t[i+1])*t[i+1];
	cout<<t[n-1];
	return 0;
}


Measured memory_bytes: 256
n = int(input())
alist = [int(i) for i in input().split()]
alist.sort()

def calc_gcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def get_custum(xlist):
    prev = None
    gcm_list = []
    for a in xlist:
        if prev is None:
            gcm_list.append(a)
            prev = a
            continue
        ret = calc_gcm(a, prev)
        gcm_list.append(ret)
        prev = ret

    for boundary, gcm in enumerate(gcm_list):
        if gcm == gcm_list[-1]:
            break

    gcm_1 = None
    for i, a in enumerate(xlist):
        if i == boundary - 1:
            continue
        if gcm_1 is None:
            gcm_1 = a
            continue
        gcm_1 = calc_gcm(a, gcm_1)

    gcm_2 = None
    for i, a in enumerate(xlist):
        if i == boundary:
            continue
        if gcm_2 is None:
            gcm_2 = a
            continue
        gcm_2 = calc_gcm(a, gcm_2)

    return max(gcm_1, gcm_2)

ret1 = get_custum(alist)
alist.reverse()
ret2 = get_custum(alist)

print(max(ret1, ret2))


Measured memory_bytes: 65764
#include<bits/stdc++.h>
using namespace std;
 
int main() {
vector<string> str(3);
for (int  i = 0; i < 3; i++) {
cin >> str[i];
}
vector<int> cnt(3,0);
int pass = 0;
while (1) {
for (int i = 0; i < 3; i++) {
if (cnt[i] == str[i].length()) {
cout << char('A' + i) << endl;
return 0;
}
}
cnt[pass]++;
pass = str[pass][cnt[pass]-1] - 'a';
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;
using P = pair<ll, ll>;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

class UnionFind {
public:
  // 親の番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> parent;

  // 作るときは parent の値を全て -1 にする
  // こうすると全てバラバラになる
  UnionFind(const int& n = 0) : parent(n, -1) {}

  // x がどのグループに属しているか調べる
  int find(const int& x) {
    if (parent[x] < 0) return x;
    return parent[x] = find(parent[x]);
  }

  // x と y をくっつける  O(log n)
  bool unite(int x, int y) {
    // x と y を直接くっつけるのではなく，root(x) に root(y) をくっつける
    x = find(x);
    y = find(y);
    if (x == y) return false;  // すでにくっついているからくっつけない

    // 大きい方(x) に小さい方(y)をくっつけたい 大小が逆だったらひっくり返す
    if (size(x) < size(y)) swap(x, y);

    parent[x] += parent[y];  // x のサイズを更新する
    parent[y] = x;  // y の親を x に変更する
    return true;
  }

  // 自分のいるグループの頂点数を調べる
  int size(const int& x) { return -parent[find(x)]; }

  // x と y が同じグループに属しているか否か
  bool same(const int& x, const int& y) { return find(x) == find(y); }
};

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

  ll n, m;
  cin >> n >> m;

  vector<pair<int, int>> bridges;
  rep(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    bridges.emplace_back(a, b);
  }

  ll ans = (n * (n-1)) / 2;   // 全部の橋が落ちている
  vector<ll> x;
  x.push_back(ans);

  UnionFind uf(n);
  for (auto itr = bridges.rbegin(); itr != bridges.rend(); itr++) {
    int a = itr->first;
    int b = itr->second;
    if (!uf.same(a, b)) {
      ans -= ll(uf.size(a)) * uf.size(b);
    }
    uf.unite(a, b);
    x.push_back(ans);
  }
  x.pop_back();  // 全部の橋が繋がった状態については答えない

  reverse(ALL(x));
  rep(i, x.size()) cout << x[i] << endl;

  return 0;
}


Measured memory_bytes: 3444
graph = [[-1 for _ in range(15)] for _ in range(15)]
n = int(input())
for index in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        graph[index][x-1] = y

answer = 0
for index in range(2 ** n):
    honests = [0 for _ in range(n)]
    for shift in range(n):
        if (index >> shift) & 1:
            honests[shift] = 1
    ok = True
    for idx1 in range(n):
        if honests[idx1]:
            for idx2 in range(n):
                if graph[idx1][idx2] == -1:
                    continue
                if graph[idx1][idx2] != honests[idx2]:
                    ok = False
    if ok:
        answer = max(answer, honests.count(1))

print(answer)

Measured memory_bytes: 68192
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int i,n;
	double sum,x;
	char u[4];
	scanf("%d",&n);
	sum=0.0;
	for(i=0;i<n;i++)	{
		scanf("%lf %s",&x,u);
		if(strcmp(u,"JPY")==0)	sum+=x;
		else sum+=x*380000.0;
	}
	printf("%lf\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    vector<int> P(N); repp(i,0,N) cin >> P[i];
    vector<int> Q(N); repp(i,0,N) cin >> Q[i];
    vector<int> s(N); repp(i,1,N+1) s[i-1] = i;
    sort(s.begin(), s.end());
    vector<vector<int>> v;
    while(next_permutation(s.begin(), s.end())) {
        v.push_back(s);
    };
    int p = upper_bound(v.begin(), v.end(), P) - v.begin();
    int q = upper_bound(v.begin(), v.end(), Q) - v.begin();
    cout << abs(p - q) << endl;
}



Measured memory_bytes: 3256
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;
long long ans=0,tmp[10]={};
string s;
void saiki(int n,int fir,int len,long long sum){
	tmp[n]=stoll(s.substr(fir,len));
	if(n==0){
		sum+=tmp[n];
		ans+=sum;
		return;
	}
	saiki(n-1,fir-1,len+1,sum);
	saiki(n-1,fir-1,1,sum+tmp[n]);
}

int main(void) {
	cin>>s;
	long long k=s.size();
	saiki(k-1,k-1,1,0);
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    int n; cin>>n;
    int x; cin>>x;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    sort(all(a));
    int mina=a.front();
    rep(i,n)x-=a.at(i);
    cout<<x/mina+n<<endl;
}

Measured memory_bytes: 256
import itertools


n = int(input())

XY = {xy:0 for xy in itertools.product("0123456789", repeat = 2)}
for i in range(1, n + 1):
    x, y = str(i)[0], str(i)[-1]
    XY[(x, y)] += 1

answer = 0
for a in range(1, n + 1):
    x, y = str(a)[0], str(a)[-1]
    answer += XY[(y, x)]

print(answer)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<ll, ll>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> ans;
    for (int i=1; i<=N; i+=2) ans.push_back(i);
    cout << (ans.size() >= K ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().rstrip().split(' '))
G = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().rstrip().split(' '))
  a-=1
  b-=1
  G[a].append(b)
  G[b].append(a)

for i in range(n):
  print(len(G[i]))


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
S = list(input())
LR = [list(map(int,input().split())) for _ in range(Q)]
lis = []
s = [0]*N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        s[i] = 1

L = [0]*(N+1)
R = [0]*N

tmp = 0
for ind,i in enumerate(s):
    if i == 1:
        tmp += 1
    L[ind+1] = tmp

tmp = 0
for i in range(N-2,-2,-1):
    if s[i] == 1:
        tmp += 1
    R[i+1] = tmp

R.append(0)
sums =sum(s)
for i in range(Q):
    ans = sums-L[LR[i][0]-1]-R[LR[i][1]]
    print(ans)

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

using namespace std;

#define N 100000

int n;
int a[2*N+5];

int check(int x) {
	for(int i = 0; i < n-1; ++i) {
		if((a[n-i] <= x && a[n-i-1] <= x) || (a[n+i] <= x && a[n+i+1] <= x)) return 1;
		else if((a[n-i] > x && a[n-i-1] > x) || (a[n+i] > x && a[n+i+1] > x)) return 0;
	}
	return a[1] <= x;
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= 2*n-1; ++i) scanf("%d", &a[i]);
	int l = 1, r = 2*n-1;
	while(l != r) {
		int mid = l+r>>1;
		if(check(mid)) r = mid;
		else l = mid+1;
	}
	printf("%d\n", r);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007; 
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE x(n), y(n), h(n); rep(i, n)cin >> x[i] >> y[i] >> h[i];
	rep(i,101) {
		rep(j,101) {
			int tmp = 0;
			rep(k, n) {
				if (h[k]) {
					tmp = h[k] + abs(i - x[k]) + abs(j - y[k]);
					break;
				}
			}
			bool ok = true;
			rep(k, n) {
				if (h[k] != max((ll)0, tmp - abs(i - x[k]) - abs(j - y[k]))) {
					ok = false; break;
				}
			}
			if (ok)cout << i << " " << j << " " << tmp << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int s[500001],sum=0;

void mergesort(int *,int,int);
void merge(int *,int,int,int);
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  mergesort(s,0,n);
  for(i=0;i<n;i++){
    printf("%d",s[i]);
    if(i==n-1){
      printf("\n");
    }else{
      printf(" ");
    }
  }
  printf("%d\n",sum);
}

void mergesort(int s[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(s,left,mid);
    mergesort(s,mid,right);
    merge(s,left,mid,right);
  }
}

void merge(int s[],int left,int mid,int right){
  int n1,n2,L[mid-left],R[right-mid],i,j,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=s[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=s[mid+i];
  }
  L[n1]=1000000001;
  R[n2]=1000000001;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    sum++;
    if(L[i]<=R[j]){
      s[k]=L[i];
      i++;
    }else{
      s[k]=R[j];
      j++;
    }
  }
}




Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    V<ll> a(n);
    priority_queue<ll> que;
    rep(i,n){
        cin>>a[i];
        que.push(a[i]);
    }
    while(m--){
        ll v=que.top();
        que.pop();
        v/=2;
        que.push(v);
    }
    ll ans=0;
    while(!que.empty()){
        ans+=que.top();
        que.pop();
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll x, a, b;
  cin >> x >> a >> b;
  ll y, z;
  if(x>=a){
    y = x - a;
  }
  else{
    y = a - x;
  }
  if(x>=b){
    z = x - b;
  }
  else{
    z = b - x;
  }
  if(y>z){
    print('B');
  }
  else{
    print('A');
  }
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  rep(i, n) cin >> a[i] >> b[i];

  sort(a, a + n);
  sort(b, b + n);

  int ans = 0;
  if (n % 2 == 1) {
    int mn = a[n / 2], mx = b[n / 2];
    ans = mx - mn + 1;
  } else {
    double mn = (a[n / 2] + a[n / 2 - 1]) / 2.0;
    double mx = (b[n / 2] + b[n / 2 - 1]) / 2.0;
    ans = (mx - mn) * 2 + 1;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5196
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,m, sum = 0;
    cin >> n >> m;
    if(n >= m)cout << 0 << endl;
    else{
        int x[m], l[m - 1];
        for(int i = 0;i < m;i++)cin >> x[i];
        sort(x, x + m);
        for(int i = 0;i < m - 1;i++)l[i] = x[i + 1] - x[i];
        sort(l, l + m - 1);
        for(int i = 0;i < n - 1;i++)sum += l[m - 2 - i];
        cout << x[m - 1] - x[0] - sum << endl;
    }
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>
using namespace std;

int n;
vector<pair<int,int> > e[111111];
vector<int> Q;

int sz[111111],mxsz[111111];
void dfs_sz_down(int x,int fat){
	sz[x] = 1;
	mxsz[x] = 0;
	for(vector<pair<int,int> >::iterator it = e[x].begin(); it != e[x].end(); it++){
		int y = it->first;
		if(y == fat)continue;
		dfs_sz_down(y, x);
		mxsz[x] = max(mxsz[x], sz[y]);
		sz[x] += sz[y];
	}
	mxsz[x] = max(mxsz[x], n-sz[x]);
	if(mxsz[x] <= n/2){
		Q.push_back(x);
	}
}

long long int res[111111];

void dfs(int x,int fat){
	sz[x] = 1;
	res[x] = 0;
	for(vector<pair<int,int> >::iterator it = e[x].begin(); it != e[x].end(); it++){
		int y = it->first;
		if(y == fat)continue;
		dfs(y, x);
		sz[x] += sz[y];
		res[x] += res[y] + (long long int)sz[y] * it->second;
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		e[x].push_back(make_pair(y,z));
		e[y].push_back(make_pair(x,z));
	}
	dfs_sz_down(1,1);
	long long int bes = 0;
	for(vector<int>::iterator it = Q.begin(); it!=Q.end(); it++){
		int x = *it;
		dfs(x, x);
		long long int now = res[x] * 2, v = now;
		for(vector<pair<int,int> >::iterator it2 = e[x].begin(); it2!=e[x].end(); it2++)
			if(Q.size() == 1 || (Q.size() == 2 && (it2->first) == Q[0] + Q[1] - x))
				v = min(v, (long long int)(it2->second));
		bes = max(bes, now - v);
	}
	cout << bes << endl;
	return 0;
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

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

   ll n,k; cin>>n>>k;
   vll v(n+1);

   for(int i=1;i<=n;i++) cin>>v[i];
   ll mark[n+3],step[n+3]; mem(mark,-1); mem(step,0);

   int ic,dis,inc=1;
   mark[1]=0; step[0]=1;

   for(int i=1;;){
    int nxt=v[i];
    if(mark[nxt]>-1){
        dis=mark[nxt]-mark[1];
        ic=nxt;
        break;
    }
    else{ mark[v[i]]=inc;
    step[inc++]=v[i];
    i=v[i];
    }
   }

   if(k<=dis) {
    cout<<step[k]<<endl;
   }
   else{
    k-=dis;inc=1;
    mem(step,0);
    mem(mark,-1);
    step[0]=ic;
    mark[ic]=0;
    for(int i=ic;;) {
        int nxt=v[i];
        if(mark[nxt]>-1){
        dis=mark[nxt]-mark[1];
        ic=nxt;
        break;
    }
    else{ mark[v[i]]=i;
    step[inc++]=v[i];
    i=v[i];
    }
    }
    ll rem=k%inc;
    cout<<step[rem]<<endl;
   }
   End;
}


Measured memory_bytes: 7952
// failed to generate code

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

int main(){	
	ll N, M, MM = 0;
	cin >> N >> M;
	vector<ll> A(N), B(M), C(M);
	for (ll i=0; i<N; i++) {
		cin >> A[i];
	}
	map<ll, ll> m;
	for (ll i=0; i<M; i++) {
		cin >> B[i] >> C[i];
		if (m[C[i]] == 0) MM++;
		m[C[i]] += B[i];
	}
	sort(A.begin(), A.end());
	sort(C.begin(), C.end(), greater<ll>());
	unique(C.begin(), C.end());

	ll idx = 0, count = 0, upd = 0;
	for (ll i=0; i<N; i++) {
		if (A[i] < C[idx]) {
			upd += C[idx];
			count++;
			// cout << "i:" << i << " m[C[idx]]:" << m[C[idx]] << endl;
			m[C[idx]]--;
		}
		if (m[C[idx]] == 0) idx++;
		if (idx == MM) break;
		if (count == N) break;
	}
	ll res = 0;
	sort(A.begin(), A.end(), greater<ll>());
	for (ll i=0; i<N-count; i++) {
		res += A[i];
	}
	res += upd;
	// cout << count << " " << upd << endl;
	cout << res << endl;
	return 0;
}


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

#define inRange(x, y, w, h) (0 <= x && x < w && 0 <= y && y < h)

using namespace std;

struct Point {
	int x;
	int y;
	int count;
};

int main( void )
{
	int dx[] = { 0, 0, -1, 1 };
	int dy[] = { -1, 1, 0, 0 };
	int w, h;
	int map[60][60];
	while(cin >> w >> h, w | h) {
		w = 2 * w - 1; h = 2 * h - 1;
		for(int y=0; y < h; ++y)
			for(int x=0; x < w; ++x) map[y][x] = 9999;
		for(int y=0; y < h; ++y) {
			int input;
			for(int x=(y+1)%2; x < w; x+=2) { cin >> input; map[y][x] = (input)? 0 : 9999; }
		}
		for(int y=1; y < h; y+=2)
			for(int x=1; x < w; x+=2) {
				for(int d=0; d < 4; ++d) {
					int mx = x + dx[d];
					int my = y + dy[d];
					if(inRange(mx, my, w, h) && !map[my][mx]) {
						map[y][x] = 0;
						break;
					}
				}
			}

		Point tmp;
		queue<Point> q;
		tmp.x = tmp.y = 0; tmp.count = map[0][0] = 1;
		q.push(tmp);
		while(!q.empty()) {
			tmp = q.front(); q.pop();
			for(int d=0; d < 4; ++d) {
				int mx = tmp.x + dx[d];
				int my = tmp.y + dy[d];
				if(inRange(mx, my, w, h) && tmp.count+1 < map[my][mx]) {
					Point tmp2;
					tmp2.x = mx;
					tmp2.y = my;
					tmp2.count = map[my][mx] = tmp.count + 1;
					q.push(tmp2);
				}
			}
		}
		int answer = 0;
		if(map[h-1][w-1] != 9999)
			answer = (map[h-1][w-1] + 1) / 2;
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 924