akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int solve(vector<array<int, 3> > &v, vector<array<int, 3> > &dp, int pos, int i) {
    if(pos == v.size()) return 0;
    if(dp[pos][i] != -1) return dp[pos][i];
    switch(i) {
        case 0: dp[pos][i] = max(v[pos][1] + solve(v, dp, pos+1, 1), v[pos][2] + solve(v, dp, pos+1, 2));
                break;
        case 1: dp[pos][i] = max(v[pos][0] + solve(v, dp, pos+1, 0), v[pos][2] + solve(v, dp, pos+1, 2));
                break;
        case 2: dp[pos][i] = max(v[pos][0] + solve(v, dp, pos+1, 0), v[pos][1] + solve(v, dp, pos+1, 1));
                break;
    }
    return dp[pos][i];
}

int main() {
    int n;
    cin>>n;
    vector<array<int, 3> > v(n);
    vector<array<int, 3> > dp(n, {-1, -1, -1});
    for(auto &e: v) cin>>e[0]>>e[1]>>e[2];
    dp[0][0] = v[0][0] + solve(v, dp, 1, 0);
    dp[0][1] = v[0][1] + solve(v, dp, 1, 1);
    dp[0][2] = v[0][2] + solve(v, dp, 1, 2);
    cout<<max(dp[0][0], max(dp[0][1], dp[0][2]))<<endl;
}


Measured memory_bytes: 11752
import numpy as np

A, B, H, M = map(int, input().split())

w_h = 360/12*H + 30/60*M #時針の角度(angle)
w_m = 360/60*M #分針の角度(angle)

dif_angle = abs(w_h-w_m)
if dif_angle >= 180:
    dif_angle = 360 - dif_angle

rad = dif_angle/180*np.pi

C_2 = (A**2) + (B**2) - 2*A*B*np.cos(rad)
ans = np.sqrt(C_2)

print(ans)


Measured memory_bytes: 27232
S = input().split()
M = int(S[0])
D = int(S[1])
count = 0

for m in range(1, M + 1):
    for d in range(1, D + 1):
        d1  = d %  10
        d10 = d // 10
        if d1 >= 2 and d10 >= 2:
            if d1 * d10 == m:
                count += 1

print(count)

Measured memory_bytes: 3060
a,b,x=map(int,input().split())
#a<=y<=bでy%x=0を満たすyの個数を求める
#f(n)を0以上n以下で上記のyの個数を表す関数と定義する
#すると，問題の答えはf(b)-f(a-1)である
#f(b):0以上b以下のyの個数,f(a-1):0以上a-1以下のyの個数
#a=0のときf(-1)が呼ばれることに注意する
#f(b)=b//x+1
#a>0 f(a-1)=(a-1)//x+1
#a=0 f(a-1)=0
def between(a,b,x):
    if a==0:
        na=0
    else:
        na=(a-1)//x+1
    nb=b//x+1
    print(nb-na)
between(a,b,x)

Measured memory_bytes: 9084
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


bool s[200001];
int e[100000];

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

	int n, m;
	cin >> n >> m;
	rep(i, m)cin >> e[i], e[i]--;
	for (int i = m - 1; i >= 0;i--) {
		if (!s[e[i]]) {
			cout << e[i]+1 << endl;
			s[e[i]] = true;
		}
	}
	rep(i,n) {
		if (!s[i]) {
			cout << i + 1 << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 3712
import itertools

values = map(int, input().split())
ps = list(itertools.permutations(values))

_max = 0
for p in ps:
    num1 = p[0] + (p[1] * 10 + p[2])
    num2 = (10 * p[0] + p[1]) + p[2]
    _max = max([_max, num1, num2])
print(_max)


Measured memory_bytes: 3060
import math

a, b = map(int, input().split())

x_min = a / 0.08
x_max = (a + 1) / 0.08

y_min = b / 0.1
y_max = (b + 1) / 0.1

x_list = list(range(math.ceil(x_min), math.floor(x_max) + 1))
if x_max == math.floor(x_max):
    x_list.pop(-1)

y_list = list(range(math.ceil(y_min), math.floor(y_max) + 1))
if y_max == math.floor(y_max):
    y_list.pop(-1)


matome = set(x_list) & set(y_list)
matome = list(matome)


if not matome:
    print(-1)
else:
    print(min(matome))

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int i,j;
  int a=-1,b=-1;
  int c=0;
  char s[5];

  for(i=0;i<4;i++){
    scanf("%c",&s[i]);
  }
  s[4] = '\n';

  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      if(i!=j && s[i] == s[j]){

        c++;
      }
    }
  }
  if(c==4){printf("Yes\n");}
  else{printf("No\n");}
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int k; cin >> k;
  string ans = "";
  rep(i,k) ans += "ACL";
  cout << ans;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3612
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	s <- getLine
	t <- getLine
	print $ length $ filter ( id ) $ zipWith (/=) s t

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

