akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = Integer.parseInt(scanner.next());
        ArrayList<Long> list = new ArrayList();
        for (long i = 1; i < 10; i++) {
            list.add(i);
        }
        if (k < 10) {
            System.out.println(list.get(k-1));
            return;
        }
        k -= 9;
        long one;
        ArrayList<Long> tmp = new ArrayList();
        while (!list.isEmpty()) {
            tmp = new ArrayList();
            for (long li: list) {
                one = li%10;
                if (one == 0) {
                    tmp.add(li*10 + 0);
                    tmp.add(li*10 + 1);
                    k -= 2;
                } else if (one == 9) {
                    tmp.add(li*10 + 8);
                    tmp.add(li*10 + 9);
                    k -= 2;
                } else {
                    for (long i = one-1; i < one+2; i++) {
                        tmp.add(li*10 + i);
                    }
                    k -= 3;
                }
            }
            if (k <= 0) {
                break;
            }
            list = tmp;
        }
        System.out.println(tmp.get(tmp.size() - 1 -  Math.abs(k)));
    }
}

Measured memory_bytes: 31188
fn conn(adjl: &Vec<Vec<usize>>, v: usize, used: &mut usize) {
    for &u in &adjl[v] {
        if (1usize << u) & *used == 0 {
            *used |= 1usize << u;
            conn(adjl, u, used);
        }
    }
}
fn solve() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut edges = vec![];
    for i in 0..m {
        let (u, v): (usize, usize) = (read::<usize>() - 1, read::<usize>() - 1);
        edges.push((u, v))
    }
    let mut res = 0;
    let all = (1 << n) - 1;
    for i in 0..m {
        let mut adjl = vec![vec![]; n];
        for j in 0..m {
            if j == i {
                continue;
            }
            adjl[edges[j].0].push(edges[j].1);
            adjl[edges[j].1].push(edges[j].0);
        }
        let mut visited: usize = 1;
        conn(&adjl, 0, &mut visited);
        if visited != all {
            res += 1;
        }
    }
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2240
ar = gets.split
dd = gets.split

n = ar[0].to_i
m = ar[1].to_i
#p dd.map!{|x| x.to_i}
dsum = dd.map!{|x| x.to_i}.inject(:+)

cnt = 0
for j in 1..n do
  if (dd[j-1] >= dsum/(4.0*m)) then
    cnt = cnt+1
  end
end
    
if (cnt<m) then
  puts( "No" )
elsif
  puts( 'Yes')
end

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

namespace AtCoder
{
    class Store
    {
        public long price;
        public long num;
        public long sum;
    }

    class Program
    {

        static void Main()
        {
            //ここから
            int[] str = ReadLineToIntArray();
            int N = str[0];
            int M = str[1];

            List<Store> stores = new List<Store>();

            for(int i = 0; i < N; i++)
            {
                stores.Add(new Store());
                long[] temp = ReadLineToLongArray();
                stores[i].price = temp[0];
                stores[i].num = temp[1];
                stores[i].sum = temp[0] * temp[1];
            }

            stores = stores.OrderBy(s => s.price).ToList();

            long sum = 0, ans = 0;

            while (sum < M)
            {
                foreach(var store in stores)
                {
                    if (sum + store.num <= M)
                    {
                        sum += store.num;
                        ans += store.sum;
                    }
                    else
                    {
                        ans += store.price * (M - sum);
                        sum += M - sum;
                        break;
                    }
                }
            }

            //ここまで


            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }



        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }



    }
}


Measured memory_bytes: 26928
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 100001;

ll fact[N_MAX], rfact[N_MAX];

ll perm(ll n, ll r){
    return (fact[n] * rfact[r]) % MOD;
}

ll comb(ll n, ll r){
    return (perm(n, r) * rfact[n-r]) % MOD;
}

