akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}


int main() {
	int num, digit;
	while (cin >> num >> digit) {
		if (num == 0 && digit == 0) break;
		string numstr = to_string(num);
		int flag = 1;
		vector<string> numkey;

		for (int j = 0; j < 20; j++) {

			//1.0埋め
			//cout << "@" << digit << " " << numstr.size() << " " << numstr << endl;
			int si = digit - numstr.size();
			for (int i = 0; i < si; i++) {
				numstr = '0' + numstr;
			}
			numkey.emplace_back(numstr);
			//2.最大最小
			string maxnum, minnum;
			maxnum = minnum = numstr;
			sort(minnum.begin(), minnum.end());
			sort(maxnum.begin(), maxnum.end(), greater<>());
			//cout << "max" << maxnum << endl;
			//cout << "min" << minnum << endl;

			//3.差
			int dif;
			dif = stoi(maxnum) - stoi(minnum);
			//cout << "dif" << dif << endl;

			numstr = to_string(dif);

			for (int k = 0; k < numkey.size(); k++) {
				if (stoi(numkey[k]) == dif){
					cout << k << " " << dif << " " << j - k +1<< endl;
					flag = 0;

					//cout << numkey << endl;

					break;
				}
			}
			//cout <<"*"<< numkey << endl;
			if (flag == 0) break;
			//numkey.emplace_back(numstr);
		}
	}
}



Measured memory_bytes: 3248
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

lli n, k, sum = 0;
vector<lli> v;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> k;
	v.resize(n);
	
	for (int i = 0; i < v.size(); i++)
	{
		cin >> v[i];
	}
	
	for (int i = 0; i < k; i++)
	{
		auto x = min_element(v.begin(), v.end());
		sum += *x;
		v.erase(x);
	}
	
	cout << sum << "\n";
	
	
	return 0;
}


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

using namespace std;