using namespace std;

#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) for (int i=0;i<(n);i++)
#define ll long long

int main()
{
	int n, k;
	vector<ll> vll;

	cin >> n >> k;

	rep (i, n) {
		ll h;
		cin >> h;
		vll.push_back(h);
	}

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

	ll res = 10000000000;

	Rep (i, k-1, n) {
		res = min(res, vll[i] - vll[i-k+1]);
	}

	cout << res << endl;
}



Measured memory_bytes: 1400
import java.util.*;
import java.lang.*;

class Main {

	public static void main(String[] args) {
		new Main().solve();
	}

	public void solve() {
		Scanner scanner = new Scanner(System.in);
		int numOps = scanner.nextInt();
		int key, pri;
		Node root = null;

		for(int i = 0; i < numOps; i++) {
			String op = scanner.next();

			if(op.equals("insert")) {
				key = scanner.nextInt();
				pri = scanner.nextInt();
				root = insert(root, key, pri);
			} else if(op.equals("find")) {
				key = scanner.nextInt();
				System.out.println(find(root, key) ? "yes" : "no");
			} else if(op.equals("delete")) {
				key = scanner.nextInt();
				root = erase(root, key);
			} else if(op.equals("print")) {
				printTreap(root);
			}
		}
	}

	public Node rightRotate(Node t) {
		Node s = t.left;
		t.left = s.right;
		s.right = t;
		return s;
	}

	public Node leftRotate(Node t) {
		Node s = t.right;
		t.right = s.left;
		s.left = t;
		return s;
	}

	public Node insert(Node t, int key, int pri) {
		if(t == null)
			return new Node(key, pri);

		if(key == t.key)
			return t;

		if(key < t.key) {
			t.left = insert(t.left, key, pri);
			if(t.pri < t.left.pri)
				t = rightRotate(t);
		} else {
			t.right = insert(t.right, key, pri);
			if(t.pri < t.right.pri)
				t = leftRotate(t);
		}

		return t;
	}

	public Node erase(Node t, int key) {
		if(t == null)
			return null;

		if(key == t.key) {
			if(t.left == null && t.right == null)
				return null;
			else if(t.left == null)
				t = leftRotate(t);
			else if(t.right == null)
				t = rightRotate(t);
			else {
				if(t.left.pri > t.right.pri)
					t = rightRotate(t);
				else 
					t = leftRotate(t);
			}

			return erase(t, key);
		}

		if(key < t.key)
			t.left = erase(t.left, key);
		else
			t.right = erase(t.right, key);

		return t;
	}

	public boolean find(Node root, int target) {
		if(root == null)
			return false;

		if(root.key == target)
			return true;
		else if(root.key < target)
			return find(root.right, target);
		else
			return find(root.left, target);
	}

	public void printTreap(Node root) {
		inorderTraverse(root);
		System.out.println();
		preorderTraverse(root);
		System.out.println();
	}

	private void inorderTraverse(Node root) {
		if(root != null) {
			inorderTraverse(root.left);
			System.out.print(" " + root.key);
			inorderTraverse(root.right);
		}
	}