void init(ll n){
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(int i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    if(k == 1) {
        cout << 0 << endl;
        return 0;
    }

    init(n);

    vector<ll> c(n, 0);
    if(k-2 == 0) c[0] = 1;
    for(int i=max(1, k-2);i<n;++i) {
        c[i] = c[i-1] + comb(i, k-2);
        c[i] %= MOD;
    }

    ll ans = 0LL;
    for(int i=0;i<n;++i) {
        ll coef = 0;
        // cerr << i << endl;
        if(n-2-i >= k-2) {
            // cerr << "\t" << n-2-i << endl;
            coef += MOD - c[n-2-i];
            coef %= MOD;
        }
        if(i-1 >= k-2) {
            // cerr << "\t" << i-1 << endl;
            coef += c[i-1];
            coef %= MOD;
        }
        if(a[i] < 0) a[i] += MOD;
        ans += (a[i] * coef) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


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

using namespace std;

#define int long long

void solve() {
    string s;
    cin >> s;
    set <char> kek;
    for (int i = 0; i < s.size(); ++i) kek.insert(s[i]);
    /*if (s[2] == s[3] && s[4] == s[5] && kek.size() == 4) cout << "Yes";
    else cout << "No";*/
    if (s[2] == s[3] && s[4] == s[5] && s[1] != s[0] && s[1] != s[2] && s[1] != s[4] && s[0] != s[2] && s[0] != s[4]) {
        cout << "Yes";
    }
    else cout << "No";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 1e9;

int main(){
  int N, E, T;
  cin >> N >> E >> T;
  vector<int> W(N);
  for(int i = 0; i < N; ++i) cin >> W[i];
  vector<int> G(E), C(E);
  vector<vector<int>> S(E);
  for(int i = 0; i < E; ++i){
    cin >> G[i] >> C[i];
    --G[i];
    for(int j = 0; j < C[i]; ++j){
      int s;
      cin >> s;
      S[i].push_back(s-1);
    }
  }

  for(int i = 0; i < N; ++i)
    if(not W[i])
      W[i] = 1e9;
  
  vector<bool> checked(E,false);
  int c = 0;
  for(int i = 0; i < E; ++i){
    int c_ = c;
    for(int j = 0; j < E; ++j){
      if(checked[j]) continue;
      bool f = true;
      for(int k = 0; k < C[j]; ++k)
        if(W[S[j][k]] >= INF){
          f = false;
          break;
        }
      if(not f) continue;
      vector<int> T;
      for(int k = 0; k < C[j]; ++k){
        T.push_back(W[S[j][k]]);
      }
      int t = 0;
      sort(T.rbegin(),T.rend());
      for(int k = 0; k < C[j]; ++k)
        t = max(t,k+T[k]);
      W[G[j]] = min(W[G[j]],t);
      ++c_;
      checked[j] = true;
    }
    if(c == c_) break;
    c = c_;
    if(c == E) break;
  }
  if (W[T-1] >= INF) {
    cout << -1 << endl;
  } else {
    cout << W[T-1] << endl;
  }
}



Measured memory_bytes: 3196
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
import itertools as it
#======================================================#
def main():
    s = IS()
    n = len(s)

    def calc(bits):
        sumv = 0
        for i in range(len(bits)-1):
            sumv += int(s[bits[i]:bits[i+1]])
        return sumv

    ans = 0
    for bit in range(1<<(n-1)):
        bits = [0]
        for i in range(n-1):
            if bit&(1<<i):
                bits.append(i+1)
        bits += [n]
        ans += calc(bits)
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

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

  vector<int> cnts(8, 0);
  int other = 0;
  for (int i = 0; i < n; ++i) {
    int a = va[i];
    if (a < 400) {
      cnts[0]++;
    } else if (a < 800) {
      cnts[1]++;
    } else if (a < 1200) {
      cnts[2]++;
    } else if (a < 1600) {
      cnts[3]++;
    } else if (a < 2000) {
      cnts[4]++;
    } else if (a < 2400) {
      cnts[5]++;
    } else if (a < 2800) {
      cnts[6]++;
    } else if (a < 3200) {
      cnts[7]++;
    } else {
      other++;
    }
  }

  int ans_min = 0;
  for (int i = 0; i < cnts.size(); ++i) {
    ans_min += cnts[i] > 0;
  }

  int ans_max = ans_min + other;
  cout << max(1, ans_min) << ' ' << ans_max << '\n';
  return 0;
}

Measured memory_bytes: 3472
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()
 
 
 
 
//s.reserve(32768); //updated !
//s.max_load_factor(0.25);

const int N=1e5+5;







int main(){

    int n;
    cin>>n;
    string s;
    cin>>s;
    int x=0;
    int ans=INT_MAX;int white=0;int red=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')red++;
        else white++;
    }

    ans=min(ans,red);

    for(int i=0;i<n;i++){
        if(s[i]=='R')x++;
        int d=min(i+1-x,red-x);
        ans=min(ans,d+red-x-d+i+1-(x+d));
    }

    ans=min(ans,white);

    cout<<ans<<endl;


}
 
    
 
 
 
    
 
 
 
    
    
    
 
 
 
 
    
 
 
    
 
    
 
 
 
 
 
 
    
    
 
    
 
    
 
 
 
 
    
 


Measured memory_bytes: 3752
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define FORR(i, a, b) for(long long i=(a);i>=(b);i--)
#define REPR(i, N) for(long long i=n;i>=0;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(s) (s).begin(),(s).end()
#define pb(a) push_back(a)

#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

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

ll N,L;
string S[110];

int main(){
    cin >> N >> L;
    
    REP(i,N){
        cin >> S[i];
    }

    SORT(S,N);

    REP(i,N){
        cout << S[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

int main(){
	//IOS;
	int n,x;cin>>n;
	// int a,b,c;cin>>a>>b>>c;
	// string str;cin>>str;
	

	 vector<int> l(n);
	// vector<string> s(n);
	
	for(int i=0;i<n;i++){
		cin>>l[i];
	}
	double sum=0;
	for(int i=0;i<n;i++){
		sum+=1.0/l[i];
	}
	cout<<std::fixed << std::setprecision(15)<<1.0/sum;

	





	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int n,ba = 0,jun = 0;
	String a;
	while(true){
	    n = scan.nextInt();
	    if(n == 0) break;
	    int[] mochi = new int[n];
	    a = scan.next();
	    char fuda[] = a.toCharArray();
	    for(int i = 0; i<100; i++){
		switch(fuda[i]){
		case 'M':
		    if(jun == n) jun = 0;
		    mochi[jun] += 1;
		    jun++;
		    break;
		case 'S':
		    if(jun == n) jun = 0;
		    ba += mochi[jun] + 1;  //banidasu
		    mochi[jun] =0;  //mochifudazero
		    jun++;
		    break;
		case 'L':
		    if(jun == n) jun = 0;
		    mochi[jun] += ba +1;
		    ba = 0;
		    jun++;
		    break;
		}
	    }
	    Arrays.sort(mochi);
	    for(int i = 0;i<mochi.length;i++){
		System.out.print(mochi[i]);
		System.out.print(" ");
	    }
	    System.out.println(ba);
	    jun = 0; ba = 0;
	}
    }
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int n = 5;
    vi t = { a, b, c, d, e }, nt(n);
    vi index(n);
    rep(i, n) index[i] = i;
    int ans = INF;
    do {
        int cnt = 0;
        rep(i, n) {
            while (cnt % 10 != 0) ++cnt;
            cnt += t[index[i]];
        }
        ans = min(ans, cnt);
    } while (next_permutation(all(index)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()

A = 0
B = 0
i = 0
while(True):
 A += a[i]
 i += 1
 if i==n: break
 B += a[i]
 i += 1
 if i==n: break

print(A-B)

Measured memory_bytes: 3064
/**
 *      ABC 96 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-16 15:13:20
**/

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

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

    int H, W; cin >> H >> W;
    string s[H + 2] = {};
    for (int i = 1; i <= H; ++i) {
        cin >> s[i];    
    }

    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j < W - 1; ++j) {
            if (s[i][j] == '#'){
                if ((s[i - 1][j] != '#' && s[i + 1][j] != '#') && (s[i][j - 1] != '#' && s[i][j + 1] != '#')){
                    cout << "No" << endl; return 0;
                }
            }
        }
    }

    for (int i = 1; i <= H; ++i) {
        if (s[i][0]  == '#'){
            if ((s[i - 1][0] != '#' && s[i + 1][0] != '#') && s[i][1] != '#'){
                cout << "No" << endl; return 0;
            }
        }    
    }

    for (int i = 1; i <= H; ++i) {
        if (s[i][W - 1] == '#'){
            if ((s[i - 1][W - 1] != '#' && s[i + 1][W - 1] != '#') && s[i][W - 2] != '#'){
                cout << "No" << endl; return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

int main()
{
    int a, b, k;
    cin >> a >> b;

    if ((a + b) % 2 == 1)
    {
        cout << "IMPOSSIBLE";
    }
    else
    {
        cout << (a + b) / 2;
    }

    return 0;
}

Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u32> = procon_read();
	let a = v[0];
	let b = v[1];
	let t = v[2];
	let mut check = 0;
	let mut ret = 0;
	for i in 1.. {
		check = i*a;
		if check > t {
			break;
		}
		ret += b;
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    ll cnt=0;
    rep(i,0,a+1){
        rep(j,0,b+1){
            rep(k,0,c+1){
                if(500*i+100*j+50*k==x) cnt++;
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ll a,b,c;
    ll k;
    cin >> a >> b >> c >> k;
    ll aa, bb , cc;
    aa = b+c;
    bb = a+c;
    cc = a+b;
    if(k&1){
        if(aa-bb > 1e18)
            cout <<"Unfair" << endl;
        else
            cout << aa-bb << endl;
    }
    else{
        if(a-b > 1e18)
            cout <<"Unfair" << endl;
        else
            cout << a-b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;


const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

int h, w;
vector<vector<char>> v(1000, vector<char>(1000, '#'));
vector<vector<int>> ans(1000,vector<int>(1000,-1));
void solve(int i,int j){
    deque<pair<int,int>> q;
    ans[i][j] = 0;
    q.push_back(make_pair(i,j));
    while(!q.empty()){
        pair<int,int> p=q.front();
        q.pop_front();
        int a=p.first;
        int b=p.second;
        //cout << a << " " << b << endl;
        REP(x,5){
            int k=x-2;
            REP(y,5){
                int l=y-2;
                if(k==0&&l==0){
                    continue;
                }
                int nh=a+k;
                int nw=b+l;
                if (nh < 0 || nh >= h || nw < 0 || nw >= w){
                    continue;
                }
                if(v[nh][nw]=='#'){
                    continue;
                }
                if(k*l==0&&(abs(k)==1||abs(l)==1)&&(ans[nh][nw]==-1||ans[nh][nw]>ans[a][b])){
                    q.push_front(make_pair(nh,nw));
                    ans[nh][nw]=ans[a][b];
                    continue;
                }
                if (ans[nh][nw] == -1 || ans[nh][nw] > ans[a][b]+1){
                    q.push_back(make_pair(nh, nw));
                    ans[nh][nw] = ans[a][b]+1;
                }
            }
        }
    }
}
int main()
{
    cin >> h >> w;
    int sh,sw,gh,gw;
    cin >> sh >> sw >> gh >> gw;
    REP(i,h){
        REP(j,w){
            cin >> v[i][j];
        }
    }
    sh--;sw--;gh--;gw--;
    solve(sh,sw);
    cout << ans[gh][gw] << endl;
}


Measured memory_bytes: 8524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T> inline T sqr(T t) {return t*t;}
#define pb push_back
#define mp make_pair
#define endl "\n"

inline void files(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef _WIN32
        return;
    #endif // _WIN32
    //freopen("lca.in", "r", stdin);//freopen("output.out", "w", stdout);
}

int n, k;

ll d[100100];

vector <pair<int, int> > g[100100];

void dfs(int v, int p){
    for (int i = 0; i < g[v].size(); i++){
        int to = g[v][i].first;
        ll len = g[v][i].second;
        if (to==p)
            continue;
        d[to] = d[v] + len;
        dfs(to, v);
    }
}

int main(){
    files();
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v, c;
        cin >> u >> v >> c;
        g[u].pb({v, c});
        g[v].pb({u, c});
    }
    int q;
    cin >> q >> k;
    dfs(k, 0);
    while(q--){
        int a, b;
        cin >> a >> b;
        ll ans = d[a] + d[b];
        cout << ans << endl;
    }
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int Digits(llong num){
  int cnt = 0;
  while(num > 0){
    num / 10;
    cnt++;
  }
  return cnt;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int len = S.size();
    int A_i,Z_i;
    for(int i = 0; i < len; ++i){
      if(S[i] == 'A'){
        A_i = i;
        break;
      }
    }
    for(int i = len -1; i > 0;i--){
      if(S[i] == 'Z'){
        Z_i = i;
        break;
      }
    }
    
  
    cout << Z_i - A_i + 1 << endl;
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    long long N,M; cin >> N >> M;
    M = M/2;
    if(N>M) cout << M << endl;
    else cout << (N+M)/2 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
    int N,M; cin >> N >> M;
    vector<pair<int, int>> A(M);
    rep(i,M) {
        int a,b; cin >> a >> b;
        a--; b--;
        A[i] = make_pair(b,a);
    }

    sort(all(A));
    int count = 0;
    int k = -1;
    rep(i,M) {
        int a,b;
        tie(b,a) = A[i];
        if (k < a) {
            count++;
            k = b-1;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.IRT", "r", stdin );
	int n;
	scanf ("%d", &n );

	rep (i, n ){
		bool ok = false;
		int side[3] = {0};
		rep (j, 3 ){
			scanf ("%d", &side[j] );
		} // end rep
		sort (side, side+3 );
		if (side[0] == 0 || side[1] == 0 || side[2] == 0 ) ok = false;
		else
		if (side[2] > side[0] + side[1] ) ok = false;
		if (side[2]*side[2] == side[0]*side[0] + side[1]*side[1] ) ok = true;

		cout << (ok ? "YES" : "NO" ) << endl;
	} // end rep

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

using ordered_set = tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
struct CMP {
	bool operator() (const T& lhs, const T& rhs) const{
		return lhs < rhs;
	}
};

template <typename T>
T power(T a, T n){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a);
		a = (a * a);
		n >>= 1;
	}
	
	return res;
}

template <typename T>
T power(T a, T n, long long mm){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a) % mm;
		a = (a * a) % mm;
		n >>= 1;
	}
	
	return res;
}

const ll N = 2e5+7;
const ll MOD = 1e9+7;
const ll INF = 2e14+7;

vector<int> edges[N];
int dp[N];

int dfs(int s){
	
	//debug2(s, dp[s]);
	
	if(dp[s] != -1) return dp[s];
	
	dp[s] = 0;
	
	for(auto v: edges[s]){
		dp[s] = max(dp[s], dfs(v) + 1);
	}
	
	return dp[s];
	
}

void testcase(){
	int n, m, u, v;
	cin>>n>>m;
	
	for(int i = 0; i < m; i++){
		cin>>u>>v;
		edges[u].pb(v);
	}
	
	memset(dp, -1, sizeof(dp));
	
	for(int i = 1; i <= n; i++){
		//debug2(i, dp[i]);
		if(dp[i] == -1){
			dfs(i);
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, dp[i]);
	}
	
	cout<<ans<<'\n';
}

signed main(){
	fast;
	
	int t = 1;
	//cin>>t;
	while(t--){
		testcase();
	}
	
	return 0;
}


Measured memory_bytes: 10240
n, W = gets.chomp.split.map(&:to_i)

dp = Array.new(W+1,0)

n.times do |i|
  w, v = gets.chomp.split.map(&:to_i)
  W.downto(0).each do |weight|
    if w <= weight
      dp[weight] = dp[weight-w] + v if dp[weight] < dp[weight-w] + v
    end
  end
end

# dp.each{|line| p line}
# p dp
puts dp[W]


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}

const int Max=1e6+9;
const int OO=-1e6;
int st[4]= {1,0,0,-1};
int nt[4]= {0,1,-1,0};
int n,m;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
ll mem[Max];
void init()
{
    memset(mem,-1,sizeof mem);
}
//////////////////////////////////////////////////////////

ll a[Max];
ll solve (int i  )
{
    if(i==n-1)return 0;
    if(i>=n)return Max;
    ll &ret=mem[i];
    if(~ret)return ret;

    ll take1 =solve(i+1)+abs(a[i]-a[i+1]);
    ll take2 =solve(i+2)+abs(a[i]-a[i+2]);
    return mem[i]=min(take2,take1);
}

void Fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
   init();
   n =D();
   for(int i=0; i<n;i++)
   {
       a[i]=llD();
   }
   printf("%lld",solve(0));

}


Measured memory_bytes: 18540
#include <stdio.h>
#include <cmath>

using namespace std;

int main(){
    int h, w, n;
    int r, c;
    char s[200000];
    char t[200000];

    scanf("%d %d %d", &h, &w, &n);
    scanf("%d %d", &r, &c);
    scanf("%s", s);
    scanf("%s", t);

    int out_r = c;
    int out_l = c;
    int out_u = r;
    int out_d = r;

    for(int i = 0; i < n; i++){
        switch (s[i])
        {
        case 'L':
            out_l--;
            break;
        case 'R':
            out_r++;
            break;
        case 'U':
            out_u--;
            break;
        case 'D':
            out_d++;
            break;
        }

        if(out_l <= 0 || out_r > w || out_u <= 0 || out_d > h){
            printf("NO\n");
            
            return 0;
        }

        switch (t[i])
        {
        case 'L':
            if(out_r > 1) out_r--;
            break;
        case 'R':
            if(out_l < w) out_l++;
            break;
        case 'U':
            if(out_d > 1) out_d--;
            break;
        case 'D':
            if(out_u < h) out_u++;
            break;
        }
    }

    printf("YES\n");
    return 0;
}

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

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a > b) swap(b, a);
	else if (b > c) swap(c, b);
        if (a > b) swap(b, a);
	else if (b > c) swap(c, b);
	if (a > b) swap(b, a);
	else if (b > c) swap(c, b);
	
	cout << a << " " << b << " " << c << endl;
}

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

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;


//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cout << x[i] << " ";
        }
        cout << x[x.size()-1] <<endl;
    }
}

template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cout << q.front() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

int main(void) {
    int n;
    cin >> n;
    
    vector<int> vl;
    priority_queue<int> pql;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        pql.push(tmp);
    }
    REP(i, n) {
        vl.push_back(pql.top());
        pql.pop();
    }
    //vecprint(vl);
    
    int ans = 0;
    REP(i, n-2) {
        FOR(j, i+1, n-1) {
            int idx = 1;
            while(j+idx < n) {
                //cout << vl[i] << ", " << vl[j] << ", " << vl[j+idx] << endl;
                if(vl[i] >= vl[j] + vl[j+idx]) break;
                idx++;
            }
            ans += idx-1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e6+5;
const long long INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve() {
    int n, k;
    cin >> n >> k;
    vector< int > v(n+1) , vis(n+1 ,0);
    for(int i=1;  i<=n ; i++){
        cin >> v[i];
    }
    int start = 1 , pos_where_cylce_start = -1 , cnt = 0, total = 0;
    while(1){
        if(vis[start]){
            pos_where_cylce_start = start;
            break;
        }
        total++;
        vis[start] = 1;
        start = v[start];
    }
    start = 1;
    while(1){
        if(start == pos_where_cylce_start){
            break;
        }
        cnt++;
        start = v[start];
    }
    if(k < cnt){
     	start = 1;
        while(k--){
            start = v[start];
        }
        cout << start << endl;
        return;
    }
    k-=cnt;
    int cylce_contains = total - cnt;
    k = k%cylce_contains;
    start = pos_where_cylce_start;
    while(k--){
        start= v[start];
    }
    cout << start << endl;


}

signed main(){
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/*Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/


Measured memory_bytes: 6352
N = int(input())
S = input()

out = ""
i = 0
while True:
    end = False
    if i == N-1:
        out += S[i]
        break
    for j in range(i+1, N):
        if S[i] == S[j]:
            end = True
            continue
        else:
            out += S[i]
            i = j
    if end:
        out += S[i]
        break

print(len(out))

Measured memory_bytes: 3316
a = input().split()
if(a[0] == 'H'):
    if(a[1] == 'H'):
        print("H")
    if(a[1] == 'D'):
        print("D")
if(a[0] == 'D'):
    if(a[1] == 'H'):
        print("D")
    if(a[1] == 'D'):
        print('H')

Measured memory_bytes: 3060
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();

    if a + b == c || b + c == a || c + a == b {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
N, M, *A = $<.read.split.map &:to_i
x, y, z = A.select &:odd?
if z
  puts :Impossible
  exit
end
puts a = [*x, *A.select(&:even?), *y]
b = []
a.map do |x|
  if x % 2 == 0
    if b.empty?
      b = [1]
    else
      b[-1] += 1
    end
    if x == 2
      b << 1
    elsif x == 4
      b << 3
    else
      b << x - 4 << 3
    end
  else
    if b.empty?
      b = [2] * (x / 2) + [1]
    else
      b[-1] += 1
      b += [2] * (x / 2)
    end
  end
end
puts b.size, b


Measured memory_bytes: 2940
#include <stdio.h>

int main() {
    int m, n;
    scanf("%d %d", &n, &m);
    int a[n][m], b[m];
    for (int y = 0; y < n; y++){
        for (int x = 0; x < m; x++) {
            scanf("%d", &a[y][x]);
        }
    }
    for (int z = 0; z < m; z++){
        scanf("%d", &b[z]);
    }
    for (int i = 0; i < n; i++){
        int sum = 0;
        for (int j = 0; j < m; j++){
            sum = sum + a[i][j]*b[j];
        }
        printf("%d\n", sum);
    }
    
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

struct Window
{
  int begin, end;
};

int main()
{
  int n, h, w;
  cin >> n >> h >> w;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;

  vector<Window> wins(n);

  for (int i = 0; i < n; ++i)
  {
    wins[i].begin = i * w;
    wins[i].end = (i + 1) * w;
  }

  for (int i = 0; i < n; ++i)
  {
    if (i % 2 == 0)
    {
      wins[i].begin += a[i];
      wins[i].end += a[i];
    }
    else
    {
      wins[i].begin -= a[i];
      wins[i].end -= a[i];
    }
  }

  int area[10010] = {};
  for (int i = 0; i < n; ++i)
  {
    for (int j = wins[i].begin; j < wins[i].end; ++j)
    {
      area[j]++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n * w; ++i)
  {
    if (!area[i])
      cnt++;
  }
  cout << cnt * h << endl;

  return 0;
}



Measured memory_bytes: 3152
a = list(map(int, input().split()))
ans = 0
even = [i % 2 for i in a]
if not(even[0] == even[1] == even[2]):
    ans += 1
    if even[0] == even[1]:
        a[0] += 1
        a[1] += 1
    elif even[1] == even[2]:
        a[1] += 1
        a[2] += 1
    elif even[2] == even[0]:
        a[2] += 1
        a[0] += 1

ans += (max(a) * 3 - sum(a)) // 2
print(ans)




Measured memory_bytes: 3188
#include<stdio.h>

int main()
{
    int x,y,s,k;
    int ret=0;

    scanf("%d%d",&k,&s);
    
    for(x=0;x<=k;x++)
    {
        for(y=0;y<=k;y++)
        {
            if(s-x-y<0) break;
            if(s-x-y<=k)
            {
                ret++;
            }
        }
    }

    printf("%d\n",ret);
    return 0;
}

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

#define FOR(i,a,b) for(int i = (a);i < (b);++i)
typedef long long ll;

int main(){
    int n,m; cin >> n >> m;
    vector<int> food(m,0);
    for(int i = 0;i < n;i++){
        int k; cin >> k;
        for(int l = 0;l < k;l++){
            int j;cin >> j;
            food[j-1]++;
        }
    }
    int count = 0;
    for(int i = 0;i < m;i++){
        if(food[i] == n) count ++;
    }
    cout << count << endl;
    return 0;
 } 

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include <set>
#include<algorithm>
#include<string.h>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  int n;
  scanf("%d",&n);
  long long int a[100001];
  long long int b[100001];
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  long long int ans=0;

  sort(a,a+n);
  if(n%2==1){
    long long int ans1=0;
    long long int ans2=0;
    //mid>>max
    b[0]=a[n/2];
    for(int i=1;i<n;i++){
      if(i%2==1){b[i]=a[(n-1)-(i/2)];}
      else{b[i]=a[(i-1)/2];}
    }
    for(int i=1;i<n;i++){
      ans1+=abs(b[i]-b[i-1]);
    }
    for(int i=1;i<n;i++){
      if(i%2==0){b[i]=a[n-(i/2)];}
      else{b[i]=a[(i-1)/2];}
    }
    for(int i=1;i<n;i++){
      ans2+=abs(b[i]-b[i-1]);
    }
    //mid>>min
    ans = max({ans1,ans2});
    cout << ans << endl;
    return 0;
  }
  else{
    long long int ans1=0;
    long long int ans2=0;
    long long int ans3=0;
    long long int ans4=0;
    b[0]=a[n/2];
    //mid+>>max
    for(int i=1;i<n;i++){
      if(i%2==1){b[i]=a[(n-1)-(i/2)];}
      else{b[i]=a[(i-1)/2];}
    }
    for(int i=1;i<n;i++){
      ans1+=abs(b[i]-b[i-1]);
    }
    //mid+>>min
    for(int i=1;i<n;i++){
      if(i%2==0){b[i]=a[n-(i/2)];}
      else{b[i]=a[(i-1)/2];}
    }
    for(int i=1;i<n;i++){
      ans2+=abs(b[i]-b[i-1]);
    }
    b[0]=a[(n-1)/2];
    //mid->>max
    for(int i=1;i<n;i++){
      if(i%2==1){b[i]=a[(n-1)-(i/2)];}
      else{b[i]=a[(i-1)/2];}
    }
    for(int i=1;i<n;i++){
      ans3+=abs(b[i]-b[i-1]);
    }
    //mid->>min
    for(int i=1;i<n;i++){
      if(i%2==0){b[i]=a[n-(i/2)];}
      else{b[i]=a[(i-1)/2];}
    }
    for(int i=1;i<n;i++){
      ans4+=abs(b[i]-b[i-1]);
    }
    ans = max({ans1,ans2,ans3,ans4});
    cout << ans << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    string N;
    cin >> N;
    
    ll num = stoll(N.substr(5, 2));
    
    // calculation
    if (num <= 4) {
        cout << "Heisei" << "\n";
    } else {
        cout << "TBD" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "error";
            if (iA + iB < 10) { sOut = (iA + iB).ToString(); }

            //出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include<cstdio>

struct Ch{
	int p, x;
}ch[105];

int n,m,t[105];

int main(){
	scanf("%d", &n);
	for(int i = 0; i <= n - 1; i++){
		scanf("%d", &t[i]);
	}
	scanf("%d", &m);
	for(int i = 0; i <= m - 1; i++){
		scanf("%d %d", &ch[i].p, &ch[i].x);
	}
	for(int i = 0; i <= m - 1; i++){
		int T = 0;
		int pos = t[ch[i].p - 1];
		t[ch[i].p - 1] = ch[i].x;
		for(int j = 0; j <= n - 1; j++){
			T = t[j] + T;
		}
		t[ch[i].p - 1] = pos;
		printf("%d\n", T);
	}
	return 0;
}

Measured memory_bytes: 128