akhauriyash/Code-Regression huggingface dataset:
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int N = 8;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

bool hs[N], vs[N], ds0[N * 2], ds1[N * 2];
vpii qs;

/* subroutines */

void qset(int x, int y) {
  hs[y] = vs[x] = ds0[x + y] = ds1[x - y + N - 1] = true;
  qs.push_back(pii(x, y));
}

void qunset(int x, int y) {
  hs[y] = vs[x] = ds0[x + y] = ds1[x - y + N - 1] = false;
  qs.pop_back();
}

bool qused(int x, int y) {
  return (hs[y] || vs[x] || ds0[x + y] || ds1[x - y + N - 1]);
}

void qprint() {
  bool bs[N][N];
  memset(bs, false, sizeof(bs));

  for (int i = 0; i < qs.size(); i++)
    bs[qs[i].second][qs[i].first] = true;

  for (int y = 0; y < N; y++) {
    for (int x = 0; x < N; x++) putchar(bs[y][x] ? 'Q' : '.');
    putchar('\n');
  }

  exit(0);
}

void rec(int y) {
  if (y >= N) qprint();

  if (hs[y]) rec(y + 1);
  else
    for (int x = 0; x < N; x++)
      if (! qused(x, y)) {
	qset(x, y);
	rec(y + 1);
	qunset(x, y);
      }
}

/* main */

int main() {
  int k;
  cin >> k;

  for (int i = 0; i < k; i++) {
    int r, c;
    cin >> r >> c;
    qset(c, r);
  }

  rec(0);

  return 0;
}

Measured memory_bytes: 1140
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        n: u64,
    }
    let mut prime = vec![];
    let mut is_prime = vec![true; 1e6 as usize + 1];
    let mut t = 2u64;
    while t * t <= n{
        if is_prime[t as usize]{
            prime.push(t);
        }
        for i in ((t * 2)..=(1e6 as u64)).step_by(t as usize){
            is_prime[i as usize] = false;
        }
        t += 1;
    }
    let mut ans = 0;
    let mut t = n;
    for &i in prime.iter(){
        let mut cnt = 0;
        while t % i == 0{
            cnt += 1;
            t /= i;
        }
        let mut u = 1;
        while cnt - u >= 0{
            ans += 1;
            cnt -= u;
            u += 1;
        }
    }
    if t > 1{
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 3708
n,t = gets.split.map!(&:to_i)
tim = gets.split.map!(&:to_i)

ans = 0
now = 0
tim.each do |e|
    if e < now
        x = t - (now - e)
        now += x
        ans += x
    else
        now = e + t
        ans += t
    end
end

puts ans

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
  x=x->left;
  return x;
  }
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
    return x;
  }
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else{
    return treeSearch(u->right,k);
  }
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL){
    return treeMinimum(x->right);
      }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  Node a = root;
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left!=NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root = x;
  }
  else if(y == y->parent->left){
      y->parent->left=x;
    }
  else{
    y->parent->right=x;
  }
  if(y!=z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	cin >> N;
	
	LL h = -1, n = -1, w = -1;
	int found = 0;
	for(h=1; h<=3500; h++){
		for(w=1; w<=3500; w++){
			LL A = N*h*w;
			LL B = 4*h*w - N*(h+w);
			if(B > 0 && A >= B && (A % B) == 0){
				n = A / B;
				found = 1;
				break;
			}
		}
		if(found == 1){
			break;
		}
	}
	printf("%lld %lld %lld\n", h, n, w);
	return 0;
}

Measured memory_bytes: 3780
n = int(input())
a = list(map(int, input().split()))

