akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

bool isOK(vector<ll>& A, ll mid, ll K) {
    ll now = 0;
    rep(i, SZ(A)) { now += (A[i] - 1) / mid; }
    if (now <= K) {
        return true;
    } else {
        return false;
    }
}

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

    ll ng = 0;
    ll ok = 1e9;

    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(A, mid, K))
            ok = mid;
        else
            ng = mid;
    }

    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 4752
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;

        cout << (N + 1) / 2 << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const ll MOD=998244353,N=3e5+100;
ll n,k,ans,a,b;
ll f[N],inv[N];
inline ll qpow(ll a,ll p,ll m)
{
	ll ans=1,base=a;
	while (p)
	{
		if (p&1) ans=ans*base%m;
		base=base*base%m;
		p>>=1;
	}
	return ans%m;
}
inline void pre()
{
	f[0]=1;
	for (int i=1;i<=N-1;i++)
	{
		f[i]=f[i-1]*i%MOD;
		inv[i]=qpow(f[i],MOD-2,MOD);
	}
	return ;
	}
inline ll C(ll n,ll m)
{
	if ( ! m || n == m ) return 1 ;
	if ( n < m ) return 0 ;
	return f[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	if (k==0)
	{
		printf("1\n");
		return 0;
	}
	pre();
	for (int i=1;i<=n;i++)
	{
		ll x=i,y=k-i*a;
		if (y<0||y%b) continue;
		ans=(ans+C(n,x)%MOD*C(n,y/b)%MOD)%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  cout<<max(0LL,a-b)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long A = scan.nextLong();
        long B = scan.nextLong();
        long K = scan.nextLong();
        if (0 < A - K) {
            System.out.printf("%d %d\n", A - K, B);
            return;
        }
        System.out.printf("%d %d\n", 0, Math.max(B - (K - A),0));
    }
}


Measured memory_bytes: 21844
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn prime_factor(n: u64) -> std::collections::HashMap<u64, u64> {
    if n < 2 {
        return std::collections::HashMap::new();
    }
    let mut res = std::collections::HashMap::new();
    let mut n = n;
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            let c = res.entry(i).or_insert(0);
            *c += 1;
            n /= i;
        }
        i += 1;
    }
    if n != 1 {
        res.insert(n, 1);
    }
    res
}

fn main() {
    input! {
        n: u64
    };

    let pf = prime_factor(n);
    let mut res = 0;
    for (_, c) in pf {
        let mut cur = c;
        let mut m = 1;
        while cur >= m {
            cur -= m;
            res += 1;
            m += 1;
        }
    }
    println!("{}", res);
}


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

using namespace std;