	private void preorderTraverse(Node root) {
		if(root != null) {
			System.out.print(" " + root.key);
			preorderTraverse(root.left);
			preorderTraverse(root.right);
		}
	}

	class Node {
		int key;
		int pri;
		Node left;
		Node right;

		public Node(int k, int p) {
			key = k;
			pri = p;
			left = null;
			right = null;
		}
	}
}


Measured memory_bytes: 184712
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
k=abs(a-b)
if w-v>0:
    print("NO")
elif w==v:
    if k==0:
        print("YES")
    else:
        print("NO")
else:
    if k<=(v-w)*t:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 61704
#include<bits/stdc++.h>
using namespace std;
int Ceil( int n , int m){
 	if( n%m==0 ) return n/m;
  	return n/m+1;
}
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if( a%d==0 ){
    if( Ceil(a,d) < Ceil(c,b) ) cout<< "No";
    else cout<<"Yes";
  }
  else{
    if( Ceil(a,d) >= Ceil(c,b) ) cout<<"Yes";
    else cout<<"No";
  }
}

Measured memory_bytes: 3584
H, W = map(int, input().split())
costs = [list(map(int ,input().split())) for _ in range(10)]
walls = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
  for i in range(10):
    for j in range(10):
      costs[i][j] = min(costs[i][j], costs[i][k]+costs[k][j])
ans = 0
for h in range(H):
  for w in range(W):
    if walls[h][w] == -1:
      continue
    else:
      ans += costs[walls[h][w]][1]
print(ans)

Measured memory_bytes: 3444
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: usize,
        B: usize,
        C: usize,
    }
    let mut ans = "NO";
    for i in 1..B+1{
        if (A*i)%B==C{
            ans = "YES";
            break;
        }
    }
    println!("{}", ans);
}

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

int main(){
	int n;
	vector<bool> colors(8,false);
	int under = 0;
	int master = 0;

	cin >> n;

	vector<int> a(n);
	for(auto& x : a){
		cin >> x;
		if(x < 3200){
			if(!colors[x / 400]){
				++under;
				colors[x / 400] = true;
			}
		} else{
			++master;
		}
	}

	cout << max(under,1) << ' ' << under+master << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall, dijkstra
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

# f = floyd_warshall(G,directed=True(有向か、defaultはTrue))
# d = dijkstra(G, indices=0,directed=True(有向か、defaultはTrue))
n,m,l=map(int,input().split())
rinsetsu=[[0]*n for i in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    rinsetsu[a-1][b-1]=c
    rinsetsu[b-1][a-1]=c

# G = csgraph_from_dense(rinsetsu, null_value=0)
f = floyd_warshall(rinsetsu,directed=True)
# print(f)
for i in range(n):
    for j in range(n):
        f[i][j]= 1 if 1<=f[i][j]<=l else 0
# print(f)
f2= floyd_warshall(f,directed=True)

q = int(input())
for i in range(q):
    s,g=map(int,input().split())
    s-=1;g-=1
    print(int(f2[s][g])-1 if f2[s][g]!=float("inf") else -1)

# print(f2)



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

using namespace std;


void solve(string S)
{
    int y = stoi(S.substr(0, 4));
    int m = stoi(S.substr(5, 2));
    int d = stoi(S.substr(8, 2));
    if (y < 2019 || (y == 2019 && m < 4) || (y == 2019 && m == 4 && d <= 30)) cout << "Heisei\n";
    else cout << "TBD\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n, a; cin >> n >> a;

  auto f = [&] (ll y) {
    ll res = 0;
    rep2(k, 1, 100) rep(l, 100) {
      ll x = y - a*(k+l-1) - l;
      x /= (k+l);
      if (x <= 0) break;
      ll res = 1;
      rep(i, k) {
        res *= x;
        if (res >= n) return true;
      }
      rep(i, l) {
        res *= x+1;
        if (res >= n) return true;
      }
    }
    return false;
  };

  ll ok = n;
  ll ng = 0;
  while (llabs(ok - ng) > 1) {
    ll md = (ok + ng) / 2;
    if (f(md)) ok = md;
    else ng = md;
  }

  ll ans = ok;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
 string s;cin >> s;
 string t[3]={"Sunny","Cloudy","Rainy"};
 rep(i,3){
     if(s==t[i])cout << t[(i+1)%3] << endl;
 }
}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {

    int n;
    cin >> n;
    int a[n+1],b[n];
    long long int ans=0;
    for(int i=0;i<n+1;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }

    for(int i=0;i<n;i++){
        if(b[i]>a[i]){
            ans+=a[i];
            b[i]-=a[i];
            if(b[i]<=a[i+1]){
                a[i+1]-=b[i];
                ans+=b[i];
            }
            else{
                ans+=a[i+1];
                a[i+1]=0;
            }
        }
        else{
            a[i]-=b[i];
            ans+=b[i];
        }
    }

    cout << ans;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int cnt[51][26];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		for (int j = 0; j < S.size(); j++) {
			cnt[i][S[j] - 'a']++;
		}
	}
	string ans;
	for (int j = 0; j < 26; j++) {
		int c = mod;
		for (int i = 0; i < N; i++) {
			c = min(c, cnt[i][j]);
		}
		for (int i = 0; i < c; i++) {
			ans.push_back((char)('a' + j));
		}
	}
	cout << ans << endl;
}


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

int main() {
    
    // 1. input.
    int a[10];
    for(int i = 0; i < 10; i++) cin >> a[i];
    
    // 2. output answer.
    sort(a, a + 10, greater<int>());
    for(int i = 0; i < 3; i++) cout << a[i] << endl;
    
    return 0;
    
}


Measured memory_bytes: 3048
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		long ans = 0;
		for(int i = 0; i < st.length(); i ++) {
			ans += st.charAt(i) - '0';
		}
		System.out.println(ans == 1 ? 10 : ans);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
string S;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> S;
    
    if(S.compare("hi")==0 || S.compare("hihi")==0 || S.compare("hihihi")==0
       || S.compare("hihihihi")==0 || S.compare("hihihihihi")==0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    double H = scan.nextDouble();
    double W = scan.nextDouble();
    double X = scan.nextDouble();
    double Y = scan.nextDouble();
    int c = 0;
    if (X==H/2 && Y==W/2){
      c = 1;
    }
    System.out.println((H*W/2)+" "+c);
  }
}

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

