akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	K := getInt()
	p := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = getInt()
	}

	E := make([]float64, N)
	for i := 0; i < N; i++ {
		E[i] = float64(p[i] * (1 + p[i])) / 2.0 / float64(p[i])
	}

	max := 0.0
	tmp := 0.0
	for i := 0; i < N; i++ {
		if i < K {
			tmp += E[i]
			max = tmp
			continue
		}

		tmp -= E[i - K]
		tmp += E[i]
		if max < tmp {
			max = tmp
		}
	}

	fmt.Println(max)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return n * powMod(n, p-1)
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include <stdio.h>
#include <numeric>
#include <cmath>
using namespace std;

void bin_vecadd(vector<int> & input)
{
  int N = input.size();
  input[0]++;
  for(int i = 0; i < N ; i ++)
  {
    if(input[i] == 2)
    {
      input[i] = 0;
      if(i+1 != N)
      input[i+1]++; 
    }
  }
}


int main(int argc, char const *argv[])
{

  int N,M;
  cin>>N>>M;
  vector<vector<int> > mat;
  vector<int> switch_param(M,0);
  int k=0;
  for(int i = 0; i < M ; i ++)
  {
    cin>>k;
    vector<int> vec(k,0);
    for(int j = 0; j <k; j ++)
    {
      cin>>vec[j];
    }
    mat.push_back(vec);
  }

  for(int i = 0;i < M;i ++)
  {
    cin>>switch_param[i] ;
  }


  int count = 0;

  int loop = int(pow(2,N));

  vector<int> switch_vec(N,0);
  int ans_num = 0;
  int check_signal = 1;
  int light_sum = 0;
  for(int i = 0; i < loop ; i ++)//パターン
  {
    for(int j = 0; j <M ;j ++)//電球
    {
      for(int k = 0; k < mat[j].size();k++)//電球k番目
      {
        light_sum += switch_vec[mat[j][k]-1];
      }

      if(light_sum%2 != switch_param[j])
      {
        check_signal = 0;
      }

      //init
      light_sum = 0;
    }
    // for(int j = 0; j < switch_vec.size(); j ++)
    // {
    //   cout<<switch_vec[j];
    // }

   
    if(check_signal == 1)
    {
      ans_num ++;
    }
    else
    {
      check_signal = 1;
    }

    bin_vecadd(switch_vec);
  }

  cout<<ans_num;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,d;
  cin >> n >> d;
  int x = d+1;
  int cnt = 1;
  while(x<n){
    if(x+d >=n)break;
    cnt++;
    x+=2*d+1;
    
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int x; cin >> x;
  int y = x%100;
  int n = x/100;
  if(n*5>=y) puts("1");
  else puts("0");
}


Measured memory_bytes: 384
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int calc(int n) {
  int cnt = 0;
  while (n % 2 == 0) {
    cnt++;
    n /= 2;
  }
  return cnt;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<int> a;
  rep(i, n) {
    char c;
    cin >> c;
    int ai = c - '1';
    a.push_back(ai);
  }

  int t = 0, cnt = 0;
  rep(i, n) {
    if (i) cnt += calc(n - i) - calc(i);
    if (cnt == 0) t ^= a[i];
  }
  if (t & 1) {
    cout << 1 << '\n';
    return 0;
  }
  rep(i, n) {
    if (a[i] == 1) {
      cout << 0 << '\n';
      return 0;
    }
    a[i] /= 2;
  }
  t = 0, cnt = 0;
  rep(i, n) {
    if (i) cnt += calc(n - i) - calc(i);
    if (!cnt) t ^= a[i];
  }
  cout << t * 2 << '\n';
  



  




  
  return 0;
}

Measured memory_bytes: 6512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

using namespace std;

typedef long long int lli;

int yaku(lli a, lli b) {
	while (a != b) {
		if (a > b) {
			if (a%b == 0) {
				a = b;
			}
			else {
				a = a - ((lli)(a / b))*b;
			}
		}
		else {
			if (b%a == 0) {
				b = a;
			}
			else {
				b = b - ((lli)(b / a))*a;
			}
		}
	}

	return a;
}

int main() {
	string s, t, x;
	lli l, n, m, ya, ba, i, sj, tj, k, q;
	map<lli, char>set;

	cin >> n >> m;
	cin >> s >> t;

	if (s[0] != t[0]) {
		cout << -1;
		return 0;
	}

	ya = yaku(n, m);
	if (ya == 1) {
		ya = min(n, m);
		i = n * m;
		sj = m;
		tj = n;
		ba = i;
	}
	else {
		sj = m / ya;
		tj = n / ya;
		i = sj * tj;
		ba = n * m / ya;
	}
	
	k = q = 1;
	while (k < n || q < m) {
		if (sj*k == tj * q) {
			if (s[k] != t[q]) {
				break;
			}
			k++;
			q++;
		}
		else if (sj*k < tj*q) {
			k++;
		}
		else {
			q++;
		}
	}

	if (k >= n && q >= m) {
		cout << ba;
	}
	else {
		cout << -1;
	}

	return 0;
}

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


int main() {
    int N;
    cin >> N;
    vector<int>Ls(N);
    int nax = 0;
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> Ls.at(i);
        if (nax < Ls.at(i)){nax = Ls.at(i);}
        sum += Ls.at(i);
    } 
     
    if (nax < sum-nax) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MAX 1000000000
using namespace std;

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

    string s;
    string str="ABC";
    cin>>s;
    if(s.compare(str)==0)
        cout<<"ARC";
    else
        cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  rec c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
int n=read();
struct p{
int a,b;
bool operator <(const p &b)const{
  return a<b.a;
  }
}r[yuzu|10];
ll k;
int main(){
int i;
read(k);
for (i=1;i<=n;++i) r[i].a=read(),r[i].b=read();
sort(r+1,r+n+1);
for (i=1;i<=n;++i){
  k-=r[i].b;
  if (k<=0) return write(r[i].a),0; 
  }
}

Measured memory_bytes: 1024
import math
N , M = map(int, input().split())
# 数列の和がＭ
# 数列の長さがＮ
# 最大でも、M ÷ Nが最大公約数ｘ
# (a1 + a2 +  )  = （b1 + b2 +  ）×　ｘ　＝　Ｍ
# M ÷ x = （b1 + b2 +  ） >= Ｎ
# M >= N × x 
# M ÷ N >= ｘ
# Ｍ　//　Ｎ >= ｘであるｘを大きい順に調べればよい？ ＹＥＳ
# 次に、ｘが条件を満たすかどうかを確認する
# 条件１：M ÷ ｘ は正の整数である
# 条件２：M ÷ ｘ >= Ｎ
lst = []
temp = int(math.sqrt(M) + 1)
for x in range(1 , temp):
    if (M % x == 0):
        lst.append(x)
        lst.append(int(M // x))
ans = 1
for d in lst:
    if M >=  (N * d):
        ans = max(ans , d)
print(ans)

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    ll N;
    cin >> N;

    string ans;
    while (N != 0) {
        N--;
        ans.push_back((N%26)+'a');
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;

int n;
char str[MAXN];
vector<int> gph[MAXN];
int deg[MAXN], vis[MAXN], val[MAXN];
int dp[MAXN][2];

void dfs2(int x, int p){
	vis[x] = 1;
	for(auto &i : gph[x]){
		if(i != p) dfs2(i, x);
	}
}

int dfs3(int x, int p){
	int ret = 0;
	dp[x][1] = val[x];
	for(auto &i : gph[x]){
		if(i != p){
			ret = max(ret, dfs3(i, x));
			dp[x][0] = max(dp[x][0], dp[i][0] + val[x]);
			dp[x][1] = max(dp[x][1], dp[i][1] + val[x]);
		}
	}
	int cur0max = 0;
	int cur1max = val[x];
	for(auto &i : gph[x]){
		if(i != p){
			ret = max(ret, cur0max + dp[i][1]);
			ret = max(ret, cur1max + dp[i][0]); 
			cur0max = max(cur0max, dp[i][0] + val[x]);
			cur1max = max(cur1max, dp[i][1] + val[x]);
		}
	}
	return ret;
}

int solve(int x){
	int ret = 0;
	dfs2(x, 0);
	for(int i=1; i<=n; i++){
		val[i] = (str[i] == 'W') ^ (gph[i].size() & 1);
		if(vis[i]) ret += gph[i].size() + val[i];
	}
	for(int i=1; i<=n; i++){
		if(vis[i]) return ret - 2 * dfs3(i, 0);
	}
	assert(0);
}

int dfs(int x, int p, vector<pi> &v){
	int ret = (str[x] == 'W');
	for(auto &i : gph[x]){
		if(i != p){
			int val = dfs(i, x, v);
			ret += val;
			if(val) v.emplace_back(i, x);
		}
	}
	return ret;
}

int main(){
	scanf("%d",&n);
	vector<pi> ed;
	for(int i=1; i<n; i++){
		int s, e; scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	scanf("%s", str + 1);
	if(count(str + 1, str + n + 1, 'W') == 0){
		cout << 0 << endl;
		return 0;
	}
	for(int i=1; i<=n; i++){
		if(str[i] == 'W'){
			vector<pi> edg;
			dfs(i, 0, edg);
			for(int i=1; i<=n; i++) gph[i].clear();
			for(auto &i : edg){
				gph[i.first].push_back(i.second);
				gph[i.second].push_back(i.first);
				deg[i.first]++;
				deg[i.second]++;
			}
			cout << solve(i) << endl;
			return 0;
		}	
	}
}


Measured memory_bytes: 15604
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vll sum(n + 1);
	rep(i, n) {
		cin >> sum[i + 1];
		sum[i + 1] += sum[i];
	}
	ll m = 1e15 + 7;
	for (int i = 1; i < n; i++) {
		ll d = sum[n] - 2 * sum[i];
		if (d < 0) d *= -1;
		if (m > d) m = d;
	}
	cout << m << endl;
}


Measured memory_bytes: 1792
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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


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

    let mut acm = vec![0; n-1];
    acm[0] = a[0];
    for i in 1..n-1 {
        acm[i] = acm[i-1] + a[i];
    }

    // println!("{:?}", acm);

    let sum = acm[n-2] + a[n-1];

    let ans = acm.iter().map(|x| (sum - 2 * x).abs()).min().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000
using namespace std;
typedef long long ll;

int main(){
  ll n, m; cin >> n >> m;
  ll ans;
  if(2*n>=m){
    ans = m*0.5;
  }
  else{
    ans = n;
    m -= 2*n;
    ans += m*0.25;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int aa[100005],bb[100005],x,y,c,d;
int main()
{
	int mina=20000000 , minb=20000000 , minc=20000000 ;
	int a,b,m;
	cin>>a>>b>>m;
	for (int i=0;i<a;i++){
		cin>>aa[i];
		mina=min(mina , aa[i]);
	}
	for (int i=0;i<b;i++){
		cin>>bb[i];
		minb=min(minb , bb[i]);
	}
	for (int i=0;i<m;i++){
		cin>>x>>y>>c;
		d=aa[x-1]+bb[y-1]-c;
		minc=min(minc , d);
	}
	cout<<min(minc , mina+minb);
	re 0;
}

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

int main()
{
    ll n, q,b,e,t;
    cin >> n;
    vecl a(n);
    for (auto &x : a)
        cin >> x;
    cin >> q;

    while (cin >> b >> e >> t)
    {
        rep(i, e - b)
            swap(a[i + b], a[i + t]);
    }

    rep(i,n){
        cout << (i ? " " : "") << flush;
        cout << a[i] << flush;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    for (int i = 0; i < n; i += 2)
        if (a[i] % 2 == 1)
            ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, a[10001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int ans = 0;
	for (i = 1; i <= N; i++) {
		for (; a[i] % 2 == 0; a[i] /= 2) ans++;
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
# solution

from itertools import product
nim, a, b, c = map(int, input().split())
array = []
for i in range(nim):
  array.append(int(input()))

abc = [0,a,b,c]
ch = [0,1,2,3]
cal = []

for i in product(ch,repeat=nim):
  calc = 0
  su = [0,0,0,0]
  ct = [0,0,0,0]
  temp = list(i)
  for j in range(nim):
    su[temp[j]] += array[j]
    ct[temp[j]] += 1
  if (ct[1]==0)|(ct[2]==0)|(ct[3]==0):
    continue
  for k in range(1,4):
    calc += abs(abc[k]-su[k])
    calc += max((ct[k]-1),0)*10
  cal.append(calc)
    
print(min(cal))

Measured memory_bytes: 5012
#include <bits/stdc++.h>
using namespace std;
int main(){
  char x;
  
cin>> x;

  if(x == 'A'){
  cout << 'T' << endl;
  }
  else if (x == 'G'){
   cout << 'C' << endl;
  }
  else if (x == 'T'){
  cout << 'A' << endl;
  }
  else if (x == 'C'){
  cout << 'G' << endl;
  }
}

Measured memory_bytes: 3616
//contest 162 at coder
#include<bits/stdc++.h>
using namespace std;
#define rep(n) for(int i=0;i<n;i++)
#define pb push_back
int main(){
	int n;
	cin>>n;
	
	map<int,int> m;
	for(int i=1;i<=n;i++){
		m[i]=0;
	}
	for(int i=0;i<n-1;i++){
		int x;
		cin>>x;
		m[x]++;
	}
	for(int i=1;i<=n;i++){
		cout<<m[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 13012
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

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

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

int main(void){
	          int i;

	          int N;
	          cin >> N;

	          ll a=1LL;
	          for(i=0;i<N;i++){
	        	  ll T;
	        	  cin >> T;
	        	  a=lcm(a,T);
	          }

	          cout << a << endl;


	          return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N,R;
  cin>>N>>R;
  if(N<10)cout<<R+100*(10-N)<<endl;
  else cout<<R<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
int a[N];
void kill() {
	cout << "-1\n";
	exit(0);
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	a[0] = -1;
	for (int i = 1; i <= n; i++)
		if (a[i] - a[i - 1] > 1) kill();
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!a[i]) continue;
		ans++;
		if (a[i - 1] + 1 != a[i]) ans += a[i] - 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll=long long;
using ld=long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using vlll = vector<vector<vector<ll>>>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BCollectingBallsEasyVersion {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, k;
	    in >> n >> k;
	    vl x(n);
	    for(int i=0; i<n; i++){
	        in >> x[i];
	    }

	    ll res = 0;
	    for(int i=0; i<n; i++){
	        res += min(x[i]*2, abs(k-x[i])*2);
	    }

	    out << res << enl;
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	BCollectingBallsEasyVersion solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#define ll long long
using namespace std;
const int maxn=100007;
ll n,a[3*maxn],be,en,ans=-(1LL<<50),f1[2*maxn],f2[2*maxn];
struct data1{
	ll val,id;
	bool operator < (const data1 x)const{
		return val > x.val;
	}
}a1[3*maxn];
struct data2{
	ll val,id;
	bool operator < (const data2 x)const{
		return val < x.val;
	}
}a2[3*maxn];
priority_queue <data1> q1;
priority_queue <data2> q2;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1; i<=3*n; i++) {
		cin>>a1[i].val;
		a2[i].val=a1[i].val;
		a1[i].id=a2[i].id=i;
		if (i<=n) be+=a1[i].val,q1.push(a1[i]);
		if (2*n+1<=i) en+=a1[i].val,q2.push(a2[i]);	
	}
	f1[n]=be;
	f2[2*n+1]=en;
	for (int i=n+1; i<=2*n; i++) {
		data1 now=q1.top();
		f1[i]=f1[i-1];
		if (now.val<a1[i].val) f1[i]=f1[i]-now.val+a1[i].val,q1.pop(),q1.push(a1[i]); 
	}
	for (int i=2*n; i>n; i--) {
		data2 now=q2.top();
		f2[i]=f2[i+1];
		if (now.val>a2[i].val) f2[i]=f2[i]-now.val+a2[i].val,q2.pop(),q2.push(a2[i]); 
	}
	for (int i=n; i<=2*n; i++) ans=max(ans,f1[i]-f2[i+1]);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 17904
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

struct Point {
	int id, x, y;

	bool operator <(const Point& right) {
		return id < right.id;
	}
};

struct Node {
	int location, l, r;
};

bool LESS_X(const Point& left, const Point& right) {
	return left.x < right.x;
}

bool LESS_Y(const Point& left, const Point& right) {
	return left.y < right.y;
}

const int MAX = 500000;
int NIL = -1;

Point P[MAX];
Node T[MAX];
vector<Point> ans;

void find(int v, int sx, int tx, int sy, int ty, int depth) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty)
		ans.push_back(P[T[v].location]);

	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x) {
				find(T[v].l, sx, tx, sy, ty, depth + 1);
			}
		}
		if (T[v].r != NIL) {
			if (x <= tx) {
				find(T[v].r, sx, tx, sy, ty, depth + 1);
			}
		}
	} else {
		if (T[v].l != NIL) {
			if (sy <= y) {
				find(T[v].l, sx, tx, sy, ty, depth + 1);
			}
		}
		if (T[v].r != NIL) {
			if (y <= ty) {
				find(T[v].r, sx, tx, sy, ty, depth + 1);
			}
		}
	}

}

int np = 0;
int makeKdTree(int l, int r, int depth) {
	if (!(l < r))
		return NIL;

	int t = np++;
	int mid = (l + r) / 2;
	T[t].location = mid;

	if (depth % 2 == 0) {
		sort(P + l, P + r, LESS_X);
	} else {
		sort(P + l, P + r, LESS_Y);
	}

	T[t].l = makeKdTree(l, mid, depth + 1);
	T[t].r = makeKdTree(mid + 1, r, depth + 1);

	return t;
}

int main() {

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);

		Point point;
		point.id = i;
		point.x = x;
		point.y = y;
		P[i] = point;

		Node node;
		node.location = node.l = node.r = NIL;
		T[i] = node;
	}

	makeKdTree(0, n, 0);

	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		int sx, tx, sy, ty;
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);

		ans.clear();
		find(0, sx, tx, sy, ty, 0);
		sort(ans.begin(), ans.end());
		for (int j = 0; j < (int) ans.size(); ++j) {
			printf("%d\n", ans[j].id);
		}
		printf("\n");
	}

	return 0;
}

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


int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i=0;i<N;++i) cin >> p[i];
    sort(p.begin(),p.end());
    int ans=0;
    for (int i=0;i<N-1;++i) ans += p[i];
    ans += p[N-1]/2;
    cout << ans << endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
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; }
const long long INF = 1LL<<60;

// 入力
string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0

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

    // DPループ
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 39996
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output14.txt", "w", stdout);
#endif
	long n;
	cin>>n;
	long a[n+1],i,ans=0;
    for(i=1;i<=n;i++)
    {
    	cin>>a[i];
    	if(i%2!=0&&a[i]%2!=0)
    		ans++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3632
hash = Hash.new(0)

while line = gets
  a, b = line.chomp.split.map(&:to_i)
  if a == 0 && b == 0
    odds = hash.select { |key, value| value % 2 == 1 }
    puts (odds.keys == [1, 2]) ? :OK : :NG
    hash = Hash.new(0)
  end
  hash[a] += 1
  hash[b] += 1
end

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

int T[101];
int P[101];
int X[101];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

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

    int M;
    cin >> M;

    for(int i = 0; i < M; ++i)
        cin >> P[i] >> X[i];
    
    for(int i = 0; i < M; ++i){
        int p = P[i] - 1;
        int ans = sum - T[p] + X[i];
        cout << ans << endl;
    }

    return 0;
};

Measured memory_bytes: 256
p = [x for x in input()]
p_len = len(p)
s = input()

for i in range(p_len):
    jadge_string = "".join(p)
    if s in jadge_string:
        print("Yes")
        break
    elif i == p_len-1:
        print("No")
    else:
        c = p.pop(0)
        p.append(c)


Measured memory_bytes: 5568
import numpy as np
N = int(input())
X = []
for i in range(N):
  X += list(map(int, input().split()))
X = np.array(X).reshape(N, 3)

dp = np.zeros((N+1,4))
for i in range(N):
  for j in range(3):
    for k in range(3):
      if j == k: continue
      dp[i+1,k+1] = max(dp[i+1,k+1], dp[i,j+1]+X[i,k])
print(int(np.max(dp[-1,1:])))

Measured memory_bytes: 26424
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

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

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int32_t main(){
   boost;
   int N,K;cin>>N>>K;
   int t[N];
   for(int i=0; i<N; i++) cin>>t[i];
   sort(t,t+N);
   int s=0;
   for(int i=0; i<K; i++) s+=t[i];
   cout << s << endl;


   return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5;
int a[maxn+5],b[maxn+5];
int n;
int main()
{

    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        int x;
        scanf("%d",&x);
        if(i&1) ++a[x];else ++b[x];
    }
    int mxa=0,mxb=0;
    for(int i=1;i<=100000;++i)
        if(a[i]>a[mxa]) mxa=i;
    for(int i=1;i<=100000;++i)
        if(b[i]>b[mxb]) mxb=i;
    int mxxa=0,mxxb=0;
    for(int i=0;i<=100000;++i)
        if(i!=mxa&&a[i]>a[mxxa]) mxxa=i;
    for(int i=0;i<=100000;++i)
        if(i!=mxb&&b[i]>b[mxxb]) mxxb=i;
    if(mxa!=mxb) printf("%d\n",n-a[mxa]-b[mxb]);
    else
        printf("%d\n",min(n-a[mxa]-b[mxxb],n-a[mxxa]-b[mxb]));
    return 0;
}


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

int main(){
  int n,y,z;
  cin>>n>>y;
  for(int i = 0; i <= n; i++){
  	for(int j = 0; j <= n; j++){
  		z = n-i-j;
  		if(10000*i + 5000*j + 1000*z > y || z < 0)	break;
  		if(10000*i + 5000*j + 1000*z == y){
  			cout<<i<<" "<<j<<" "<<z;
  			return 0;
  		}
  	}
  }
  cout<<"-1 -1 -1";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1; i <= 9; ++i)
    for (RI j = 1; j <= 9; ++j)
      if (i * j == n) return puts("Yes"), 0;
  puts("No");

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

inline void build(const vector<ll>& a, vector<ll>& b, ll fst)
{
	b[0] = fst;

	for(int i = 1; i < len(b); ++i)
		b[i] = 2 * a[i - 1] - b[i - 1];
}

inline bool check(const vector<ll>& b, ll fsum)
{
	for(auto element: b)
		fsum -= element;

	return fsum >= 0;
}

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

	vector<ll> a(n), b(n);
	ll fsum = 0;

	for(auto& element: a)
	{
		cin >> element;
		fsum += element;
	}

	ll L = 0, R = (ll)1e10 + 77;

	while(R - L > 1)
	{
		ll M = (L + R) / 2;

		build(a, b, M);

		if(check(b, fsum))
			L = M;
		else
			R = M;
	}

	build(a, b, L);

	cout << b << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 2944
#!/usr/bin/env python3
def YesNo(T):
    if T:
        print('Yes')
    else:
        print('No')

N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
A.sort()
tmp = sum(A) / (4*M)
for i in reversed(range(N)):
    if A[i] >= tmp:
        cnt += 1
    else:
        break
YesNo(cnt >= M)

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


int main(){
    int H, W;
    string a[100];
    int chr_cnt[26] = {};

    cin >> H >> W;
    for(int h = 0; h < H; h++){
        cin >> a[h];
        for(int w = 0; w < W; w++){
            chr_cnt[a[h][w]-'a']++;
        }
    }

    int stock_1 = 0, stock_2 = 0, stock_4 = 0;
    for(int i = 0; i < 26; i++){
        stock_1 += chr_cnt[i] % 2;
        stock_2 += (chr_cnt[i]%4)/2;
        stock_4 += chr_cnt[i]/4;
    }

    int demanded_1, demanded_2, demanded_4;
    if(H%2 == 1 && W % 2 == 1){
        demanded_1 = 1;
        demanded_2 = H/2 + W/2;
        demanded_4 = (H/2) * (W/2);
    }else if(H%2 == 1){
        demanded_1 = 0;
        demanded_2 = W/2;
        demanded_4 = (H/2)*(W/2);
    }else if(W%2 == 1){
        demanded_1 = 0;
        demanded_2 = H/2;
        demanded_4 = (H/2)*(W/2);
    }else{
        demanded_1 = 0;
        demanded_2 = 0;
        demanded_4 = (H/2)*(W/2);
    }

    //printf("%d, %d, %d\n", stock_1, stock_2, stock_4);
    //printf("%d, %d, %d\n", demanded_1, demanded_2, demanded_4);
    stock_1 -= demanded_1;
    stock_4 -= demanded_4;
    if(stock_1 == 0 && stock_4 >= 0 && demanded_2 == stock_4*2 + stock_2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main()
{
	string S;

	string abc = "abcdefghijklmnopqrstuvwxyz";

	int result = 0;
	cin >> S;

	for (int a = 0; a < S.length(); a++) {
		if (abc.substr(result, 1) == S.substr(a, 1)) {
			result++;
			a = 0;
			if (result >= abc.length()) {
				result = -1;
				break;
			}
		}
		
	}

	if (result == -1) {
		cout << "None" << endl;

	}
	else {
		cout << abc.substr(result,1) << endl;

	}
	
}



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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100111, inf = 1000111222;

ll m[max_n];
int n;

int main()
{
    //freopen("input.txt", "r", stdin);
    ll sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> m[i];
        if (i % 2 == 0) {
            sum += m[i];
        } else {
            sum -= m[i];
        }
    }
    ll fst = sum / 2;
    for (int i = 0; i < n; ++i) {
        cout << fst * 2 << ' ';
        fst = m[i] - fst;
    }

    return 0;
}




Measured memory_bytes: 2048
import scala.io.Source.stdin

object Main extends App {
  var b = new StringBuilder

  for(d<-stdin.getLines.map(_.toInt)) {
    var j = 0
    var s = 0
    while(j*d < 600-d) {
      s += j*j*d*d*d
      j += 1
    }
    b.append((s + j*j*d*d*d)+"\n")
  }

  print(b.result)
}

Measured memory_bytes: 43848
import java.util.Scanner;

public class Main {
    public static void printArr(int[] arr) {
        String[] ss = new String[arr.length];
        for (int i = 0; i < arr.length; i++) {
            ss[i] = String.valueOf(arr[i]);
        }
        System.out.println(String.join(" ", ss));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] inputs = new int[n];
        for (int i = 0; i < n; i++) {
            inputs[i] = sc.nextInt();
        }


        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int minj = i;
            for (int j = i; j < n; j++) {
                if (inputs[j] < inputs[minj]) {
                    minj = j;
                }
            }
            if (minj != i) {
                int tmp = inputs[minj];
                inputs[minj] = inputs[i];
                inputs[i] = tmp;
                cnt++;
            }
        }
        printArr(inputs);
        System.out.println(cnt);
    }

}


Measured memory_bytes: 26500
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<queue>
using namespace std;

int main(void){
    int n, K, Q;
    cin >> n >> K >> Q;
    vector<int> arr = vector<int>(n);
    vector<int> sample_arr = vector<int>(n);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sample_arr = arr;
    sort(sample_arr.begin(), sample_arr.end());

    int result = sample_arr[Q - 1] - sample_arr[0];
    for(int i = 0; i < n; i++){
        int x = arr[i];

        vector<int> cur_interval;
        for(int j = 0; j < n; j++) {
            if(arr[j] < x) cur_interval.push_back(j);
        }

        vector<int> candidates;
        for(int j = 0; j <= cur_interval.size(); j++){
            int st = (j == 0)? 0 : cur_interval[j - 1] + 1;
            int end = (j == cur_interval.size()) ? n : cur_interval[j];

            if(end - st  + 1 >= K) {
                priority_queue<int, vector<int>, greater<int> > temp;
                for(int k = st; k < end; k++){
                    temp.push(arr[k]);
                }
                for(int k = 0; k < end - st + 1 - K; k++){
                    int top = temp.top();
                    temp.pop();
                    candidates.push_back(top);
                }
            }
        }
        //candidates.push_back(x);

        if(candidates.size() >= Q) {
            sort(candidates.begin(), candidates.end());
            /*
            for(int k = 0; k < candidates.size(); k++){
                cout << candidates[k] << ' ';
            }
            cout << endl;
            cout << candidates[Q - 1] << " " <<  candidates[0] << "=" << candidates[Q - 1] - candidates[0] << endl;
            */
            if(result > candidates[Q - 1] - candidates[0]) result = candidates[Q - 1] - candidates[0];
        }
    }

    cout << result << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    ll n; cin >> n;
    vector<int> p(1000010, 0);
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0) {
            p[i]++;
            n /= i;
        }
    }

    ll ans = 0;
    if (n != 1) ans++;

    for (auto &&i : p)
    {
        ll pnum = i;
        ll cnt = 1;
        while (pnum - cnt >= 0) {
            ans++;
            pnum -= cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}


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

int x[100005];

int main(){
	int n; cin>>n;
	memset(x,0,sizeof(x));
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	sort(x+1,x+n+1);
	x[0]=x[1]-1;
	int num=0,ans=0;
	for(int i=1;i<=n;i++){
		if (x[i]==x[i-1]) num++;
		else{
			if (num%2==1) ans++;
			num=1;			
		}
	}
	if (num%2==1) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())

l, r = [], []
for i in range(m):
    tmpa, tmpb = map(int, input().split())
    l.append(tmpa)
    r.append(tmpb)

print(min(r) - max(l) + 1 if min(r) >= max(l) else 0)


Measured memory_bytes: 11020
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(10);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

ll N, K;
ll A[200005];

int main() {
	cin >> N >> K;
	rep (i, N) cin >> A[i];

	sort(A, A + N);

	const ll INF = TEN(18) + 1;
	ll l = -INF, r = INF, m;
	while (r - l > 1) {
		m = (l + r) / 2;
		ll num = 0, S = 0, T = 0;
		rep (i, N) {
			if (A[i] * A[i] <= m) {
				T++;
			}
			if (A[i] > 0) {
				int l2 = -1, r2 = N, m2;
				while (r2 - l2 > 1) {
					m2 = (r2 + l2) / 2;
					(A[m2] * A[i] <= m ? l2 : r2) = m2; 
				}
				S += r2; //インデックスはl2だがSに足したいのは個数なのでl2+1(=r2)
			}
			else if (A[i] < 0) {
				int l2 = -1, r2 = N, m2;
				while (r2 - l2 > 1) {
					m2 = (r2 + l2) / 2;
					(A[m2] * A[i] <= m ? r2 : l2) = m2;
				}
				S += N - r2;
			}
			else {
				if (m >= 0) S += N;
			}
		}
		num = (S - T) / 2;
		(num >= K ? r : l) = m;
	}

	cout << r << endl;
	return 0;
}


Measured memory_bytes: 5156
#include <stdio.h>
#define MIN(x,y)	((x)<(y)?(x):(y))
int main(){
  int n,m,x,cmin=99999999;
  int c[12]={0}, a[12][12]={0};
  
  //取得
  scanf("%d%d%d", &n,&m,&x);
  for(int i=0; i<n; i++){
    scanf("%d", &c[i]);
    for(int j=0; j<m; j++){
      scanf("%d", &a[i][j]);
    }
  }
  //bit全探索
  for(int b=0; b<(1<<n); b++){
    int asum[12]={0}, csum=0;
    for(int i=0; i<n; i++){
      //本iが選択肢にある場合
      if(b & (1<<i)){
        csum += c[i];
        for(int j=0; j<m; j++){ asum[j] += a[i][j]; }
      }
    }
    //現在の本の選び方で、すべての理解度がXを超えるか
    int flag=0;
    for(int j=0; j<m; j++){
      if( asum[j] < x ){ flag=1; break; }
    }
    //現在の本の選び方でOKなので、最小金額判定
    if( !flag ){ cmin = MIN( cmin, csum ); }
  }
  //表示
  if(cmin==99999999){ printf("-1\n"); }
  else				{ printf("%d\n", cmin); }
  return 0;
}

Measured memory_bytes: 1728
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int[] b = new int[n];
      int[] c = new int[n];

      for(int i = 0; i < n; i++) a[i] = sc.nextInt();
      for(int i = 0; i < n; i++) b[i] = sc.nextInt();
      for(int i = 0; i < n; i++) c[i] = sc.nextInt();

      Arrays.sort(a); Arrays.sort(b); Arrays.sort(c);

      long[] conBC = new long[n];
      for(int i = 0, j = 0; i < n && j < n; i++) {
          int numB = b[i];
          while(j < n && c[j] <= numB)
              j++;
          conBC[i] = n - j;
      }

      long[] conAB = new long[n];
      for(int i = 0, j = 0; i < n; i++) {
          int numB = b[i];
          while(j < n && a[j] < numB)
              j++;
          conAB[i] = j;
      }
      long cnt = 0;
      for(int i = 0; i < n; i++)
        cnt += (long)conAB[i]  * (long)conBC[i] ;
      System.out.println(cnt);
  }
}



Measured memory_bytes: 51884
import java.util.*;
import java.lang.*;
 
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);

		int k;
		k=sc.nextInt();
		String s;
		s=sc.next();
		int l=s.length();
		if(k>=l)
		{
		    
		    System.out.println(s);
		}
		else
		{
		    s=s.substring(0,k);
		    s=s+"...";
		    System.out.println(s);
		}
	}
}


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	if(n==1 || n%2!=0){
		cout << "No\n";
		return 0;
	}
	for(int i=0,j=n/2;j<n;i++,j++){
		if(s[i]!=s[j]){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";

	return 0;
}



Measured memory_bytes: 256