int main() {

    string str;
    cin >> str;

    if (str == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1;
        return 0;
    }

    if (str.length() < 26 ){
        for (char i = 'a'; i <= 'z'; i++){
            if (str.find(i)> 25 || str.find(i) < 0){
                cout << str + i;
                break;
            }
        }
    }else{

        for (int i = 25; i > -1; i--){

            for (char j = str[i]; j <= 'z'; j++){
                if (j != str[i]){
                    if ((str.substr(0,i)).find(j)> 25 || (str.substr(0,i)).find(j) < 0){
                        cout << (str.substr(0,i)) + j;
                        return 0;
                    }
                }
            }

        }


    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


int n, q, a, b;


signed main() {
	int n, k,a,b;
	cin >> n >> k;
	map<int, int>ma;
	rep(i, n) {
		cin >> a >> b;
		if (!ma.count(a)) {
			ma[a] = 0;
		}
		ma[a] += b;
	}
	for (auto p : ma) {
		auto ke = p.first;
		auto v = p.second;
		k -= v;
		if (k <= 0) {
			cout << ke << endl;
			break;
		}
	}
}



Measured memory_bytes: 4224
#include <complex.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}

double triangle_area(xy_t a, xy_t b) {
  return (cross_product(a, b) / 2.0);
}

int main() {
  xy_t P[110];
  int N = 0;
  double x, y;
  
  while(scanf("%lf,%lf", &x, &y)!= EOF) {
    xy_t entry(x,y);
    P[N++] = entry;
  }

  //center all coordinates based on first element
  for (int i = 1; i < N; i++) {
    P[i] -= P[0];
  }
  
  //calculate sum
  double sum = 0.0;
  for (int i = 1; i+1 < N ; i++) {
    xy_t  b = P[i] , c = P[i + 1];
    sum += triangle_area(b, c);
  }

  printf("%.6f\n", abs(sum));
  
}

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

using namespace std;

#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)

LL k;
string s;

int main()
{
	cin>>s;
	cin>>k;
	k--;
	LL i=0;
	for(;i<s.size()&&s[i]=='1';i++);
	if(k<i){
		cout<<1<<endl;
		return 0;
	}
	cout<<s[i]<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define maxn 100009
using namespace std;
int cnt[maxn];
int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= n; i++){
		int x;
		cin >> x;
		cnt[x]++;
	}
	int ans = 0;
	for(int i = 0; i < maxn - 3; i++){
		ans = max(ans, cnt[i] + cnt[i + 1] + cnt[i + 2]);
	}
	cout << ans << endl;
	return 0;
}

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

#define endl "\n"

void hk()
{
    long long int n, x=0, y=0, ans=0, a,b,c,k;

    cin>>a>>b>>c>>k;

    if(k > a + b)
    {
        ans += a;
        k -= (a+b);
    }
    else
    {
        if(a > k)
            ans = k;
        else
            ans = a;
        k = 0;
    }
    ans -= k;

    cout<<ans<<endl;
    return;
}

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

 	int t;
 	t = 1;

 	for(int i=1;i<=t;i++)
    {
        hk();
    }
 	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    long long k;
    cin>>n>>k;
    vector<long long> a(n);
    for(long long i=0;i<n;i++) cin>>a.at(i);
    if(n<=k){
    map<long long,long long> tra;
    long long s=1;
    long long num=0;
    for(long long i=0;i<k;i++){
        if(tra.count(s)){
            num=i+1;
            break;
        }
        else tra[s]++;
        s=a.at(s-1);
    }
    long long pla=1;
    long long NUM=1;
    while(pla!=s){
        NUM++;
        pla=a.at(pla-1);
        }
    long long ans=((k-NUM+1)%(num-NUM));
    long long place=1;
    for(long long i=0;i<NUM+ans-1;i++){
        place=a.at(place-1);
    }
    cout<<place;
    }
    else{
        long long tele=1;
        for(long long i=0;i<k;i++){
            tele=a.at(tele-1);
        }
        cout<<tele;
    }
}
    
    


  
        