int solve(int n,char s[]){
  int i,j;

  i = 0;
  j = n - 1;
  while(i < j){
    if(s[i] != s[j]) return 1;
    i++;
    j--;
  }


  i = 0;
  j = (n - 1)/2 - 1;
  while(i < j){
    if(s[i] != s[j]) return 1;
    i++;
    j--;
  }

  i = (n + 3)/2 - 1;
  j = n - 1;
  while(i < j){
    if(s[i] != s[j]) return 1;
    i++;
    j--;
  }

  return 0;
}

int main(){
  int n;
  char s[100];

  scanf("%s", s);
  n = strlen(s);

  if(solve(n,s)) printf("No\n");

  else printf("Yes\n");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;

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

int main(){
	string s;
	cin>>s;
	int l = 0;
	for(int i = 0; i < s.size(); i++){
		if(l%2==0 && s[i]=='A') l++;
		else if(l%2==1 && s[i]=='Z') l++;
	}
	string ans;
	rep(i, l/2) ans+="AZ";
	if(ans.size()==0) {
		cout<<-1<<endl; 
		return 0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define REPI(i,a,b) for(int (i)=int(a);i<int(b);++i)
#define INF 10000000

int main(void){
  using namespace std;
  int X,A;
  cin >> X >> A;
  if(X < A) cout << 0;
  else cout << 10;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<malloc.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int i=0;
	char s[1005];
	scanf("%s",&s);
	for(i=0;s[i]!='\0';i++);
	if(s[i-1]=='s')
	{
		s[i]='e';s[i+1]='s';s[i+2]='\0';
	}
	else
	{
		s[i]='s';s[i+1]='\0';
	}
	printf("%s",s);

}

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

int main(){
   int n,m;
   cin >> n >> m;
   vector<pair<int,int>>stu(n);
   vector<pair<int,int>>poi(m);
   rep(i,n){
       int a,b;
       cin >> a >> b;
       stu[i]=make_pair(a,b);
   }
   rep(i,m){
       int c,d;
       cin >> c >> d;
       poi[i]=make_pair(c,d);
   }
   for(int i=0;i<n;i++){
       int ans=m;
       int ansd=inf;
       for(int j=0;j<m;j++){
           int dis=abs(stu[i].first-poi[j].first)+abs(stu[i].second-poi[j].second);
           if(dis<ansd){
               ansd=dis;
               ans=j+1;
           }
       }
       cout << ans << endl;
   }

    return 0;
}

Measured memory_bytes: 256
hs = [nil, 2,5,5,4,5,6,3,7,6]
n, _ = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
as.sort!
as.reverse!

dp = [-10000] * 10003
dp[0] = 0
dp.size.times{|i|
  as.map{|a|
    if i == hs[a]
      dp[i] = [dp[i], 1].max
    end
    if i - hs[a] >= 0
      dp[i] = [dp[i-hs[a]] + 1, dp[i]].max
    end
  }}

ans = []
rest = n
dp[n].times {
  as.each {|a|
    if dp[rest - hs[a]] == dp[rest] - 1
      ans << a
      rest -= hs[a]
      break
    end
  }
}
puts ans.join('')

Measured memory_bytes: 3964
#include <cstdio>

const int MAXN=105;
int h,w;
int cnt[30],mod[4];
char mat[MAXN][MAXN];

int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;++i)
		scanf("%s",mat[i]+1);
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j)
			++cnt[mat[i][j]-'a'+1];
	}
	for(int i=1;i<=26;++i)
		++mod[cnt[i]%4];