int main() {
    int n, k;

    scanf("%d %d", &n, &k);

    long long int cnt = 0, tmp;

    if(k % 2 == 0) {
        tmp = floor(1.0 * (n - k / 2) / k) + 1;
        cnt += tmp < 0 ? 0 : tmp * tmp * tmp;
    }

    tmp = floor(n / k);
    cnt += tmp < 0 ? 0 : tmp * tmp * tmp;

    printf("%lld\n", cnt);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

template<class T>
T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
template<class T>
T lcm(T a, T b){return a / gcd(a, b) * b;}

int main() {
    long long a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
    string inp_str, judge_str;
    vector<char> inp;
    cin >> inp_str >> judge_str;
    for(int i = 0; i < inp_str.size(); i++) inp.push_back(inp_str[i]);

    bool success = false;
    for(int i = 0; i < inp.size(); i++){
        string tmp = "";
        for(int start = i; start < inp_str.size()+i; start++){
            tmp += inp[start%inp_str.size()];
        }

        if(judge_str == tmp) success = true;
    }

    if(success){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
  char c;
  cin >> c;
  string S ="abcdefghijklmnopqrstuvwxyz";
  for(int i=0; i<25; i++){
  	if(c == S.at(i)) {
      cout << S.at(i+1) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<pair<int,int> > A(N);
    for(int i=0;i<N;i++){
        int s;cin >> s;
        A[i] = make_pair(s,i+1);
    }
    sort(A.begin(),A.end());
    for(int i=0;i<N-1;i++){
        cout << A[i].second << " ";
    }
    cout << A[N-1].second << "\n";
    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = Integer.parseInt(scan.next());
        scan.close();

        int sum = 0;
        for (int a = 1; a <= k; a++) {
            for (int b = 1; b <= k; b++) {
                for (int c = 1; c <= k; c++) {
                    int gcd = gcd(a, gcd(b, c));
                    sum += gcd;
                }
            }
        }

        System.out.println(sum);
    }

    private static int gcd(int a, int b) {
        if (a < b) {
            int memory = a;
            a = b;
            b = memory;
        }

        int q = a % b;
        while (q != 0) {
            a = b;
            b = q;
            q = a % b;
        }
        return b;
    }

}


Measured memory_bytes: 35760
#include<iostream>
#include<cmath>
using namespace std;
#define limit (int)(pow(10, 9) + 7)
 
int main() {
  int N;
  cin >> N;
  
  long long int power = 1;
  for(int i = 1; i <= N; i++){
    power *= i;
    power %= limit;
  }
  
  cout << power << endl;
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));


const int LimitN = 5e5 + 10; 

int n; 
long long a, b, c, d;  
int main() {
    #define file "in"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    scanf("%d %lld %lld %lld %lld", &n, &a, &b, &c, &d); 
    
    for (int i = 1; i <= n; ++i) {
    	pair<long long, long long> s[3];
    	s[0] = make_pair(a - 1LL * (i - 1) * d, a - 1LL * (i - 1) * c); 
    	s[1] = make_pair(b - 1LL * (n - i) * d, b - 1LL * (n - i) * c);
    	if (s[0].first > s[1].first) swap(s[0], s[1]);	  
    	if (s[0].second >= s[1].first) {
    		printf("YES\n");
    		return 0; 
    	}
    	 
    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
# tenka1-2018D - Crossing
"""
if N = K(K + 1)/2 -> Yes
construct a triangle(e.g. N = 10, K = 4):
    1 0 0 0
    2 3 0 0
    4 5 6 0
    7 8 9 10
the answer will be:
  {each row until 0 + column straight down from there}
    {1 2 4 7}
    {2 3 5 8}
    {4 5 6 9}
    {7 8 9 10}
  {diagonal line}
    {1 3 5 10}
"""
def main():
    N = int(input())
    K = int((N * 2) ** 0.5)
    if K * (K + 1) / 2 != N:
        print("No")
        return
    row, cur, cnt = [], 1, 1
    while cur + cnt - 1 <= N:
        row.append(list(range(cur, cur + cnt)) + [0] * (K - cnt))
        cur += cnt
        cnt += 1
    col = [list(c) for c in zip(*row)]
    ans, diag = [], []  # diag: diagonal line
    for i, (r, c) in enumerate(zip(row, col)):
        diag.append(r[i])
        ans.append(r[:i] + c[i:])
    ans.append(diag)
    print("Yes", K + 1, sep="\n")
    for a in ans:
        print(K, end=" ")
        print(" ".join(map(str, a)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 12396
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  int ret = 0;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    if(i%2==1&&x%2==1)ret++;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> l_l; 
const ll INF=10001001000;
int main(){
    ll N;cin >> N;
    vector<l_l> paths[100100];
    for(int i=1; i<=N-1; i++){
        ll a,b,c;cin >> a >> b >> c;
        paths[a].push_back({b,c});
        paths[b].push_back({a,c});
    }
    ll Q,K;cin >> Q >> K;
    vector<ll> x(Q),y(Q);
    for(int i=0; i<Q; i++){
        cin >> x[i] >> y[i];
    }
    vector<ll> d(N+1,INF);
    stack<l_l> st;
    st.push({K,0});
    d[K]=0;
    while(!st.empty()){
        l_l now=st.top();st.pop();
        for(auto Next:paths[now.first]){
            if(d[Next.first]==INF){
                d[Next.first]=d[now.first]+Next.second;
                st.push({Next.first,d[Next.first]});
            }
        }
    }
    for(int i=0; i<Q; i++){
        cout << d[x[i]]+d[y[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 12400
N,M = map(int,input().split())

H = tuple(map(int,input().split()))

memo = [True]*N

for _ in range(M):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    if H[a] == H[b]:
        memo[a] = False
        memo[b] = False
    else:
        _,k = min((H[a],a),(H[b],b))
        memo[k] = False

print(sum(memo))

Measured memory_bytes: 20168
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
constexpr double inf = 1e18;
struct nagata {
  vector<double> miv, mav;
  nagata() {
    miv.assign(3,  inf);
    mav.assign(3, -inf);
  }
  void insert (int x, int i) {
    i++;
    cmn(miv[i], x);
    cmx(mav[i], x);
  }
  double breadth (double t) {
    return max(0., 
      max({
        mav[0],
        mav[1] + t,
        mav[2] + t * 2
      }) -
      min({
        miv[0],
        miv[1] + t,
        miv[2] + t * 2
      })
    );
  }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  nagata hor, ver;
  for (int i = 0; i < n; i++) {
    int x, y; char d;
    cin >> x >> y >> d;
    hor.insert(x,
      d == 'R' ? 1 : (d == 'L' ? -1 : 0)
    );
    ver.insert(y,
      d == 'U' ? 1 : (d == 'D' ? -1 : 0)
    );
  }
  double ret = 1e18;
  for (int i = 0; i < 400'000'000; i++) {
    double t = (double)i / 2;
    cmn(ret,
      hor.breadth(t) *
      ver.breadth(t)
    );
  }
  cout << setprecision(10) << ret << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

const char newl = '\n';

ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans*=a;a*=a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mod){ll ans=1;do{if(b&1)ans=ans*a%mod;a=a*a%mod;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            mp[a - 1] += 1;
        }
    }

    int cnt = 0;
    rep(i, n) {
        if (mp[i] == 0) {
            cnt++;
        }
    }

    cout << cnt << newl;

    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
long long t1[100005],t2[100005],t3[100005],t4[100005];
int main(){
	char s[100005];
	int i,j,k,l,m,n;
	
	scanf("%s",s);
	t1[0]=t2[0]=t3[0]=0;
	t4[0]=1;
	if(s[0]=='A'){
	t1[0]=1;	} 
	if(s[0]=='?'){t1[0]=1;t4[0]=3;} 
	l=strlen(s);

	for(i=1;i<l;i++){
	t1[i]=t1[i-1];
	t2[i]=t2[i-1];
	t3[i]=t3[i-1];
	t4[i]=t4[i-1];
	if(s[i]=='A')t1[i]+=t4[i-1];
	if(s[i]=='B')t2[i]+=t1[i-1];
	if(s[i]=='C')t3[i]+=t2[i-1];
	if(s[i]=='?'){
	t1[i]=t1[i-1]*3+t4[i]; 
t2[i]=t2[i-1]*3+t1[i-1];
t3[i]=t3[i-1]*3+t2[i-1];	
	t4[i]*=3;
}
		t1[i]%=1000000007;
		t2[i]%=1000000007;
		t3[i]%=1000000007;
		t4[i]%=1000000007;
	}
	printf("%lld",t3[l-1]);
	 return 0;
}

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

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

    int n = s.size() - 1;
    ll ans = 0;
    string num;
    for (int bit = 0; bit < (1 << n); bit++) {
        num = s[0];
        REP(i, 0, n) {
            if (bit & (1 << i)) {
                ans += stoll(num);
                num = "";
            }
            num += s[i + 1];
        }
        ans += stoll(num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
   string str0="";
  for (int i=0;i<w+2;i++){
    str0 = str0 + "#";
  }
  cout << str0 << endl;
  
  string str, STR;
  for (int i=0;i<h;i++){
    cin >> str;
    STR ="#" + str + "#";
    cout << STR << endl;
  }
  
  cout << str0 << endl;
}   

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int a,b;
    while(cin >> a >> b){
        if(a>=13){
            cout << b << endl;
        }else if(a>=6 && a<=12){
            cout << b/2 << endl;
        }else{
            cout << 0 << endl;
        }

    }
    return 0;
}

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


using namespace std;
typedef long long li;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    li n;
    cin >> n;
    vector<li> xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> ys[i];
    }

    li ans = 0;
    for (int b = 0; b < 29; ++b) {
        const li mask = (1LL << (b + 1)) - 1;
        vector<li> subxs(n), subys(n);
        for (int i = 0; i < n; ++i) {
            subxs[i] = xs[i] & mask;
            subys[i] = ys[i] & mask;
        }

        sort(subys.begin(), subys.end());
        const li unit = 1LL << b;
        li bits = 0;
        for (int xp = 0; xp < n; ++xp) {
            bits += (lower_bound(subys.begin(), subys.end(), 2 * unit - subxs[xp]) -
                    lower_bound(subys.begin(), subys.end(), 1 * unit - subxs[xp]));
            bits += (lower_bound(subys.begin(), subys.end(), 4 * unit - subxs[xp]) -
                    lower_bound(subys.begin(), subys.end(), 3 * unit - subxs[xp]));
        }
        ans += (bits & 1) * unit;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6572
n, k = input().split()
N = int(n)
K = int(k)

h_array = []
for i in range(N):
    tree = int(input())
    h_array.append(tree)

h_array.sort()

#最小値を更新していくので、初期値を無限として設定しておく
result = float("inf")
#indexに注意
for i in range(K - 1, N):
    result = min(result, h_array[i] - h_array[i - K + 1])

print(result)

Measured memory_bytes: 7384
N = int(input())

sho, mod = divmod(N , 1.08)

for p in [sho - 1, sho, sho + 1]:
    price = int(int(p) * 1.08)
    if price == N:
        print(int(p))
        exit(0)
    else:
        pass

print(":(")



Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main(){
    int t = 0; //太郎の得点
    int h = 0; //花子の得点
    int n;
    string str1, str2;
    cin >>n;
    for(int i = 0; i<n; i++){
        cin >>str1 >>str2;
        if(str1 == str2){
            t += 1;
            h += 1;
        }else if(str1 > str2){
            t += 3;
        }else if(str1 < str2){
            h += 3;
        }
        
    }cout <<t <<" " <<h <<endl;
    return 0;
}


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

void solve(int len, char *str) {
    int l_b = 0, r_w = 0, i, min = 200100;
    for(i = 0; i < len; ++i) {
        if(str[i] == '.') { ++r_w; }
    }
    if(l_b + r_w < min) { min = l_b + r_w; }
    for(i = 0; i < len; ++i) {
        if(str[i] == '.')       { --r_w; }
        else if(str[i] == '#')  { ++l_b; }
        if(l_b + r_w < min) { min = l_b + r_w; }
    }
    printf("%d\n", min);
}

int main()
{
    int n;
    scanf("%d", &n);
    char *str = (char*)malloc((n+100)*sizeof(char));
    scanf("%s", str);
    solve(n, str);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){

    ll N,iSum,iMax,l;

    iSum = 0;
    iMax = 0;
    string res;

    cin >> N;

    REP(i,N)
    {
        cin >> l;
        iMax = max(iMax,l);
        iSum += l;
    }

    res = "No";
    if(iMax < iSum - iMax)res = "Yes";

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
int main(){
  int w, h, n;cin>>w>>h>>n;
  int xr=w, xl=0;
  int yt=h, yb=0;
  for(int i=0;i<n;i++){
    int x, y, a;cin>>x>>y>>a;
    switch(a){
      case 1: xl=max(xl, x);break;
      case 2: xr=min(xr, x);break;
      case 3: yb=max(yb, y);break;
      case 4: yt=min(yt, y);break;
    }
  }
  if(xl>=xr || yt<=yb){
    cout << 0 << endl;
  }else{
    cout << (xr-xl)*(yt-yb) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <iomanip>
 
int main()
{
    std::array<long double, 1001> table = {0.0};
    for (int i = 1; i < 1001; i++) {
        table[i] = static_cast<long double>(i + 1) / 2;
    }
 
    int n{}, k{};
    std::cin >> n >> k;
    std::vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        std::cin >> nums[i];
    }
 
    long double result{};
    for (int i = 0; i < k; i++) {
        result += table[nums[i]];
    }
    auto tmp = result;
    for (int i = 1; i <= n - k; i++) {
        tmp = tmp - table[nums[i - 1]] + table[nums[i + k - 1]];
        if (tmp > result) {
            result = tmp;
        }
    }
 
    std::cout<<std::fixed<<std::setprecision(10) << result << std::endl;
    
    return 0;
}

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



int lvlp(int n){
	if(n==0)return 1;
	else  return 2*lvlp(n-1)+1;
}
int lvln(int n){
	if(n==0)return 1;
	else  return 2*lvln(n-1)+3;
}

int f(int n,int x){
	if(n==0&&x==1)return 1;
	else if(x==1)return 0;
	else if(x<=lvln(n-1)+1)return f(n-1,x-1);
	else if(x==lvln(n-1)+2)return lvlp(n-1)+1;
	else if(x<=2*lvln(n-1)+2)return lvlp(n-1)+1+f(n-1,x-lvln(n-1)-2);
	else return 2*lvlp(n-1)+1;
}


signed main(){
	int n,x;cin>>n>>x;
	int ret=f(n,x);
	cout<<ret<<endl;



}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#----------
L_list = [int(input().strip()) for _ in range(5)]
k = int(input().strip())
#----------
L_list.sort()

flag=True
for i in range(1,len(L_list) ):
  if (L_list[i] - L_list[0]) > k:
    flag = False

if flag == True:
  print("Yay!")
else:
  print(":(")


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

int main(){
    int n ,m;
    cin >> n >> m ;
    vector<int64_t> a(n+1,-1) ;
    a.at(0) = 1 ;
    a.at(1) = 1 ;

    for (size_t i = 0; i < m; i++)
    {
        int j ;
        cin >> j ;
        a.at(j) = 0 ;
    }
    for (size_t i = 2; i < n+1; i++)
    {
        if (a.at(i) != -1 )
        {
            continue ;
        }
        
        a.at(i) = a.at(i-1) + a.at(i-2)  ;
        a.at(i) = a.at(i) % 1000000007 ;
    }

    /*for (size_t i = 0; i < n; i++)
    {
        cout << a.at(i) << endl ;
    }
    */
    cout << a.at(n) << endl ;
    
    
    
}    

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

const ll mod = 998244353ll;
// const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5],rfact[fact_table + 5];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n, m, k, num, a, b, c, d, e, h, q, ans, sum;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

ll x[500005], y[500005];

string s, t;

void solve() {
    cin >> s >> t;
    n = s.size();
    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(s[i] != t[i])ans ++;
    }
    p(ans);
    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}



Measured memory_bytes: 3796
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main(){
    string x;
    cin >> x;
    int n = x.length();

    if(n == 2){
        if(x[0] == x[1]){
            printf("1 2");
        }
        else {
            printf("-1 -1");
        }
        return 0;
    }
    
    for(int i = 0; i < n-2; i++){
        if(x[i] == x[i + 1] || x[i + 1] == x[i + 2] || x[i + 2] == x[i]){
            printf("%d %d", i+1, i+3);
            return 0;
        }
    }
    printf("-1 -1");
    
    return 0;
}


Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,a,b,c;
int l[10];
int cnt[4],len[4];
int main(){
    cin>>n>>a>>b>>c;
    rep(i,n){
        cin>>l[i];
    }
    int ans=1000100010;
    rep(i,1<<(n*2)){
        cnt[0]=0;cnt[1]=0;cnt[2]=0;cnt[3]=0;
        len[0]=0;len[1]=0;len[2]=0;len[3]=0;
        rep(j,n){
            int id=(i>>(j*2))&3;
            ++cnt[id];
            len[id]+=l[j];
        }
        if(len[1]==0||len[2]==0||len[3]==0) continue;
        int ta=abs(a-len[1])+abs(b-len[2])+abs(c-len[3]);
        FOR(j,1,4) ta+=(cnt[j]-1)*10;
        ans=min(ans,ta);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> H >> W >> N;
	int sy, sx;
	cin >> sy >> sx;
	string s, t;
	cin >> s >> t;
	L = 0;
	R = W + 1;
	if (s.back() == 'L')L++;
	if (s.back() == 'R')R--;
	for (int i = N - 2; i >= 0; i--) {
		if (t[i] == 'R')L--;
		if (t[i] == 'L')R++;
		L = max(L, 0LL);
		R = min(R, W + 1);
		if (s[i] == 'R')R--;
		if (s[i] == 'L')L++;
		if (R - L == 1) {
			cout << "NO\n";
			return 0;
		}
	}
	if (sx <= L || sx >= R) {
		cout << "NO\n";
		return 0;
	}

	L = 0;
	R = H + 1;
	if (s.back() == 'U')L++;
	if (s.back() == 'D')R--;
	for (int i = N - 2; i >= 0; i--) {
		if (t[i] == 'D')L--;
		if (t[i] == 'U')R++;
		L = max(L, 0LL);
		R = min(R, H + 1);
		if (s[i] == 'D')R--;
		if (s[i] == 'U')L++;
		if (R - L == 1) {
			cout << "NO\n";
			return 0;
		}
	}
	if (sy <= L || sy >= R) {
		cout << "NO\n";
		return 0;
	}

	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 920
n, m = map(int,input().split())
h = list(map(int,input().split()))

d = dict()
for i in range(1,n+1):
    d[i] = h[i-1]
    

l_1 = []
l_2 = []
for j in range(1,m+1):
    x, y = map(int,input().split())
    if d[x] > d[y]:
        l_1.append(x)
        l_2.append(y)
        continue
    elif d[x]==d[y]:
        l_2.append(x)
        l_2.append(y)
        continue
    else:
        l_1.append(y)
        l_2.append(x)
        continue

l_1 = set(l_1)
l_2 = set(l_2)
l_3 = l_2.intersection(l_1)

print(len(l_1-l_3) + n - len(l_2|l_1))

Measured memory_bytes: 41708
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b;
	if((a==1&&b==2)||(a==2&&b==1))
		c=3;
	if((a==1&&b==3)||(a==3&&b==1))
		c=2;
	if((a==2&&b==3)||(a==3&&b==2))
		c=1;
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> g(h, vector<int>(w));

  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];

  int i = 0, j = 0;
  int color = 1;
  bool rev = false;
  for (auto v : a) {
    int c = v;
    while (c) {
      g[i][j] = color;
      //printf("[%d][%d] = %d]\n", i, j, color);
      if (rev) --j;
      else ++j;
      if (j == w) {
        rev = true;
        ++i;
        --j;
      } else if (j == -1) {
        rev = false;
        ++i;
        ++j;
      }
      --c;
    }
    ++color;
  }

  for (int p = 0; p < h; p++) {
    for (int q = 0; q < w; q++) {
      cout << g[p][q] << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3696
#include <stdio.h>

int main(void)
{
  int W,H,x,y,r;

  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

  if(((x+r)<=W&&0<(x+r))&&((y+r)<=H&&0<(y+r))){
    puts("Yes");
  }else if(((x+r)>W||0>=(x+r))||((y+r)>H||0>=(y+r))){
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 1848
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(x) cout << "x " << x;

int main()
{
   int arr[3][3];
   for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
         cin >> arr[i][j];
      }
   }
   int n;
   cin >> n;
   while (n--) {
      int x;
      cin >> x;

      for (int i = 0; i < 3; i++) {
         for (int j = 0; j < 3; j++) {
            if (arr[i][j] == x) arr[i][j] = 0;
         }
      }
   }

   if (arr[0][0] == 0 and arr[0][1] == 0 and arr[0][2] == 0) cout << "Yes\n";
   else if (arr[1][0] == 0 and arr[1][1] == 0 and arr[1][2] == 0) cout << "Yes\n";
   else if (arr[2][0] == 0 and arr[2][1] == 0 and arr[2][2] == 0) cout << "Yes\n";
   else if (arr[0][0] == 0 and arr[1][0] == 0 and arr[2][0] == 0) cout << "Yes\n";
   else if (arr[0][1] == 0 and arr[1][1] == 0 and arr[2][1] == 0) cout << "Yes\n";
   else if (arr[0][2] == 0 and arr[1][2] == 0 and arr[2][2] == 0) cout << "Yes\n";
   else if (arr[0][0] == 0 and arr[1][1] == 0 and arr[2][2] == 0) cout << "Yes\n";
   else if (arr[0][2] == 0 and arr[1][1] == 0 and arr[2][0] == 0) cout << "Yes\n";
   else cout << "No\n";



    return 0;
}

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

double P, E, T;

double solve(int K, double R, double L){
	double H = (R + L) / 2.0;
	if( K == 0 ){
		if( fabs(T - H) < E ){
			return 1.0;
		}else{
			return 0.0;
		}
	}
	
	if( R < T - E || T + E < L ){
		return 0.0;
	}else if( T - E <= L && R <= T + E ){
		return 1.0;
	}
	
	if( H <= T ){
		return P * solve(K - 1, H, L) + (1.0 - P) * solve(K - 1, R, H);
	}else{
		return P * solve(K - 1, R, H) + (1.0 - P) * solve(K - 1, H, L);
	}	
}

int main(){
	int K, L, R;
	cin >> K >> L >> R >> P >> E >> T;
	printf("%.6f\n", solve(K, R, L));
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){
    ll N; cin >> N;
    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);
    }

    ll ans = 0;
    for(ll i = 0; i < N; i++){
        for(ll j = i + 1; j < N; j++){
            ans += vec[j] * vec[i];
        }        
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        long R = 0;
        long G = 0;
        long B = 0;
        long ans;
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == 'R') {
                R++;
            } else if (S.charAt(i) == 'G') {
                G++;
            } else if (S.charAt(i) == 'B') {
                B++;
            }
        }
        ans = R * B * G;

        long sum = 0;
        for (int i = 0; i < N - 2; i++) {
            for (int j = i + 1; j < N - 1; j++) {
                if (2 * j - i >= N) {
                    continue;
                }
                if (S.charAt(i) != S.charAt(j) && S.charAt(i) != S.charAt(2 * j - i)
                        && S.charAt(j) != S.charAt(2 * j - i)) {
                    sum++;
                }
            }
        }

        System.out.println(ans - sum);
        sc.close();
    }
}


Measured memory_bytes: 37092
/*input
1
3
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
const int N =6e5+5;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int powmod(int base,int exp,int mod)
{
	int res=1LL;
	while(exp>0)
	{
		if(exp&1LL)
			res=(res*base)%mod;
		exp/=2LL;
		base=(base*base)%mod;
	}
	return res%mod;
}
double dp[301][301][301];
int val,n;
double recurr(int total,int ones,int twos,int thres)
{
	if(total==val)
		return 0;
	else if(dp[ones][twos][thres]!=-1.00)
		return dp[ones][twos][thres];
	else
	{
		double temp=0.00;
		if(thres>0)
			temp+=(ld(thres)/ld(n))*(recurr(total+1,ones,twos+1,thres-1));
		if(twos>0)
			temp+=(ld(twos)/ld(n))*(recurr(total+1,ones+1,twos-1,thres));
		if(ones>0)
			temp+=(ld(ones)/ld(n))*(recurr(total+1,ones-1,twos,thres));
		temp+=1.00;
		int something=n-ones-twos-thres;
		temp=(ld(n)/ld(n-something))*temp;
		dp[ones][twos][thres]=temp;
		return temp;

	}
}
int main()
{
	cin>>n;
	int a=0,b=0,c=0;
	int x;
	rep(i,n)
	{
		cin>>x;
		val+=x;
		if(x==1)
			a++;
		else if(x==2)
			b++;
		else
			c++;
	}
	rep(i,301)
	{
		rep(j,301)
		{
			rep(k,301)
			{
				dp[i][j][k]=-1.00;
			}
		}
	}
	double ans=recurr(0,a,b,c);
	cout<<fixed<<setprecision(12);
	cout<<ans<<endl;


}

Measured memory_bytes: 213376
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;
ll mo=998244353;

ll ret;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	ll ret=1;
	ll V[3]={},D[3]={};
	
	queue<int> Q;
	FORR(c,S) {
		if(c=='R') i=0;
		if(c=='G') i=1;
		if(c=='B') i=2;
		
		// close
		x=(i+1)%3;
		y=(i+2)%3;
		if(D[i]) {
			(ret*=D[i])%=mo;
			D[i]--;
		}
		else if(V[x]) {
			(ret*=V[x])%=mo;
			D[y]++;
			V[x]--;
		}
		else if(V[y]) {
			(ret*=V[y])%=mo;
			D[x]++;
			V[y]--;
		}
		else {
			V[i]++;
		}
		//cout<<c<<" "<<V[0]<<" "<<V[1]<<" "<<V[2]<<" "<<D[0]<<" "<<D[1]<<" "<<D[2]<<" "<<ret<<endl;
	}
	
	FOR(i,N) ret=ret*(i+1)%mo;
	
	
	
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
using namespace std;
int main()
{
	long long N, W;
	cin >> N >> W;
	vector<pair<long long,long long>> coins(N);
	vector<long long> dp(W+1);
	for (long long i = 0; i < N; i++) {
		long long w, v;
		cin >> w >> v;
		coins[i] = { w,v };
		
	}
	long long mx = 0;
	for (auto p : coins) {
		long long weight = p.first;
		long long value = p.second;
		for (long long i = W; i >=1 ; i--) {
			if (i >= weight) dp[i] = max(dp[i - weight] + value, dp[i]);
			mx = max(mx, dp[i]);
		}

		
	}
	cout << mx;

}


Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int maxn=5e4+10;
ll gcd(ll a, ll b){return (b==0)?a:gcd(b, a%b);}
bool isPrime(int n) {
    if(n<=3){
        return n>1;
    }
    if(n%6!=1&&n%6!=5){
        return false;
    }
    int sqr=sqrt(n);
    for(int i=5;i<=sqr;i+=6){
        if(n%i==0||n%(i+2)==0){
            return false;
        }
    }
    return true;
}
int dis[4][2]={0,1,0,-1,1,0,-1,0};
int main()
{
	ll h,w;
	cin>>h>>w;
	if(h==1||w==1)
	cout<<1<<endl;
	else
	{
		ll sum=h*w;
	if(sum%2==0)
	cout<<sum/2;
	else
	cout<<sum/2+1;
	cout<<endl;
	}
} 

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    long K = lread();
    long n = N - K;
    long X = lread();
    long a = (n < 0) ? N * X : K * X;
    long b = (n < 0) ? 0 : n * lread();
    writeln(a + b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv)
{
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N - 2; ++i) {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++)
    cin >> s.at(i);
  
  bool flag = true;
  for(int i=1; i<n; i++) {
    for(int j=0; j<i; j++) {
      if(s.at(j) == s.at(i)) {
        flag = false;
        break;
      }
    }
    if(s.at(i).at(0) != s.at(i-1).at(s.at(i-1).size()-1)) 
      flag = false;
    if(flag == false)
      break;
  }
  
  if(flag == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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


def solve(tmp):
    ans = 0
    for i in range(1, n):
        if tmp * (tmp + a[i]) < 0:
            tmp += a[i]
        else:
            ans += abs(tmp + a[i]) + 1
            if tmp < 0:
                tmp = 1
            else:
                tmp = - 1
    return ans

minus = min(a[0], -1)
plus = max(a[0], 1)
ans = min(solve(plus) + abs(a[0] - plus), solve(minus) + abs(a[0] - minus))
print(ans)


Measured memory_bytes: 64112
N,X = map(int,input().split())
A = list(map(int,input().split()))

Ans = 0
# 初項が超過している場合を考慮
d = max(0,A[0]-X)
A[0] -= d
Ans += d
# 第2項以降は貪欲に処理
for i in range(1,N):
    d = max(0,A[i]+A[i-1]-X)
    A[i] -= d
    Ans += d

print(Ans)

Measured memory_bytes: 14540
N = int(input())
s = set()
word = input()
s.add(word)
last = word[-1]
for i in range(N-1):
  word = input()
  if word in s or word[0] != last:
    print('No')
    quit()
  else:
    s.add(word)
    last = word[-1]

print('Yes')

Measured memory_bytes: 3060
A = list(input())
B = list(input())
dicB = {}
dicA = {}
for i in range(len(A)):
    dicB.setdefault(B[i], A[i])
    dicA.setdefault(A[i], B[i])
    if dicB.get(B[i]) != A[i] or dicA.get(A[i]) != B[i]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 70476
#include <algorithm>
#include <iostream>
#include <vector>
 
typedef unsigned uint;
 
bool is_exist_bin_search(uint v, std::vector<uint> &s){
  uint min = 0, max = s.size();
  while(min < max){
    uint mid = (min + max) / 2;
    uint v_mid = s[mid];
    if(v_mid == v) return true;
 
    if(v_mid >= v) max = mid;
    else min = mid+1;
  }
  return false;
}
 
unsigned count(std::vector<uint> &s, std::vector<uint> &t){
  uint n = 0;
  for(uint i = 0; i < t.size(); i++){
    if(is_exist_bin_search(t[i],s)) n++;
  }
  return n;
}
 
int main(){
  std::ios_base::sync_with_stdio(false);
 
  uint n;
  std::cin >> n;
  std::vector<uint> s(n,0);
  for(uint i = 0; i < n; i++){
    std::cin >> s[i];
  }
  s.erase(std::unique(s.begin(),s.end()),s.end());
 
  uint q;
  std::cin >> q;
  std::vector<uint> t(q,0);
  for(uint i = 0; i < q; i++){
    std::cin >> t[i];
  }
 
  std::cout << count(s,t) << '\n';
}

Measured memory_bytes: 1580
#include <iostream>
#include <cstdint>

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b, c;
  cin >> a >> b >> c;
  if (c >= a && c <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

const int MAXN = 200005;

int n, a[MAXN];
int b[MAXN];

bool judge(int mid)
{
	for (int i = 1; i <= 2*n-1; i++) 
		b[i] = (a[i]>=mid);
	int Lpos = 1, Rpos = 2*n-1;
	for (int i = n; i > 1; i--)
		if (b[i] == b[i-1]) {
			Lpos = i;
			break;
		}
	for (int i = n; i < 2*n-1; i++)
		if (b[i] == b[i+1]) {
			Rpos = i;
			break;
		}
	// cerr << mid << " " << Lpos << " " << Rpos << endl;
	if (n-Lpos < Rpos-n) return b[Lpos];
	else return b[Rpos];
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= 2*n-1; i++) scanf("%d", &a[i]);
	int L = 1, R = 2*n-1, mid;
	while (L <= R) {
		mid = (L+R)>>1;
		if (judge(mid)) L = mid+1;
		else R = mid-1;
	}
	printf("%d\n", L-1);
	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a,b; cin >> a >> b;
  cout << (a*b==15 ? '*' : a+b==15 ? '+' : 'x') << endl; 
}





Measured memory_bytes: 3600
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
AB = []

for i in range(M):
    ab = list(map(int, input().split()))
    AB.append(ab)

l = [1 for i in range(N)]
for ab in AB:
    a = ab[0]-1
    b = ab[1]-1

    if H_list[a] <= H_list[b]:
        l[a] = 0

    if H_list[b] <= H_list[a]:
        l[b] = 0

print(sum(l))


Measured memory_bytes: 32028
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define For(i,n) for(ll i = 0 ; i < n ; i++)

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll n,a,b;
  cin>>n>>a>>b;
  ll tot = a+b;
  ll rep = n/tot;
  ll ad = min(a,n-rep*tot);
  cout<<rep*a + ad;
}

Measured memory_bytes: 256
log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin
  .split(" ")
  .map(Number);

  var X = lines[0]
  var A = lines[1]

  if(X < A) {
    log(0)
  } else {
    log(10)
  }


Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    int n;
    cin >> n;
    vector<string> names(n);
    for(int i = 0; i < n; i++){
        cin >> names[i];
    }
    vector<int> march(5,0);
    for(int i = 0; i < n; i++){
        if(names[i][0] == 'M')
        march[0]++;
        else if(names[i][0] == 'A')
        march[1]++;
        else if(names[i][0] == 'R')
        march[2]++;
        else if(names[i][0] == 'C')
        march[3]++;
        else if(names[i][0] == 'H')
        march[4]++;
    }
    int ans = 0;

    for(int i = 0; i < 3; i++){
        for(int j = i + 1; j < 4; j++){
            for(int k = j + 1; k < 5; k++){
                if(march[i] + march[j] + march[k] >= 3)
                ans += (march[i] * march[j] * march[k]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6144
import java.util.Scanner;
public class Main {
	public static void main( String[] args ) {
		Scanner sc = new Scanner( System.in ) ;
		int i = 1;
		int x = sc.nextInt() ;
		while( x != 0 ) {
			System.out.println( "Case " + i + ": " + x ) ;
			i++;
			x = sc.nextInt() ;
		}
	}
}

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

void solve(){

	int n ;
	cin>>n ;

	vector<int> x(n) ; 
	vector<int> y(n) ;

	rep(i,n){
		cin>>x[i] ;
	}

	rep(i,n){
		cin>>y[i] ;
	}

	vector<int> temp=x ;

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

	int f1=0 ;
	int f2=0 ;
 	
 	int ans1=0 ;
 	int ans2=0 ;

 	do{
 		f1++ ;
 		f2++ ;
 		if(temp==x){
 			ans1=f1 ;
 		}

 		if(temp==y){
 			ans2=f2 ;
 		}
 	}while(next_permutation(temp.begin(),temp.end())) ;

 	cout<<abs(ans1-ans2) ;

}


int main(){


		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3604