Measured memory_bytes: 14788
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long H,X,ans=0;
  cin>>H;
  X=1;
  while(H)
  {
    ans+=X;
    H/=2;
    X*=2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 555

int n, m, i, j;
char s[maxN][maxN];

bool red(int x, int y) {
    if (y == 1) return true;
    if (y == m) return false;
    return (x & 1);
}

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d%d\n", &n, &m);
    for (i = 1; i <= n; i++) scanf("%s\n", s[i] + 1);

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= m; j++) {
            if (red(i, j) || s[i][j] == '#')
                printf("#");
            else
                printf(".");
        }
        printf("\n");
    }

    printf("\n");

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= m; j++) {
            if (!red(i, j) || s[i][j] == '#')
                printf("#");
            else
                printf(".");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 1152
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    fast();


    LL t,n,i,j,k,x,y,c,m;
    cin >> n;
    LL a[n];
    gall(a, n);
    LL dp[n];
    dp[n - 1] = 0;
    for(LL i = n - 2; i >= 0; --i){
        if(a[i] >= a[i + 1]){
            dp[i] = dp[i + 1] + 1;
        }
        else{
            dp[i] = 0;
        }
    }
    cout << *max_element(dp, dp + n);
    
}

Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    char ch;
    cin>>ch;
    char bo[5]={'a','e','i','o','u'};
    rep(i,5){
        if(ch==bo[i]){cout<<"vowel"<<endl;return 0;}
    }
    cout<<"consonant"<<endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let n: i32 = format!("{}{}", a, b).parse().unwrap();
    for i in 1..1001 {
        if i * i == n {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

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


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

using namespace std;

int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int sz=s.size();
    if(sz<=k)
    {
        cout<<s<<endl;
    }else
    {
        for(int i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
void solve(){
    ll k; cin >> k;
    ll sum = 0;
    for(ll i = 1;i <= k;i++){
        for(ll j = 1;j <= k;j++){
            for(ll l = 1;l <= k;l++){
                sum += __gcd(i,__gcd(j,l));
            }
        }
    }
    cout << sum << endl;
}

int main() {
    //int t; cin >> t; while(t--)
    solve();
    
	return 0;
}


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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    string s;
    cin>>s;
    int ans=0;
    for(auto c:s)
    {
        ans+=(c-'0');
    }
    int  n=s.length()-1;
    ans=max(ans,s[0]-'0'-1+9*n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	char a[5];
	cin>>a;
	for(int i=0; i<5; i++){
		if(a[i]==65 && a[i+1]==67){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

int n, m, v[100100];
vector<int> G[100100];

int main()
{
	scanf ("%d %d", &n, &m);
	for (int i = 0; i < m; i++){
		int x, y; scanf ("%d %d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}

	for (int i = 1; i <= n; i++) v[i] = -1;
	queue<int> q; q.push(1);
	while (!q.empty()){
		int x = q.front(); q.pop();
		for (auto& y : G[x]) if (v[y] == -1){
			q.push(y); v[y] = x;
		}
	}

	for (int i = 2; i <= n; i++) if (v[i] == -1){
		puts("No");
		return 0;
	}
	puts("Yes");
	for (int i = 2; i <= n; i++) printf ("%d\n", v[i]);
	return 0;
}


Measured memory_bytes: 10108
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, M, A[1010], B[1010], takara[1010];
int dp[1010][1 << 12];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        cin >> A[i] >> B[i];
        rep(j, 0, B[i]) {
            int c;
            cin >> c;
            c--;
            takara[i] |= 1 << c;
        }
    }

    rep(i, 0, M + 1) rep(msk, 0, 1 << N) dp[i][msk] = inf;
    dp[0][0] = 0;

    rep(i, 0, M) rep(msk, 0, 1 << N) {
        chmin(dp[i + 1][msk], dp[i][msk]);
        chmin(dp[i + 1][msk | takara[i]], dp[i][msk] + A[i]);
    }

    int ans = dp[M][(1 << N) - 1];
    if (ans == inf) ans = -1;
    cout << ans << endl;
}








Measured memory_bytes: 16256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

template <typename T>
vector<T> bellman_ford(int s, int V,vector<edge<T> > &G){
    const T INF = numeric_limits<T>::max();
    vector<T> d(V, INF);
    d[s] = 0;
    for (int i = 0; i < V - 1; ++i) {
        for (auto &&e : G) {
            if (d[e.from] == INF) continue;
            d[e.to] = min(d[e.to], d[e.from] + e.cost);
        }
    }
    for (auto &&e : G) {
        if(d[e.from] == INF) continue;
        if(d[e.from] + e.cost < d[e.to]) return vector<T> ();
    }
    return d;
}

int main() {
    int V, E, R;
    scanf("%d %d %d", &V, &E, &R);
    vector<edge<int>> g;
    for(int i = 0; i < E; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        g.emplace_back(a, b, c);
    }
    auto dists = bellman_ford(R, V, g);
    if(dists.empty()) puts("NEGATIVE CYCLE");
    for(auto &dist : dists) {
        if(dist == numeric_limits< int >::max()) puts("INF");
        else printf("%d\n", dist);
    }
}



Measured memory_bytes: 3268
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

K,N = Line[0],Line[1]

# print(K,N)

input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

# print(Line)

sinLine = [y - x for (x, y) in zip(Line[0:], Line[1:])]

sinLine.append(Line[0]+K-Line[-1])

print(sum(sinLine)-max(sinLine))

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

using namespace std ; 

const int N =1e6 + 7 ; 

int n ;

int grp(pair<int , int>  pr){
        return pr.first <= pr.second ; 
}

bool cp(pair<int , int> a , pair<int , int> b){

        if( grp(a) && grp(b) ){
                if(a.first == b.first) return a.second > b.second ; 
                return a.first < b.first ; 
        }
        else if(grp(a) != grp(b)){
                return grp(a) > grp(b) ; 
        }
        if(a.first == b.first ) 
                return a.second < b.second ; 
        return a.second > b.second ; 
}

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

        vector<pair <int , int> > v ; 
        int tot = 0 ; 
        for(int i = 0 ;i < n ;i++){
                string s ; 
                cin>>s ;
                int sum = 0 , mn = 0 ; 
                for(auto u : s){
                        if( u== '(') sum++ ; 
                        else sum-- ; 
                        mn =  min(mn , sum) ; 
                }
                v.push_back({-mn , sum - mn}) ; 
                tot+= sum ; 
        }
        sort(v.begin() , v.end() , cp ) ; 
        int A = 0 ; 
        int req = 1e9 ; 
        for(int i = 0 ; i < n ;i++){
                int a = v[i].second  ; 
                int b = v[i].first ; 
                A-= b ;
                req = min(req , A) ;  
                A+=a; 
        }

        if( req ==0 && tot == 0 )
                cout<<"Yes" ; 
        else 
                cout<<"No" ; 
        return 0 ; 
}


Measured memory_bytes: 11600
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}



ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1LL;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

ll mod_inv(ll x, ll mod) {
	return mod_pow(x, mod - 2, mod);
}

ll n;
ll two_inv[201010];

P p(Graph& g, ll v, ll par) {
	P ret = make_pair(0,1);//期待値、頂点数のペア

	Array kids;
	for(auto e:g[v]){
		if(e.to!=par){
			P kid = p(g,e.to,v);
			(ret.first += kid.first)%=MOD;
			ret.second+=kid.second;
			kids.push_back(kid.second);
		}
	}

	if(ret.second==n) return ret;
	kids.push_back(n-ret.second);//親側にある頂点数
	ll ans = two_inv[1];//穴になるのは白の場合のみ
	(ans += MOD - two_inv[n])%=MOD; //全部白の確率をひく
	for(auto kid:kids){
		(ans += MOD - ((1-two_inv[kid]+MOD)%MOD * two_inv[n-kid])%MOD)%=MOD;//一辺だけ黒を含む確率をひく
	}
	(ret.first+=ans)%=MOD;
	return ret;
}





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

	cin >> n;
	Graph g(n);

	REP(i, n-1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		add_edge(g, a, b, -1,true,-1);
	}

	two_inv[1] = mod_inv(2LL, MOD);
	for (ll i = 2; i <= n; i++) two_inv[i] = (two_inv[i - 1] * two_inv[1]) % MOD;

	ll sum = 0;
	REP(i, n) {
		if(g[i].size()==1){
			P ans=p(g,i,-1);
			cout<<ans.first<<endl;
			return 0;
		}
	}

	return 0;
}


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

using namespace std;

#define MOD 1'000'000'007

typedef long long int ll;
long long int dp[2001][2001];

ll getWays(int s, int cur)
{
	if(s == 0) return 1;
	if(s == 3) return 1;

	if(s < 3) return 0;
	

	if(dp[s][cur] != -1) return dp[s][cur];
	ll ways = 0;
	for(int i = 3; i <= s; ++i)
	{
		ways += getWays(s - i, cur+i);
		assert(ways >= 0);
		ways %= MOD;
	}

	dp[s][cur] = ways % MOD;
	return dp[s][cur];
}
int main()
{
	memset(dp, -1, sizeof(dp));
	
	int s;
	cin >> s;
	cout << getWays(s, 0) % MOD;

	return 0;
}

Measured memory_bytes: 34896
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } } _io;
typedef long long ll; typedef long double db;

ll exgcd(ll a, ll b, ll& x, ll& y)
{
	if (!b)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll d = exgcd(b, a % b, x, y);
	ll t = x;
	x = y;
	y = t - (a / b) * y;
	return d;
}
ll getInv(ll a, ll mod)
{
	ll x, y;
	return exgcd(a, mod, x, y) == 1 ? (x % mod + mod) % mod : -1;
}

const ll mod = 1e9 + 7, maxn = 1e6 + 5;
ll fact[maxn];

ll fpow(ll a, ll b)
{
	ll res = 1;
	while (b != 0)
	{
		if (b & 1) res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}
void make_fact()
{
	fact[0] = 1;
	for (ll i = 1; i <= 1e6; ++i)
		fact[i] = (fact[i - 1] * i) % mod;
}

int main()
{
	make_fact();
	ll n;
	cin >> n;
	if (n == 1) cout << 0 << endl;
	else
	{
		cout << (((fpow(10, n) - ((2 * fpow(9, n)) % mod)) % mod) + fpow(8, n) + mod) % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 11456
#include<stdio.h>
int main(void){
	
	int n,i;
	char s[100],t[100],ans[200];
	
	for(i=0; i<200; i++) ans[i] = '\0';
	
	scanf("%d", &n);
	scanf("%s", s);
	scanf("%s", t);
	
	for(i=0; i<n*2; i+=2){
		ans[i] = s[i/2];
		ans[i+1] = t[i/2];
	}
	
	printf("%s\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,v;
int main(){
	scanf("%d%d",&n,&v);
	for (int i=0;i<=n;i++)
		for (int j=0;j+i<=n;j++)
			if (i*10000+j*5000+(n-i-j)*1000==v)
				return printf("%d %d %d",i,j,n-i-j),0;
	puts("-1 -1 -1"); 
} 


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

void solve() {
    int d,t,s;
    cin>>d>>t>>s;

   
    if(d<=t*s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
     freopen("in.txt","r",stdin);
      
     #endif

     int t;
     t=1;
     while(t--) solve();


   return 0;
}


Measured memory_bytes: 3616
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 26;
const int D = 365;

int d;

int c[N];
int s[D][N];

vi ans;

int last[N];
int evaluate(const vi& t){
    memset(last, 0, sizeof last);
    int ret = 0;
    FOR(i,t.size()){
        ret += s[i][t[i]];
        last[t[i]] = i+1;

        FOR(j,N){
            ret -= c[j] * (i+1 - last[j]);
        }
    }
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>d;
    FOR(i,N)cin>>c[i];
    FOR(i,d){
    	FOR(j,N){
    		cin>>s[i][j];
    	}
    }

    FOR(i,d){
        // bruteforce
        int best = -1, vbest = -OO;
        FOR(j,N){
            ans.pb(j);
            int v = evaluate(ans);
            if(v > vbest){
                vbest = v;
                best = j;
            }
            ans.pop_back();
        }

        ans.pb(best);
    }

    FOR(i,d){
        cout << ans[i]+1 << endl;
    }

    cerr << "final: " << evaluate(ans) << endl;

    return 0;
}


Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<25);
const ll INFLL = (1ll<<60);
const ll BASE = (1ll<<32);

#define l_ength size

ll MOD[3]={998244353ll,(ll)(1e9+7),(ll)(1e9+9)};

void mul_mod(ll& a, ll b, int k){
	a *= b;
	a %= MOD[k];
}

void add_mod(ll& a, ll b, int k){
	a = (a<MOD[k])?a:(a-MOD[k]);
	b = (b<MOD[k])?b:(b-MOD[k]);
	a += b;
	a = (a<MOD[k])?a:(a-MOD[k]);
}

ll h[1001001][3];

int ufr[575575],ufp[575575];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufp[i] = i;
		ufr[i] = 1;
	}
}

int ufind(int x){
	if(ufp[x] == x){
		return x;
	}
	return ufp[x] = ufind(ufp[x]);
}

bool unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return true;
	}
	if(ufr[x] < ufr[y]){
		swap(x,y);
	}
	ufp[y] = x;
	ufr[x] += ufr[y];
	return false;
}

int main(void){
	int n,m,i,j,k,ans=0;
	ll x[3]={0ll,0ll,0ll},y[3],z[3]={1ll,1ll,1ll};
	bool flag = true;
	string s,t;
	cin >> s; n = s.l_ength();
	cin >> t; m = t.l_ength();
	ufinit(n);
	for(j=0; j<m; ++j){
		for(k=0; k<3; ++k){
			mul_mod(x[k],BASE,k);
			add_mod(x[k],t[j],k);
			h[j+1][k] = h[j][k];
			mul_mod(h[j+1][k],BASE,k);
			add_mod(h[j+1][k],s[j%n],k);
			mul_mod(z[k],BASE,k);
		}
	}
	for(i=0; i<n; ++i){
		for(k=0; k<3; ++k){
			y[k] = h[i+m][k];
			add_mod(y[k],MOD[k]-(h[i][k]*z[k])%MOD[k],k);
		}
		if(x[0] == y[0] && x[1] == y[1] && x[2] == y[2]){
			if(unionf(i,(i+m)%n)){
				flag = false;
			}
		}
		for(k=0; k<3; ++k){
			h[i+m+1][k] = h[i+m][k];
			mul_mod(h[i+m+1][k],BASE,k);
			add_mod(h[i+m+1][k],s[(i+m)%n],k);
		}
	}
	for(i=0; i<n; ++i){
		ans = max(ans,ufr[i]-1);
	}
	cout << ((flag)?ans:(-1)) << endl;
	return 0;
}


Measured memory_bytes: 29192
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  REP(i, n)
  cin >> h[i];
  int count = 0;
  
  for(int i = 0; i < n; i++){
    if(h[i] >= k)
      count++;
  }
  
  printf("%d", count);
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll N;
	cin>>N;
	ll end=sqrt(N);
	
	for(int i=end;i>=1;i--){
		if(N%i==0){
			cout<<(i-1)+(N/i-1);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
var s,tmp:ansistring;
    i,count:longint;
begin
    readln(s);
    tmp:=s[1];
    for i:=2 to length(s) do
    begin
        if tmp<>s[i] then
            inc(count);
        tmp:=s[i];
    end;
    writeln(count);
end.

Measured memory_bytes: 1384
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>

#define MOD 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)

//using namespace std;
using namespace std;

typedef long long ll;


int main() {
    int n;
    cin >> n;
    unordered_map<ll,int> um;
    for(int i = 0;i < n;++i){
        ll l;
        cin >> l;
        ++um[l];
    }
    if(n % 3 == 0){
        if(um.size() == 3 && (*um.begin()).second == (*(++um.begin())).second && (*um.begin()).second == (*(++++um.begin())).second){
            ll a = um.begin()->first;
            ll b = (++um.begin())->first;
            ll c = (++++um.begin())->first;
            if((a ^ b) == c && (a ^ c) == b && (b ^ c) == a){
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
        }
        else if(um.size() == 2){
            ll a = um.begin()->first;
            ll b = (++um.begin())->first;
            if(a == 0 || b == 0){
                if(a == 0 && (++um.begin())->second == um.begin()->second * 2){
                    cout << "Yes" << endl;
                }
                else if(b == 0 && (um.begin())->second == (++um.begin())->second * 2){
                    cout << "Yes" << endl;
                }
                else{
                    cout << "No" << endl;
                }
            }
            else{
                cout << "No" << endl;
            }
        }
        else if(um.size() == 1 && (*um.begin()).first == 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }else{
        if(um.size() == 1 && (*um.begin()).first == 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}






Measured memory_bytes: 4640
#include <stdio.h>

int main() {
	int n, q, b[100010], c[100010], num[100010] = { 0 };
	long long int all = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		all += a;
		num[a]++;
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++) scanf("%d%d", &b[i], &c[i]);

	for (int i = 0; i < q; i++){
		all += (c[i] - b[i]) * num[b[i]];
		num[c[i]] += num[b[i]];
		num[b[i]] = 0;
		printf("%lld\n", all);
	}
	return 0;
}

Measured memory_bytes: 2900
#include<stdio.h>
long long int n, q, s[100001], i, count, key;

int binary_search(long long int i, long long int j){
    long long int x = i + (j-i)/2;
    if(s[x] == key){count++;return 1;}
    else if(i == j || i>j) return 0;
    else if(key > s[x]){
        return binary_search(x+1, j);
    }else if(key<s[x]){
        return binary_search(i, x-1);
    }
}
int main(){
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld", &s[i]);
    }
    scanf("%lld", &q);
    count = 0;
    for(i=0;i<q;i++){
        scanf("%lld", &key);
        binary_search(0, n-1);
    }
    printf("%lld\n", count);
    return 0;
}



Measured memory_bytes: 2556
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    map<string, int> m;
    REP(n, N) {
        string s;
        cin >> s;
        m[s]++;
    }

    int mx = 0;
    for(auto kv: m) {
        mx = max(kv.second, mx);
    }

    set<string> words;
    for(auto kv: m) {
        if (kv.second == mx) words.insert(kv.first);
    }
    for(auto w: words) cout << w << endl;

    return 0;
}



Measured memory_bytes: 34700
r,D,x_2000 = gets.split(" ").map(&:to_i)

X = [x_2000]
k = 0
X.each do |n|
  if k <= 9
    X[k] = r * X[k] - D
    X << X[k]
    k = k+1
  end
end
X.slice!(10)
puts X

Measured memory_bytes: 1788
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	int n;
	int freq[ 7 ];

	while( cin >> n ){
		memset( freq, 0, sizeof(freq) );
		for( int i = 0; i < n; ++i ){
			double height;
			cin >> height;
			int f = static_cast<int>( height - 155 ) / 5;
			if( f < 1 ){
				f = 1;
			}else if( f > 6 ){
				f = 6;
			}
			freq[ f ]++;
		}

		for( int i = 1; i <= 6; ++i ){
			cout << i << ":";
			for( int j = 0; j < freq[ i ]; ++j ){
				cout << "*";
			}
			cout << endl;
		}
	}

	return 0;
}

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9+7);
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;


int main(){
    ll h, w;
    cin >> h >> w;
    if(min(h,w) > 1){
        cout << (h*w+1)/2 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K;
mint cnt[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;

    rrep(g, K, 1) {
        cnt[g] = mint(K / g) ^ N;
        int gg = g * 2;
        while (gg <= K) {
            cnt[g] -= cnt[gg];
            gg += g;
        }
    }

    mint ans = 0;
    rep(g, 1, K + 1) ans += cnt[g] * g;
    cout << ans << endl;
}







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


#define MOD 1000000007L

using ll = long long int;

using namespace std;
int main() {
  string s;
  cin >> s;
  vector<ll> dp(13, 0);
  vector<ll> tmp(13, 0);

  dp[0] = 1;

  for (int idx = 0; idx < s.size(); idx++) {
    if (s[idx] == '?') {
      fill(tmp.begin(), tmp.end(), 0);
      for (int x = 0; x < 10; x++) {
        for (int i = 0; i < 13; i++) {
          tmp[(10 * i + x) % 13] =
            (tmp[(10 * i + x) % 13] + dp[i]) % MOD;
        }
      }

      copy(tmp.begin(), tmp.end(), dp.begin());
    } else {
      int digit = s[idx] - '0';

      for (int i = 0; i < 13; i++) {
        tmp[(10 * i + digit) % 13] = dp[i];
      }

      copy(tmp.begin(), tmp.end(), dp.begin());
    }
  }

  cout << dp[5] << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
int main()
{
  int N, D, X;
  cin >> N >> D >> X;
  int A[N];
  rep(i, 0, N)cin >> A[i];
 
  int ans = 0;
  rep(i, 0, N){
    ans += (D - 1) / A[i] + 1;
  }
  cout << ans + X << endl;
  return 0;
}

Measured memory_bytes: 256
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x , y , sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const ll MOD = 1000000007; /// 1e9+7
const int MAX = 100005;     /// 1e5+5
ll bigmod(ll n, ll r)
{
    if(r==0) return 1;
    if(r==1) return n;
    if(r%2==0)
    {
        ll ret = bigmod(n, r/2);
        return ((ret%MOD) * (ret%MOD)) % MOD;
    }
    else return ((n%MOD) * (bigmod(n,r-1)%MOD)) % MOD;
}
ll modinverse(ll a){return bigmod(a,MOD-2)%MOD;}
ll lcm(ll a, ll b) {a=abs(a); b=abs(b); return (a/__gcd(a,b))*b;}
ll gcd(ll a, ll b) {a=abs(a); b=abs(b); if(!b) return a; return __gcd(b,a%b);}
//int in() {int x; scanf("%d",&x); return x;}
//ll lin() {ll x; scanf("%lld",&x); return x;}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;
	int mx=INT_MIN, mn=INT_MAX, px=-1, pn=-1;
	for(int i=1; i<=n; i++){
		int x; cin>>x;
		if(x>mx) mx=x,px=i;
		if(x<mn) mn=x,pn=i;
	}
	cout<<2*n-1<<endl;
	if(abs(mx)<abs(mn)){
		for(int i=1; i<=n; i++) cout<<pn<<" "<<i<<endl;
		for(int i=n; i>1; i--) cout<<i<<" "<<i-1<<endl;
	}
	else{
		for(int i=1; i<=n; i++) cout<<px<<" "<<i<<endl;
		for(int i=1; i<n; i++) cout<<i<<" "<<i+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
typedef long long ll;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define PI pair<int,int>

const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const ll mod = (ll)(1e9 + 7);
const int N = 1000010;


int main() {    
    string str;
    while (cin >> str) {
        int n = str.length();
        if (str[n-1] == '3') cout << "bon\n";
        else if (str[n-1] == '0' || str[n-1]=='1' || str[n-1]=='6' || str[n-1]=='8') {
            cout << "pon\n";
        } else cout << "hon\n";
    }
    return 0;
}
    


Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int t = sc.nextInt();
    if(x-t>0){
      System.out.println(x-t);
    }else{
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
 
# define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d%d",x,y)
#define piii(x,y,z) printf("%d%d%d",x,y,z) 
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld%lld",x,y)
#define plll(x,y,z) printf("%lld%lld%lld",x,y,z) 
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pp pop_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<ll> 
#define tci int t;scanf("%d",&t);while(t--)
const int maxn=10e6+4;

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

 	vint v;
 	for(int i=1;i<100000;i++)
 	{
 		v.pb(i*i);
 	}
 	ll n;sl(n);
 	rep(i,100000)
 	{
 		if(v[i]>n)
 		{
 			cout<<v[i-1];
 			return 0;
 		}
 	}
    return 0;
}	

Measured memory_bytes: 1400