//	if(h==1 || w==1){
//		int tmp= h==1 ? w:h;
//		mod[0]=mod[1]=0;
//		for(int i=1;i<=26;++i)
//			++mod[cnt[i]%2];
//		if(mod[1]==(tmp&1)) printf("Yes");
//		else printf("No");
//		return 0;
//	}
//	if(h==1 && w==1){
//		printf("Yes");
//		return 0;
//	}
//	else if(h==1 && w==2 || h==2 && w==1){
//		if(mod[2]==1) printf("Yes");
//		else printf("No");
//		return 0;
//	}
//	else if(h==1 && w==3 || h==3 && w==1){
//		if(mod[2]==1) printf("Yes");
//		else if(mod[3]==1) printf("Yes");
//        else printf("No");
//        return 0;
//	}
	if((h&1) && (w&1)){
		if(mod[1]==1 && mod[3]==0)
			printf("Yes");
		else if(mod[1]==0 && mod[3]==1 && (mod[2]+1)<=2)
			printf("Yes");
		else printf("No");
	}
	else if(((h&1) && (~w&1)) || ((~h&1) && (w&1))){
		int tmp= h&1 ? w:h;
		if((mod[2]<=tmp>>1) && mod[1]==0 && mod[3]==0)
			printf("Yes");
		else printf("No");
	}
	else{
		if(mod[1]==0 && mod[2]==0 && mod[3]==0)
			printf("Yes");
		else printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
map<string, int> k; 
int main() {
  ioso
  #ifndef ONLINE_JUDGE
  ffe
  #endif
  ll n; cin >> n;
  vector<string> kk;
  string s;
  for(int i=0;i<n;++i) {
    cin >> s;
    kk.push_back(s);
  }
  int fk=0;
  for(auto i: kk) {
    fk = k[i];
    k[i] = fk+1;
  }
  int mx=0;
  for(auto i:kk) {
    mx = max(mx,k[i]);
  }
  //std::vector<string> an;
  set<string> an;
  for(auto i:kk) {
    if(k[i]==mx) {
      an.insert(i);
    }
  }
  int siz = an.size();

  for(auto i:an) {
    cout << i << endl;
  }
} 

Measured memory_bytes: 40792
#include<bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int N=2e5+100;
using namespace std;
int a[N];
LL dp[52][52][2510];
int main()
{
	io;
	int n,ave;
	while(cin>>n>>ave)
	{
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=n;i++)cin>>a[i];
		dp[0][0][0]=1;
		for(int i=1;i<=n;++i)
			for(int j=0;j<=i;++j)
			{
				for(int k=2500;k>=0;--k)
				{
					dp[i][j][k]+=dp[i-1][j][k];
					if(k>=a[i]&&j)dp[i][j][k]+=dp[i-1][j-1][k-a[i]];
				}
			}
		LL ans=0;
		for(int i=1;i<=n;i++)
			ans+=dp[n][i][ave*i];
				//cout<<i<<" "<<ave*i<<" "<<dp[n][i][ave*i]<<endl;
//		for(int i=1;i<=n;i++)
//			for(int j=0;j<=i;j++)
//				for(int k=0;k<=46;++k)cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){
    int n, i, a, b, c;
    cin >> n;
    for (i = 0; i < n; i++){
        cin >> a >> b >> c;
        if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
vector<int> generate_sigma0(int n) {
    vector<int> sigma0(n + 1);
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j += i) {
            sigma0[j]++;
        }
    }
    return sigma0;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    auto s0 = generate_sigma0(10'000'000);
    ll ans = 0;
    for(ll k = 1; k <= n; k++) {
        ans += k * s0[k];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 42264
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

ll calc(const vector<pair<int, int>> &s) {
    int n = s.size();
    priority_queue<int> l;
    priority_queue<int, vector<int>, greater<int>> r;
    for (int i = 0; i < n; ++i) {
        l.push(s[i].first);
        r.push(s[i].second);
    }

    int c = 0;
    ll ans = 0;
    while (true) {
        if (l.top() <= c) break;
        ans += l.top() - c;
        c = l.top();
        l.pop();
        if (r.top() >= c) break;
        ans += c - r.top();
        c = r.top();
        r.pop();
    }

    return ans + abs(c);
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> s(n);
    for (auto &e: s) cin >> e.first >> e.second;

    ll ans = 0;
    ans = max(ans, calc(s));
    for (auto &e: s) {
        swap(e.first, e.second);
        e.first *= -1;
        e.second *= -1;
    }
    ans = max(ans, calc(s));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2292
#include<iostream>
using namespace std;
int main(){
   int a,b;
   cin >> a >> b;
   int c,d;
   cin >> c >> d;
   int mas = a * b;
   mas -= (a * d) + (b * c);
   mas += (c * d);
   cout << mas << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
    ll n;
    cin>>n;
    vl x(n);
    rep(i,n){
        cin>>x[i];
    }
    vl t = x;
    sort(all(x));
    rep(i,n){
        if(t[i] >= x[n/2]) cout<<x[n/2-1]<<endl;
        else cout<<x[n/2]<<endl;
    }
	return 0;
}


Measured memory_bytes: 6236
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,a[SZ],b[SZ],an=0,ff[SZ],ed=0;
map<int,int> id;
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
inline int al(int x)
{int&p=id[x]; if(!p) p=++an; return p;}
inline void uni(int a,int b)
{
	int ga=gf(a),gb=gf(b);
	if(ga^gb) ff[ga]=gb;
}
int main()
{
	scanf("%d",&n); int e=-1;
	for(int i=1;i<=n;++i)
		scanf("%d",a+i),a[0]^=a[i];
	for(int i=1;i<=n;++i)
		scanf("%d",b+i),b[0]^=b[i];
	for(int i=1;i<=n;++i)
		if(a[i]!=b[i]) uni(al(a[i]),al(b[i])),++e;
	al(a[0]); al(b[0]);
	for(int i=1;i<=an;++i) if(!ff[i]) ++e;
	sort(a,a+n+1); sort(b,b+n+1);
	for(int i=1;i<=n;++i)
		if(a[i]!=b[i]) {puts("-1"); return 0;}
	printf("%d\n",e);
}


Measured memory_bytes: 11008
#include <cstdio>
#include <stack>
using namespace std;
int main(){
	int n;
	stack<int> car;
	while(~scanf("%d",&n)) {
		if(n!=0) car.push(n);
		else{
			printf("%d\n",car.top());
			car.pop();
		}
	}	
	return 0;
}

Measured memory_bytes: 1036
import java.util.Scanner;

public class Main {
  private static boolean isOddNumDigits (int n) {
    int count = 0;
    while (n > 0) {
      n /= 10;
      count++;
    }
    return count % 2 == 1;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    sc.close();
    int count = 0;
    for (int i = 1; i <= n; i++) {
      count += isOddNumDigits(i) ? 1 : 0;
    }
    System.out.println(count);
  }
}

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


int main() {

    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        int cnt = 0;
        for (char c = 'a'; c <= 'z'; ++c) {
            bool left = false, right = false;
            for (int j = 0; j < i; ++j) {
                if (s[j] == c) left = true;
            }
            for (int k = i; k < n; ++k) {
                if (s[k] == c) right = true;
            }
            if (left && right) ++cnt;
        }
        ans = max(cnt, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] a_b_c = sc.nextLine().split(" ");
        int a = Integer.parseInt(a_b_c[0]);
        int b = Integer.parseInt(a_b_c[1]);
        int c = Integer.parseInt(a_b_c[2]);
        int i = (int)IntStream.rangeClosed(a, b)
                .filter(x -> {
                    return c % x == 0;
                })
                .count();
        System.out.println(i);
    }
}




Measured memory_bytes: 32392
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:
  print('Yes')
else:
  print('No')

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

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int r,c,q;cin>>r>>c>>q,r|c|q;){
		vi as(q),bs(q),os(q);
		rep(i,q) cin>>as[i]>>bs[i]>>os[i];
		
		ll res=0;
		int cnts[2]={r,c};
		vi flgs[2]={vi(r),vi(c)};
		for(int i=q;i--;){
			int a=as[i],b=bs[i],o=os[i];
			if(flgs[a][b]) continue;
			flgs[a][b]=1;
			cnts[a]--;
			if(o)
				res+=cnts[!a];
		}
		
		cout<<res<<endl;
	}
	
	return 0;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  u64 N, K;
  cin >> N >> K;
  vector<u64> Sum(N + 1, 0);
  u64 tmp = 0;
  for (u64 i = 0; i < N + 1; ++i) {
    tmp += i;
    Sum[i] += tmp;
  }
  u64 res = 0;
  for (u32 i = K; i <= N; ++i) {
    res += (Sum[N] - Sum[N - i]) - Sum[i - 1] + 1;
    if (res > MAX_NUM) res %= MAX_NUM;
  }
  res++;
  cout << res % MAX_NUM << endl;
}

Measured memory_bytes: 4792
def maxHeapify(A, i):
    l = 2*i
    r = 2*i+1
    if l < len(A) and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r < len(A) and A[r] > A[largest]:
        largest = r
    if not largest == i:
        A[i], A[largest] = A[largest],A[i]
        maxHeapify(A, largest)

def buildMaxHeap(A, H):
    for i in range(H//2,0,-1):
        maxHeapify(A, i)
        
H = int(input())
A = [int(i) for i in input().split()]
A = [0] + A
buildMaxHeap(A, H)
tmp = ""
for i in A[1:]:
    tmp+= " " + str(i)
print(tmp)


Measured memory_bytes: 63844
#include<stdio.h>
 #include<string.h>
 int main(void)
 {
     char S[100];
     int i,N,j=0;
     scanf("%s",S);
     N=strlen(S)-1;
     for(i=0;i<=N;i++)
       if(S[i]!=S[N-i]) j++;
     printf("%d\n",j-j/2);
     return 0;
 }

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    vector<ll>s(n+1);
    rep(i,n) s[i+1] += s[i] + a[i];
    ll ans = 1e19;
    for(int i = 1;i<=n-1;i++) {
        ll x = s[i];
        ll y = s[n] - s[i];
        ll tmp = abs(x-y);
        ans = min(ans,tmp);
    }
    cout << ans << endl;

}

Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int n;
    cin>>n;
    int a[n];
    for(int i = 0;i < n;i++) cin>>a[i];
    sort(a,a+n);
    int ans = a[n-1]/2;
    for(int i = 0;i < n-1;i++) ans += a[i];
    cout<<ans;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
	bool f[105000];
	int n;
	long long int sum[105000];
	memset(f,false,sizeof(f));
	sum[0]=0;
	for(int i=2;i*i<=105000;i++){
		if(f[i])continue;
		for(int j=i*i;j<105000;j+=i)f[j]=true;
	}
	int k=1;
	for(int j=2;j<=105000;j++){
		if(!f[j]){
			sum[k]=sum[k-1]+j;
			k++;
		}
	}
	while(1){
		cin>>n;
		if(n==0)break;
		cout<<sum[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template< typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; }
template< typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;
  vector<int> A(N+1),B(N);
  cin >> A >> B;
  int sum = 0;
  for (int i = N-1; i >= 0; i--) {
    sum += min(A[i+1],B[i]);
    B[i] -= min(A[i+1],B[i]);
    sum += min(A[i],B[i]);
    A[i] -= min(A[i],B[i]);
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N, K;
  cin >> N >> K;

  int ans = 0;
  if (N > K && K > 1) ans = N - K;

  cout << ans << endl;
}

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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

int n;
int h[100005];
int dp[100005];

int main(){
  
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d",&h[i]);
  }

  dp[2]=abs(h[1]-h[2]);
  for(int i=3;i<=n;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }

  printf("%d\n",dp[n]);
  
  return (0);
}


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

int main()
{
  uint64_t n;
  cin >> n;
  uint64_t ans = 0;
  vector<uint64_t> primes;

  for (uint64_t i = 2; i <= 1'000'000; i++) {
    bool f = true;
    for (uint64_t p : primes) {
      if (p * p > i) break;
      if (i % p == 0) {
        f = false;
        break;
      }
    }
    if (f) {
      primes.push_back(i);
    }
  }

  for (uint64_t p : primes) {
    if (p * p > n) break;
    for (uint64_t x = p; x <= n; x *= p) {
      if (n % x == 0) {
        n /= x;
        ans++;
      }
    }
    while (n % p == 0) {
      n /= p;
    }
  }

  if (n > 1) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 4328
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int k,x;
    cin >> k >> x;
    cout << ((500*k >= x) ? "Yes" : "No") << endl;
}

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

int main(){
  int n,sum=0;
  cin >> n;
  vector<int> l(2*n);
  for(int i=0;i<2*n;i++)cin >> l.at(i);
  sort(l.begin(),l.end());
  for(int i=0;i<n;i++)sum+=l.at(i*2);
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int a;
	cin >> a;
	cout<<(a + a*a + a*a*a);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define MAX_N 200000
#define mid ((l+r)>>1)
using namespace std;
int n, a[MAX_N+5];
bool chk(int x)
{
	map <int, int> c;
	if (x == 1) return is_sorted(a+1, a+n+1);
	for (int i = 1, v; i <= n; i++)
		if ((v = a[i]) <= a[i-1])
		{
			c[v]++, c.erase(c.upper_bound(v), c.end());
			while (v && c[v] == x) c.erase(v), c[--v]++;
			if (!v) return false;
		}
	return true;
}
int bi_search(int l, int r)
{
	int ret = n;
	while (l <= r)
		if (!chk(mid)) l = mid+1;
		else ret = mid, r = mid-1;
	return ret;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a+i);
	return printf("%d\n", bi_search(1, n)), 0;
}

Measured memory_bytes: 1152
h,w=map(int,input().split());f=lambda x:max(x)-min(x);g=lambda h,w:min([min(f([i,((h-i)//2),(h-i-(h-i)//2)])*w,f([i*w,(h-i)*(w//2),(h-i)*(w-w//2)]))for i in range(1,h)]);print(min(g(h,w),g(w,h)))

Measured memory_bytes: 7096