cnt = 0
while True:
    if n == sum(1 if x % 2 == 0 else 0 for x in a):
        a = list(map(lambda x: x//2, a))
        cnt += 1
    else:
        break
print(cnt)


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s;
	while(cin>>s,s!="0"){
		int ans=0,c[2][11]={0},d;
		rep(i,s.size()){
			d=(i&1?10:1)*(s[i]-'0');
			rep(j,11)c[i&1][(j+d)%11]=c[i&1^1][j];
			if(s[i]!='0')c[i&1][d%11]++;
			ans+=c[i&1][0];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1120
#include <stdio.h>

int main(void)
{
	char c;
	int i;
	
	while (scanf("%c", &c)){
		if (c == '\n'){
			break;
		}
		
		if ('a' <= c && c <= 'z'){
			c -= 0x20;
		}
		printf("%c", c);
	}
	
	printf("\n");
	
	return (0);
}

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

int main(void)
{
    int A, B;
    cin >> A >> B;
    if( A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0 ){
        cout << "Possible";
        return 0;
    }
    cout << "Impossible";
    return 0;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

bool chk(string s)
{
  map<char, int> mp;
  REP(i,s.size()) mp[s[i]]++;
  return (mp.size()!=1);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  int ans = 1e9;
  for(char c='a'; c<='z'; c++){
    string t = s;
    int cnt = 0;
    while(chk(t)){
      string tmp = "";
      REP(i,t.size()-1){
        if(t[i]==c || t[i+1]==c) tmp.push_back(c);
        else tmp.push_back(t[i]);
      }
      t = tmp;
      cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = long.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var sum = new long[N];
        var diff = new long[N];

        for (var i = 0; i < N; i++)
        {
            if (i - A[i] >= 0)
            {
                diff[i - A[i]]++;
            }
            if (i + A[i] < N)
            {
                sum[i + A[i]]++;
            }
        }
        Console.WriteLine(sum.Zip(diff, (s, d) => s * d).Sum());
    }
}


Measured memory_bytes: 47536
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>
#include <cassert>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> d1(n), d2(n);
	rep(i, n)cin >> d1[i] >> d2[i];
	rep(i, n - 2)
	{
		if (d1[i] == d2[i] && d1[i + 1] == d2[i + 1] && d1[i + 2] == d2[i + 2])
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

using namespace std;

int main() {
    int n, a, b, c=0;
    cin >> n >> a >> b;
    for(int i=1;i<=n;i++) {
        int k = i, s = 0;
        while(k) {
            s += k%10;
            k /= 10;
        }
        if(s >= a && s <= b) c += i;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

ll cnt[5];
string tmp="MARCH";

void chk(string s){
	if(s[0]=='M') cnt[0]++;
	else if(s[0]=='A') cnt[1]++;
	else if(s[0]=='R') cnt[2]++;
	else if(s[0]=='C') cnt[3]++;
	else if(s[0]=='H') cnt[4]++;
}

int main(){
	IOS();
	ll n;cin>>n;
	REP(i,n){
		string s;cin>>s;
		chk(s);
	}
	ll ans=0;
	REP(i,5){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				ans+=cnt[i]*cnt[j]*cnt[k];
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define MOD 1000000007
#define INF MOD
#define ALL(x) std::begin(x), std::end(x)


int N, A, B, C, l[11];


long long cost(int X, const std::vector<int>& a)
{
  if (a.empty())
    return INF;
  
  int L = 0;

  for (const auto& i : a)
    L += l[i];

  return std::abs(L - X) + (a.size() - 1) * 10;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N >> A >> B >> C;

  for (int i = 0; i < N; i ++)
    std::cin >> l[i];

  int wm = INF;

  for (int i = 0; i < (1 << 16); i ++) {
    int x;

    std::vector<int> a, b, c, d;

    for (int j = 0, ii = i; j < N; j ++, ii >>= 2) {
      x = ii & 3;

      (x == 1 ? a : x == 2 ? b : x == 3 ? c : d).push_back(j);
    }

    long long w = cost(A, a) + cost(B, b) + cost(C, c);

    if (w < wm)
      wm = w;
  }

  std::cout << wm << std::endl;

  return 0;
}


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

using namespace std;

#define sc(a) scanf("%d", &a);

int n;

int main(){
    sc(n);
    int arr[n];
    for(int i = 0; i < n; i++){
        sc(arr[i]);
    }
    int ctd = 0;
    for(int i = 0; i < n; i++){
        while(arr[i] % 2 == 0){
            //cout << ctd << '\n';
            arr[i] /= 2;
            ctd += 1;
        }
    }
    cout << ctd << '\n';
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):

    return [il(t) for _ in range(N)]


N = ii()
A = il()
ans = float("inf")
for sign in (1, -1):
    sum_a = 0
    c = 0
    for i in range(N):
        sum_a += A[i]
        if sum_a * sign <= 0:
            # +1になるまで加算
            c += abs(sum_a) + 1
            # 総和は1or-1のため
            sum_a = sign
        sign *= -1
    ans = min(ans, c)
print(ans)


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

int seq[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int k;
    cin >> k;
    cout << seq[k];
}

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

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

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

	int n, k;
	cin >> n >> k;

	int sum = 0;

	vector<int> a(n);

	for (int &x : a) {
		cin >> x;
		sum += x;
	}

	sort(a.begin(), a.end());
	int m = k;

	while (k > 0 && a.back() * 4 * m >= sum) {
		k--;
		a.pop_back();
	}

	cout << (k == 0 ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

string s;
/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();
    cin >> s;

    if (SZ(s) == 2 && s[0] == s[1]) {
        cout << 1 << " " << 2 << endl;
        return 0;
    }

    REP (i, SZ(s) - 2) {
        if (s[i] == s[i+2] || s[i] == s[i+1] || s[i+1] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict

N = int(input())
A = [int(v) for v in input().split()]
Q = int(input())

dic = defaultdict(int)

ans = 0
for a in A:
    ans += a
    dic[a] += 1

for _ in range(Q):
    b,c = [int(v) for v in input().split()]
    if b in dic:
        value = dic.pop(b)
        ans += c * value
        ans -= value * b
        dic[c] = dic[c] + value
    print(ans)


Measured memory_bytes: 21368
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


ll n, c;
vector<pair<ll, ll>> cs[30];
ll num[30][half_inf];

void solve() {
    rep(i, c) sort(cs[i].begin(), cs[i].end());
    rep(i, c) {
        ll now = -1;
        rep(j, cs[i].size()) {
            if (now == cs[i][j].first) {
                for (ll k = cs[i][j].first + 1; k <= cs[i][j].second; k++) {
                    num[i][k]++;
                }
            } else {
                for (ll k = cs[i][j].first; k <= cs[i][j].second; k++) {
                    num[i][k]++;
                }
            }
            now = cs[i][j].second;
        }
    }
    ll ans = 0;
    rep(i, half_inf) {
        ll temp = 0;
        rep(j, c) {
            temp += num[j][i];
        }
        ans = max(temp, ans);
    }
    cout << ans << endl;
}

int main() {
    cin >> n >> c;
    rep(i, n) {
        ll s, t, c;
        cin >> s >> t >> c;
        s--, t--, c--;
        cs[c].emplace_back(make_pair(s, t));
    }
    solve();
    return 0;
}

Measured memory_bytes: 26112
#include<cstdio>

int main(){
    int a,b,d,r;
    double f;
    
    scanf("%d %d" , &a , &b);
    
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;

    printf("%d %d %f\n", d , r , f);
    
    return 0;

}



Measured memory_bytes: 2752
N = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

sorted_a = sorted(a)
sorted_b = sorted(b)
sorted_c = sorted(c)
ans = 0
before_a = 0
before_c = 0
count_a = 0
count_c_rest = 0
for each_b in sorted_b:
    for ai in range(before_a, len(sorted_a)):
        if each_b > sorted_a[ai]:
            count_a += 1
            before_a += 1
        else:
            before_a = ai
            break

    for ci in range(before_c, len(sorted_c)):
        if sorted_c[ci] <= each_b:
            count_c_rest += 1
            before_c += 1
        else:
            before_c = ci
            break

    ans += count_a * (len(sorted_c)-count_c_rest)
print(ans)


Measured memory_bytes: 23328
#include <iostream>
using namespace std;
bool test(int a) {
    if (a/10000!=a%10){
        return false;
    }
    if ((a/1000)%10 !=(a%100)/10){
        return false;
    }
    return true;
}
int main(void) {
    int A,B;
    cin >> A >> B;
    int s = 0;
    for (int i=A;i<=B;i++) {
        if (test(i)){
            s++;
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
package main

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

var (
	BufferSize = 10*10*10*10*10 + 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func getRev(before byte) byte {
	if before == '0' {
		return '1'
	}
	return '0'
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	s := scanStr(sc)

	var count int
	prev := s[0]
	for i := 1; i < len(s); i++ {
		if prev == s[i] {
			prev = getRev(s[i])
			count++
		} else {
			prev = s[i]
		}
	}

	fmt.Printf("%d\n", count)
}

func main() {
	check()
}


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

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<LL,LL>


#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())


#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
const int N = 100000;
int cnt[N + 5];
int n,ara[N + 5];
int main()
{
    cin >> n;
    FOR(i,1,n)
    {
        cin >> ara[i];
        cnt[ara[i]]++;
    }
    int ans = 0;
    FOR(i,0,N)
    {
        int c = 0;
        if(i-1>=0)c+=cnt[i-1];
        c+=cnt[i];
        c+=cnt[i+1];
        ans = max(ans,c);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
using namespace std;
int a[105];
int main()
{
    long long n,num1,num2,sum=0;
    scanf("%lld",&n);
    while(n--)
    {
        scanf("%lld%lld",&num1,&num2);
        sum+=(num2-num1+1);
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(void){
	ios::sync_with_stdio(false);
	int T;
	cin>>T;
	for(int t=1;t<=T;t++){
		int a=0,b=0,ok=true;
		for(int i=1,x;i<=10;i++){
			cin>>x;
			if(!ok)continue;
			if(x<a&&x<b){
				cout<<"NO"<<endl;
				ok=false;
				continue;
			}
			else if(x>a&&x>b){
				if(a>b)	a=x;
				else	b=x;
			}
			else if(x<a&&x>b){
				b=x;
			}
			else if(x>a&&x<b){
				a=x;
			}
			if(i==10)
				cout<<"YES"<<endl;
		}
	}
}

Measured memory_bytes: 1184
N = int(input())
seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
prime_map = {}
for prime in seed_primes:
    prime_map[prime] = 0


for i in range(2, N+1):
    _i = i
    for prime in seed_primes:
        while _i % prime == 0:
            prime_map[prime] += 1
            _i = _i // prime

reduced_prime_map = {}
for k, v in prime_map.items():
    if v > 0:
        reduced_prime_map[k] = v

prime_list = list(reduced_prime_map.values())



def dfs(n, res):
    global count
    if res == 75:
        count += 1
        return
    if res > 75:
        return
    if n == len(prime_list):
        return

    for thres in [0, 2, 4, 14, 24, 74]:
        if prime_list[n] >= thres:
            dfs(n + 1, res*(thres+1))

count = 0
dfs(0, 1)
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using Int = int64_t;
int main() {
    Int N, cnt = 0;
    cin >> N;
    vector<Int> a(N);
    for (auto& i : a) {
        cin >> i;
        if (i == cnt + 1) cnt++;
    }
    cout << (cnt == 0 ? -1 : N - cnt) << endl;
}


Measured memory_bytes: 1792
n,m=map(int,input().split())
def divisor(n): #約数全列挙
    ans = [1,n]
    i = 2
    while i**2 <= n:
        if n%i == 0:
            ans.append(i)
            if i**2 < n:
                ans.append(n//i)
        i += 1
    ans.sort()
    return ans

mlist=divisor(m)
ans = 0
for i in mlist:
    if n*i<=m:
        ans = max(ans,i)

print(ans)

Measured memory_bytes: 38640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 20:41:09 2019

@author: shinjisu
"""


# 2019/2/9 Yahoo
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def getIntLines(n): return [int(input()) for i in range(n)]


def zeros(n): return [0]*n


def db(x):
    global debug
    if debug:
        print(x)


def probA():
    N, K = getIntList()
    db((N, K))
    if (N+1)//2>=K:
        return 'YES'
    else:
        return 'NO'


def probB():
    a, b = zeros(3), zeros(3)
    db((a,b))
    for i in range(3):
        a[i], b[i] = getIntList()
    db((a,b))
    c = set([])
    e = zeros(5)
    for i in range(3):
        c.add(a[i])
        c.add(b[i])
        e[a[i]] += 1
        e[b[i]] += 1
    db((c,e))
    c0,c1,c2,c3,c4=0,0,0,0,0
    for i in range(1, 5):
        if e[i]==0:
            c0 += 1
        elif e[i] == 1:
            c1 += 1
        elif e[i] == 2:
            c2 += 1
        elif e[i] == 3:
            c3 += 1
        else:
            c4 += 1
    db((c0,c1,c2,c3,c4))
    if c1 == 2 and c2 == 2: 
        return 'YES'
    else:
        return 'NO'


def probC():
    K, A, B = getIntList()
    db((K,A,B))
    if B-A < 3:
        bCount = 1 + K
    elif 1+K < A:
        bCount = 1 + K
    else:
        remK = 1+K-A  # ビスケットはA枚
        db(remK)
        bCount = A
        bCount += remK//2*(B-A)
        bCount += remK % 2
    return bCount


def issuedCode():
    for i in range(1, 10**9):
        if (1+K-i*2)//A==i:
            break
        db(i)
    bCount = B*i + (K-2*i)


debug = False
print(probC())


Measured memory_bytes: 3192
n=int(input())
info=[]
for i in range(n-1):
    c,s,f=map(int,input().split())
    info.append([c,s,f])
def cal(i):
    global info,n
    time=0
    s=(n-1)-i #スタートの番号
    for i in range(i):
        if i==0:
            time+=(info[s][1]+info[s][0])
            s+=1
            continue
        if time<=info[s][1]: #sについた時点でまだ一本目が出発していない。
            time=info[s][1]+info[s][0]
        else:
            sa=time-info[s][1] #一本目が出発してからどのくらい経ったか
            if sa%info[s][2]==0: #ジャストで電車来る。
                time+=info[s][0]
            else:
                time+=((sa//info[s][2]+1)*info[s][2]-sa+info[s][0])
        s+=1
    return time
for i in range(n-1,-1,-1): #i=移動回数
    print(cal(i))

Measured memory_bytes: 39792
from collections import deque

N, Q = map(int, input().split())

# N個の頂点について、隣接要素を格納
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

# 各piにxiを追加しておく（子要素は見ない）
points = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x

# 答え
result = [0] * N

# 訪れたら1, まだ訪れていなかったら0
visited = [0] * N
visited[0] = 1

# [ [頂点、累計ポイント], [頂点、累計ポイント], ...]
dq = deque([[0, points[0]]])

# 深さ優先探索(DFS)
while dq:
    node, count = dq.pop()
    result[node] = count
    # 今見ている頂点が持つ隣接要素について
    for ni in G[node]:
        # 未訪問の要素がある場合
        if visited[ni] != 1:
            visited[ni] = 1
            dq.append([ni, points[ni] + count])

print(*result)


Measured memory_bytes: 72296
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 100100;
int a[MAXN], sum[MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    while (cin >> N >> K) {
    	if (N==0 && K==0) break;
    	for (int i = 0; i < N; i++)
    		cin >> a[i];
    	for (int i = 0; i < N; i++) 
    		sum[i+1] = sum[i]+a[i];
    	int ans = -1e9-1;
    	for (int i = 0; i+K <= N; i++) {
    		ans = max(ans, sum[i+K]-sum[i]);
    	}
    	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3884
"""
与えられた数字で要件を満たす値を探す。
条件として、－100～100の範囲で合計が最小になる値を探す。脳筋検索法でいく( ´∀｀ )

"""


n = int(input())
a = list(map(int, input().split()))
total_comp = []

for i in range(-100,101):
    total_prc = 0
    for v in range(n):
        total_prc += (a[v]-i)**2

    total_comp.append(total_prc)
print('{}'.format(min(total_comp)))





Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007
#define INF 1050000000000000

const int maxn = 2e5 + 10;

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

	ll n; cin >> n;
	vl a(maxn);
	ll tmp;
	cin >> a[0];
	FOR(i, 1, n) { cin >> tmp; a[i] = tmp + a[i - 1]; }

	ll ans = INF;
	rep(i, n-1) if (ans > abs(a[n - 1] - 2*a[i])) ans = abs(a[n - 1] - 2*a[i]);

	Print(ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 200005
#define MOD 998244353
#define pb push_back
#define mp make_pair
#define f first
#define s second

ll n, m, i, j, k, t, l, r,tmp, ans, cnt,curr, flag, sum, mn, mx, mxi,x,pre,strt,en;
ll brr[MAX], arr[MAX], dp[101], dpp[101];
string s;
vector<ll> v;



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

        cin>>n>>l>>r;
        cout<<min(l,r)<<" "<<max((l+r)-n,0ll);

    
    return 0;   
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

int main (int argc, char* argv[]) {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int max_x = numeric_limits<int>::min();
	int min_y = numeric_limits<int>::max();
	for (int i = 0; i < n; i++) {
		int c_x;
		cin >> c_x;
		max_x = max(max_x, c_x);
	}
	for (int i = 0; i < m; i++) {
		int c_y;
		cin >> c_y;
		min_y = min(min_y, c_y);
	}
	if (x < y && max_x < min_y && max_x < y && x < min_y) {
		cout << "No War" << endl;
	} else {
		cout << "War" << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define N 100

using namespace std;

int
main ( )
{
  int res = 0;
  int d[ N ];
  int n;
  int i, j;

  scanf ( "%d", &n );
  for ( i = 0; i < n; ++i )
  {
    scanf ( "%d", &d[ i ] );
  }

  for ( i = 0; i < n; ++i )
  {
    for ( j = n - 1; j > i; --j )
    {
      if ( d[ j - 1 ] > d[ j ] )
      {
        swap ( d[ j - 1], d[ j ] );
        ++res;
      }
    }
  }

  for ( i = 0; i < n; ++i )
  {
    if ( i ) putchar ( ' ' );
    printf ( "%d", d[ i ] );
  }
  printf ( "\n%d\n", res );

  return ( 0 );
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    long long a, b;
    cin >> n >> a >> b;
    vector<long long> x(n);
    for(int i=0; i<n; ++i)
        cin >> x[i];

    long long ans = 0;
    for(int i=0; i<n-1; ++i){
        long long dx = x[i+1] - x[i];
        ans += min(dx * a, b);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	string a, b;
	cin >> a >> b;
	if (a.length() > b.length())      cout << "GREATER" << endl;
	else if (a.length() < b.length()) cout << "LESS" << endl;
	else if (a > b)                   cout << "GREATER" << endl;
	else if (a < b)                   cout << "LESS" << endl;
	else                              cout << "EQUAL" << endl;
}

Measured memory_bytes: 3636
// Islands War

#include <iostream>
#include <algorithm>

using namespace std;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second < b.second;
}

int main(){
	int N, M;
	cin >> N >> M;
	pair<int, int> req[M];
	for (int i = 0; i < M; ++i){
		cin >> req[i].first >> req[i].second;
	}

	sort(req, req + M, cmp);

	int start = 1, res = 0;

	for (int i = 0; i < M; ++i){
		if (start <= req[i].first){
			start = req[i].second;
			res++;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int d[20] = {0};
    for (int i=0; i<m; ++i) {
        cin >> d[i];
    }

    int dp[50001];
    fill_n(dp, 50001, n);
    dp[0] = 0;
    for (int i=1; i<=n; ++i) {
        for (int j=0; j<20; ++j) {
            if (i - d[j] >= 0) {
                dp[i] = min(dp[i], dp[i - d[j]] + 1);
            }
        }
    }
    cout << dp[n] << "\n";

    return 0;
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= X; i++)
    {
        for (int j = 0; j <= Y; j++)
        {
            if (i + j == X)
            {
                if (2 * i + 4 * j == Y)
                {
                    printf("Yes\n");
                    return (0);
                }
            }
        }
    }
    printf("No\n");
    return (0);
}

Measured memory_bytes: 3632
W, H, N = list(map(int, input().split()))
X = []
Y = []
A = []
field = [[0] * W for _ in range(H)]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    X.append(x)
    Y.append(y)
    A.append(a)

for i in range(N):
    if A[i] == 1:
        for j in range(X[i]):
            for k in range(H):
                field[k][j] = 1
    elif A[i] == 2:
        for j in range(X[i], W):
            for k in range(H):
                field[k][j] = 1
    elif A[i] == 3:
        for j in range(W):
            for k in range(Y[i]):
                field[k][j] = 1
    else:
        for j in range(W):
            for k in range(Y[i], H):
                field[k][j] = 1

Sum = 0
for i in range(W):
    for j in range(H):
        if field[j][i] == 0:
            Sum += 1

print(Sum)


Measured memory_bytes: 9260
#include <iostream>
using namespace std;
bool f[55565];
int main(void){
    int n;
    cin >> n;
    for(int i = 2;i <= 55555;i++){
        if(!f[i]){
            for(int j = i+i;j <= 55555;j+=i) f[j] = true;
        }
    }
     int tmp = 11;
    for(int i = 0;i < n;i++){
        cout << tmp << " ";
        tmp += 5;
        while(f[tmp]) tmp += 5;
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
center = N // 2
X_ = sorted(X)
ans = [X_[center-1], X_[center]]
center = sum(ans) / 2

for x in X:
    if x < center:
        print(ans[1])
    else:
        print(ans[0])

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

int modnum = 1000000007;

int main(){
    int N;
    std::cin >> N;
    std::vector< int > cnt(N+1, 0);
    cnt[0] = 3;
    long long ans = 1;
    for(int i=0; i<N; i++){
        int a;
        std::cin >> a;
        int tmp = cnt[a] - cnt[a + 1];
        ans *= (long long)tmp;
        ans = ans % modnum;
        cnt[a + 1]++;
    }
    
    std::cout << ans << std::endl;
    
    
    return 0;
}



Measured memory_bytes: 640
h,w = map(int, input().split())

if h ==1 or w==1:
    print(1)
elif h%2 == 1 and w%2==1:
    print(((h+1)//2)*w-w//2)
elif h%2 ==0:
    print((h//2) * w)
else:
    print((w//2) * h)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef struct segment_tree_void {
  void *array;
  int32_t size;
  size_t val_size;
  void (*func) (void *, const void *, const void *);
} segment_tree;

static inline void segment_tree_memcpy (void *dst, const void *src, size_t size) {
  uint8_t *p = dst;
  const uint8_t *q = src;
  while (size--) {
    *p++ = *q++;
  }
}

segment_tree* new_segment_tree (const void *ini, const int32_t n, const size_t val_size, void (*func) (void *, const void *, const void *)) {
  int32_t k = 1;
  while (k < n) k *= 2;
  segment_tree *s = (segment_tree *) calloc (1, sizeof (segment_tree));
  s->array = calloc (2 * k, val_size);
  s->size = k;
  s->val_size = val_size;
  s->func = func;
  for (int32_t i = k; i < 2 * k; ++i) {
    segment_tree_memcpy ((uint8_t *)s->array + i * val_size, ini, val_size);
  }
  uint8_t *a = s->array;
  for (int32_t i = k - 1; i > 0; --i) {
    func (a + i * val_size, a + (2 * i) * val_size, a + (2 * i + 1) * val_size);
  }
  return s;
}

void update (segment_tree * const s, int32_t k, const void *val) {
  k += s->size;
  uint8_t *p = s->array;
  const size_t size = s->val_size;
  segment_tree_memcpy (p + k * size, val, size);
  for (k >>= 1; k > 0; k >>= 1) {
    s->func (p + k * size, p + 2 * k * size, p + (2 * k + 1) * size);
  }
}

void find (const segment_tree *s, int32_t l, int32_t r, void *res) {
  int32_t lindex[64];
  int32_t rindex[32];
  int32_t llen = 0;
  int32_t rlen = 0;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) lindex[llen++] = l++;
    if (r & 1) rindex[rlen++] = --r;
  }
  while (rlen > 0) {
    lindex[llen++] = rindex[--rlen];
  }
  const uint8_t *p = s->array;
  segment_tree_memcpy (res, p + lindex[0] * s->val_size, s->val_size);
  for (int32_t i = 1; i < llen; ++i) {
    s->func (res, res, p + lindex[i] * s->val_size);
  }
}

typedef int32_t i32;

void min (void *c, const void *a, const void *b) {
  i32 p = *(i32 *)a;
  i32 q = *(i32 *)b;
  *(i32 *)c = p < q ? p : q;
}

void run(void){
  i32 n, q;
  scanf ("%" SCNi32 "%" SCNi32, &n, &q);
  i32 initial_value = 2147483647;
  segment_tree *s = new_segment_tree (&initial_value, n, sizeof (i32), min);
  while (q--) {
    i32 type, x, y;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &type, &x, &y);
    if (type == 0) {
      update (s, x, &y);
    } else {
      i32 res = 0;
      find (s, x, y + 1, &res);
      printf ("%" PRIi32 "\n", res);
    }
  }
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2744
N, M = map(int, input().split())
a = list(map(int, input().split()))

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

lcm = 1
for i, ai in enumerate(a):
    gcd = mygcd(lcm, ai)
    lcm = (lcm * ai) // gcd

possible = False
for i, ai in enumerate(a):
    if (lcm // ai) % 2 == 0: break
    else: continue
else:
    possible = True

if possible:
    print((((2 * M) // lcm) + 1) // 2)
else:
    print(0)

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	string s; cin >> s;
	vector<int> cnt(26, 0);
	rep(i, 0, s.size())cnt[s[i] - 'a']++;
	bool flag = true;
	rep(i, 2, s.size()) {
		if (s[i] != s[i - 2]) {
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << "Second" << endl;
		return 0;
	}
	if (s.front() == s.back()) {
		if (s.size() % 2)cout << "Second" << endl;
		else cout << "First" << endl;
	}
	else {
		if (s.size() % 2)cout << "First" << endl;
		else cout << "Second" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pa;
const int maxn=1e5+10;

inline ll rd(){
    ll x=0;char c=getchar();int neg=1;
    while(c<'0'||c>'9'){if(c=='-') neg=-1;c=getchar();}
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*neg;
}

int eg[maxn*2][2],egh[maxn],ect;
int N,M,ans[maxn*2],l,r;
bool flag[maxn];

inline void adeg(int a,int b){
	eg[++ect][0]=b,eg[ect][1]=egh[a],egh[a]=ect;
}

void dfs(int x,bool d){
	flag[x]=1;
	for(int i=egh[x];i;i=eg[i][1]){
		int b=eg[i][0];if(flag[b]) continue;
		if(d) ans[++r]=b;
		else ans[--l]=b;
		dfs(b,d);break;
	}
}

int main(){
    //freopen("","r",stdin);
	N=rd(),M=rd();
	for(int i=1;i<=M;i++){
		int a=rd(),b=rd();
		adeg(a,b);adeg(b,a);
	}
	ans[l=r=1e5]=1;
	dfs(1,0),dfs(1,1);
	printf("%d\n",r-l+1);
	for(int i=l;i<=r;i++) printf("%d ",ans[i]);
    return 0;
}

Measured memory_bytes: 3200
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    B = LI()
    C = LI()
    A.sort()
    B.sort()
    C.sort()
    ans=0
    for b in B:
        ans += bisect_left(A, b) * (N-bisect_right(C, b))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 92644
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    b = IR(n)
    b.sort()
    a = deque(b)
    q = deque([a.pop()])
    n -= 1
    for i in range(n):
        if i&2:
            ai = a.pop()
        else:
            ai = a.popleft()
        x = q[0]
        y = q[-1]
        if i&1:
            q.append(ai)
        else:
            q.appendleft(ai)
    ans = 0
    for i in range(n):
        ans += abs(q[i+1]-q[i])
    a = deque(b)
    q = deque([a.popleft()])
    for i in range(n):
        if i&2:
            ai = a.popleft()
        else:
            ai = a.pop()
        if i&1:
            q.append(ai)
        else:
            q.appendleft(ai)
    ans2 = 0
    for i in range(n):
        ans2 += abs(q[i+1]-q[i])
    print(max(ans,ans2))
    return


#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 53212
#include <stdio.h>
#define MAX_N (100000)
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void) {
  int A, B;
  scanf("%d %d", &A, &B);

  int K = (A + B);
  if(K % 2) {
    printf("IMPOSSIBLE\n");
  } else {
    printf("%d\n", K / 2);
  }

  return 0;
}


Measured memory_bytes: 128