akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
	int x1, y1, x2, y2;

	scanf("%d  %d %d %d", &x1, &y1, &x2, &y2);
	int Xvecter = x2 - x1;
	int Yvecter = y2 - y1;
	printf("%d %d %d %d", x2 - Yvecter, y2 + Xvecter, x1 - Yvecter, y1 + Xvecter);

	return 0;
}

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

int main()
{
	long long n, i, x, y;
	scanf("%lld", &n);
	for(i=(int)sqrt(n); i>=1; i--)
	{
		if(n%i==0)
		{
			x=i;
			y=n/i;
			printf("%lld", x+y-2);
			return 0;
		}
	}
}

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

int main(void){

  long long a,b;

  cin >> a >> b;
  
  if((a + b)%2 != 0)
    cout << "IMPOSSIBLE" << endl;

  else
    cout << (a + b)/2 << endl;
  

  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : ITP_1_4_B.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	double r;
	cin >> r;
	printf("%lf %lf",r*r*M_PI,r*2.0*M_PI);
	return 0;
}

Measured memory_bytes: 3272
from math import sin, cos, atan2

def sgn(x, eps=1e-10):
    if x < -eps: return -1
    if -eps <= x <= eps: return 0
    if eps < x: return 1

class Vector():
    def __init__(self, x=0.0, y=0.0):
        self.x = x
        self.y = y

    def arg(self):
        return atan2(self.y, self.x)

    def norm(self):
        return (self.x**2 + self.y**2)**0.5

    def rotate(self, t):
        nx = self.x * cos(t) - self.y * sin(t)
        ny = self.x * sin(t) + self.y * cos(t)
        return Vector(nx, ny)

    def counter(self):
        nx = -self.x
        ny = -self.y
        return Vector(nx, ny)

    def times(self, k):
        nx = self.x * k
        ny = self.y * k
        return Vector(nx, ny)

    def unit(self):
        norm = self.norm()
        nx = self.x / norm
        ny = self.y / norm
        return Vector(nx, ny)

    def normal(self):
        norm = self.norm()
        nx = -self.y / norm
        ny = self.x / norm
        return Vector(nx, ny)

    def add(self, other): #Vector, Vector -> Vector
        nx = self.x + other.x
        ny = self.y + other.y
        return Vector(nx, ny)

    def sub(self, other):
        nx = self.x - other.x
        ny = self.y - other.y
        return Vector(nx, ny)

    def dot(self, other): #Vector, Vector -> int
        return self.x * other.x + self.y * other.y

    def cross(self, other): #Vector, Vector -> int
        return self.x * other.y - self.y * other.x

    def __str__(self):
        return str(self.x) + ' ' + str(self.y)

class Line():
    def __init__(self, bgn=Vector(), end=Vector()):
        self.bgn = bgn
        self.end = end

    def build(self, a, b, c): #ax + by == 1
        assert sgn(a) != 0 or sgn(b) != 0
        if sgn(b) == 0:
            self.bgn = Vector(-c / a, 0.0)
            self.end = Vector(-c / a, 1.0)
        else:
            self.v = Vector(0, -c / b)
            self.u = Vector(1.0, -(a + b) / b)

    def vec(self):
        return self.end.sub(self.bgn)

    def projection(self, point):
        v = self.vec()
        u = point.sub(self.bgn)
        k = v.dot(u) / v.norm()
        h = v.unit().times(k)
        return self.bgn.add(h)

xp1, yp1, xp2, yp2 = map(int, input().split())
q = int(input())

p1 = Vector(xp1, yp1)
p2 = Vector(xp2, yp2)
l = Line(p1, p2)

for _ in range(q):
    x, y = map(int, input().split())
    p = Vector(x, y)
    proj = l.projection(p)
    print(proj)


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

main() {
  int N, x, xmax;
  string S;
  cin >> N >> S;
  xmax = x = 0;
  REP(i, N) {
    if (S[i] == 'I') {
      x++;
    } else {
      x--;
    }
    if (xmax < x) xmax = x;
  }
  cout << xmax << endl;
}


Measured memory_bytes: 256
n = int(input())
if n ==1:
    print( 1)
    exit()
cost = 0
points = []
for i in range(n):
    points.append(list(map(int, input().split())))

points.sort()
dictpq = {}
for i in range(n):
    for j in range(i+1,n):
        p = points[i][0] - points[j][0]
        q = points[i][1] - points[j][1]
        if (p,q) in dictpq:
            dictpq[(p,q)] +=1
        else:
            dictpq[(p,q)] =1
print(n-max(dictpq.values()))

Measured memory_bytes: 3188
#include <cstdio>
#include <vector>

using namespace std;

#define FOR(it,c) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)

int main() {
	vector<int> v;
	for(int i = 1; i <= 9; i++) {
		v.push_back(i);
	}
	
	FOR(it1, v) {
		FOR(it2, v) {
			printf("%dx%d=%d\n", *it1, *it2, *it1 * *it2);
		}
	}
}

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

using namespace std;

void load(void);
void calc(void);
void output(void);

int A, B, C, D, Atime, Btime;

int main(){
	load();
	calc();
	output();
	return 0;
}

void load(void){
	cin >> A >> B >> C >> D;
}

void calc(void){
	Atime = C / B;
	if(C % B != 0){
		Atime++;
	}
	Btime = A / D;
	if(A % D != 0){
		Btime++;
	}
}

void output(void){
	if(Atime <= Btime){
		cout << "Yes";
	}else{
		cout << "No";
	}
}

Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <unordered_map>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define ll long long
#define INF ((1<<30)-1)
#define NEG (-1)
#define MOD 1000000007
#define MAXN 100100
#define EPS 1e-9
#define INFLL 1e18
using namespace std;
FILE *in,*out;

int N,M,K;
vector<int> res(200,0);
ll powx[200];
ll psum[200];

int read()
{
    ll i,j,k;
    fscanf(in,"%d",&N);
    if(N==0)
    {
        printf("0\n");
        return 0;
    }
    for(i=0,j=1,k=1;i<64;i++,j<<=1)
    {
        // printf("%lld %lld\n",i,k);
        powx[i] = k;
        k *= -2;
    }
    for(i=0,j=1;i<64;i++,j*=2)
    {
        if(i>1) psum[i] = psum[i-2] + powx[i];
        else psum[i] = powx[i];
    }
    while(N)
    {
        i=0;
        while(1)
        {
            ll minx = min(psum[i],powx[i] + psum[i-1]);
            ll maxx = max(psum[i],powx[i] + psum[i-1]);
            if(minx <= N && N <= maxx)
                break;
            i++;
        }
        res[i] = 1;
        N -= powx[i];
    }
    for(i=180;i>=0;i--)
    {
        if(res[i])
            break;
    }
    for(;i>=0;i--)
    {
        cout << res[i];
    }
    cout << endl;
    return 0;
}

int main()
{
    // in = fopen("A.in","r");
    // out  = fopen("A.out","w");
    in = stdin;
    out = stdout;
    read();
    return 0;
}
//////////// Local Snippets
// forx
// fory
// vectorx
// pairx
// sizex

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define INF 100100100
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;


int main(){
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  rep(i,m){
  	cin >> l[i] >> r[i];
  }
  int left = l[0];
  int right = r[0];
  rep(i,m){
  	left = max(left, l[i]);
  	right = min(right, r[i]);
  }
  int ans = right - left + 1;
  if(ans < 0) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int x, n;
	cin >> x >> n;

	set<int> P;
	for (int i = 0; i < n; ++i)
	{
		int p;
		cin >> p;
		P.insert(p);
	}

	int ans = -100;
	for (int i = -1; i <= 101; ++i)
	{
		if (P.count(i))
			continue ;
		if (abs(x - i) < abs(x - ans))
			ans = i;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,y;
    cin>>n;
    int a[n],b[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int j=0; j<n; j++){
        y=a[j];
        b[y-1]=j+1;
    }
    for(int l=0; l<n; l++){
        cout<<b[l]<<"\n";
    }
    return 0;

}



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


int main() {
	int x,y,z,a,b;
	a=0;
	b=0;
	cin>>x;
	vector<int> vec(x);
	for (int i=0;i<x;i++){
		cin>>vec.at(i);
	}
	//cout<<vec.at(0)<<vec.at(1)<<vec.at(2)<<endl;
	sort(vec.begin(),vec.end()); 
	reverse(vec.begin(),vec.end()); 
	
	for(int i=0;i<x;i++){
		if(i%2==0){
			a+=vec.at(i);
		}
		else{
			b+=vec.at(i);
		}
	}
	cout<<a-b<<endl;

}


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

struct dat {
  int d;
  vector<int> c;
  vector<vector<int>> s;
};

int calc(const dat &a, const vector<int> &last, int day, int t) {
  int v = 0;
  v += a.s.at(day - 1).at(t);
  for (int i = 0; i < 26; i++) {
    if (i == t) continue;
    v -= a.c.at(i) * (day - last.at(i));
  }
  return v;
}

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  dat a = {d, c, s};
  
  int w = 200;
  vector<vector<int>> last(w, vector<int>(26)), ans(w);
  vector<int> score(w);
  for (int i = 0; i < d; i++) {
    vector<tuple<int, int, int>> idx;
    for (int j = 0; j < w; j++) {
      vector<int> best(w, -4e4), best_t(w);
      for (int t = 0; t < 26; t++) {
        int v = calc(a, last.at(j), i + 1, t);
        if (v > best.at(w - 1)) {
          best.at(w - 1) = v;
          best_t.at(w - 1) = t;
        }
        for (int k = w - 1; k > 0; k--) {
          if (best.at(k - 1) < best.at(k)) {
            swap(best.at(k - 1), best.at(k));
            swap(best_t.at(k - 1), best_t.at(k));
          }
        }
      }
      for (int k = 0; k < w; k++) {
        idx.emplace_back(score.at(j) + best.at(k), j, best_t.at(k));
      }
    }
    sort(idx.rbegin(), idx.rend());
    vector<vector<int>> newlast(w, vector<int>(26)), newans(w);
    for (int j = 0; j < w; j++) {
      int k = get<1>(idx.at(j)), t = get<2>(idx.at(j));
      score.at(j) = get<0>(idx.at(j));
      newans.at(j) = ans.at(k);
      newlast.at(j) = last.at(k);
      newans.at(j).push_back(t);
      newlast.at(j).at(t) = i + 1;
    }
    ans = newans;
    last = newlast;
  }
  for (int i = 0; i < d; i++) {
    cout << ans.at(0).at(i) + 1 << endl;
  }
}


Measured memory_bytes: 5648
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
from scipy.spatial.distance import chebyshev
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
ans = 0
plus = []
minus = []
for i in range(N):
    li = xy[i]
    x = li[0]
    y = li[1]
    plus.append(x+y)
    minus.append(x-y)
ans = 0
ans = max(max(plus)-min(plus),max(minus)-min(minus))
print(ans)


            








Measured memory_bytes: 96924
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */
import java.util.*;
import java.io.*;

public class Main {
    public static long sum(long[] array){
        long ans = 0;
        for(long e:array) ans+=e;
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble();
        double s = (a+b+c)/2;
        double area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
        System.out.println(Math.round(area));



    }
}


Measured memory_bytes: 24276
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define INF 1000000000000000000
//static const long double pi = 3.1415926535897932;

using namespace std;
using ld = long double;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ld atack(ld hit) {
	if (hit > 1) {
		return 2 * atack(floor(hit/2)) + 1;
	} else {
		return 1;
	}
}

int main() {
	ld h;
	cin >> h;
	cout << setprecision(16) << atack(h) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    long C = scanner.nextLong();
    long[] h = new long[N];
    for (int i = 0; i < N; i++) h[i] = scanner.nextInt();

    long[] dp = new long[N + 1];
    MyDeque<Line> deque = new MyDeque<>();

    for (int i = 1; i <= N; i++) {
      long hi = h[i - 1];
      while (deque.size() > 1 && deque.getLast(1).y(hi) < deque.getLast().y(hi)) {
        deque.removeLast();
      }
      if (!deque.isEmpty()) dp[i] = deque.getLast().y(hi) + hi * hi + C;
      Line line = new Line(-2 * hi, hi * hi + dp[i]);
      while (deque.size() > 1
          && (deque.getFirst().a - deque.getFirst(1).a) * (line.b - deque.getFirst().b)
          > (line.a - deque.getFirst().a) * (deque.getFirst().b - deque.getFirst(1).b)) {
        deque.removeFirst();
      }
      deque.addFirst(line);
    }

    System.out.println(dp[N]);
  }

  private static class MyDeque<T> {
    private Deque<T> deque = new LinkedList<>();

    public void addFirst(T t) {
      deque.addFirst(t);
    }

    public void addLast(T t) {
      deque.addLast(t);
    }

    public T removeFirst() {
      return deque.removeFirst();
    }

    public T removeLast() {
      return deque.removeLast();
    }

    public T getFirst() {
      return deque.getFirst();
    }

    public T getLast() {
      return deque.getLast();
    }

    public T getFirst(int i) {
      Iterator<T> iter = deque.iterator();
      T ret = null;
      while (i >= 0) {
        if (!iter.hasNext()) throw new NoSuchElementException("No element at " + i + ", size=" + deque.size());
        ret = iter.next();
        i--;
      }
      return ret;
    }

    public T getLast(int i) {
      Iterator<T> iter = deque.descendingIterator();
      T ret = null;
      while (i >= 0) {
        if (!iter.hasNext()) throw new NoSuchElementException("No element at " + i + ", size=" + deque.size());
        ret = iter.next();
        i--;
      }
      return ret;
    }

    public int size() {
      return deque.size();
    }

    public boolean isEmpty() {
      return deque.isEmpty();
    }
  }

  private static class Line {
    public final long a;
    public final long b;

    private Line(long a, long b) {
      this.a = a;
      this.b = b;
    }

    public long y(long x) {
      return x * a + b;
    }
  }
}


Measured memory_bytes: 96424
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n, _ := strconv.Atoi(input())
	a := make([]int, 3*n)
	for i := 0; i < 3*n; i++ {
		a[i], _ = strconv.Atoi(input())
	}
	sort.Ints(a)
	a = a[n:]

	ans := 0
	for i := 0; i < n; i++ {
		ans += a[i*2]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long int;
const ll MOD = 1000000007;

ll calc(vector<int> &memo, int n){
    if(memo[n] != -1) return memo[n];
    else{
        ll ans = 1;
        for(int i = 3; n-i >= 3; i++){
            ans += calc(memo, n-1);
            ans %= MOD;
        }
        return ans;
    }
}

int main(){
    int s;
    cin >> s;
    vector<int> memo(2020, 0);
    for(int i = 3; i <= s; i++) memo[i] = 1;
    for(int i = 3; i <= s; i++){
        for(int j = 3; i-j >= 0; j++){
            memo[i] += memo[i-j];
            memo[i] %= MOD;
        }
    }
    cout << memo[s] << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll d[100005]{0};
    ll s = 0;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        d[a]++;
        s += a;
    }
    int q;
    cin >> q;
    while(q--){
        ll b, c;
        cin >> b >> c;
        s = s - d[b] * b + d[b] * c;
        d[c] += d[b];
        d[b] = 0;
        cout << s << endl;
    }
}


Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;

ll a[100010];
ll rui[100010];
int n;
int main(){
  cin>>n;
  REP(i,n)cin>>a[i];
  rui[0]=a[0];
  for(int i=1;i<n;i++){
    rui[i]+=a[i]+rui[i-1];
  }


  ll temp=0;
  ll ans=0;
  //1こ　正
  for(int i=0;i<n;i++){
    if(i%2==0 && rui[i]+temp==0){
      temp++;
      ans++;
      continue;
    }
    if(i%2==1 && rui[i]+temp==0){
      temp--;
      ans++;
      continue;
    }
    if(i%2==0 && rui[i]+temp<0){
      ans+=abs(1-(rui[i]+temp));
      temp+=1-(rui[i]+temp);
      //cout<<i<<" "<<temp<<endl;

    }

    if(i%2==1 && rui[i]+temp>0){
      ans+=abs(-(1+rui[i]+temp));
      temp+=-(1+rui[i]+temp);
      //cout<<i<<" "<<temp<<endl;
    }
  }

  if(ans<0)ans=INF;

  temp=0;
  ll ans2=0;
  for(int i=0;i<n;i++){
    if(i%2==0 && rui[i]+temp==0){
      temp--;
      ans2++;
      continue;
    }
    if(i%2==1 && rui[i]+temp==0){
      temp++;
      ans2++;
      continue;
    }
    if(i%2==0 && rui[i]+temp>0){
      ans2+=abs(-(1+rui[i]+temp));
      temp+=-(1+rui[i]+temp);
      //cout<<i<<" "<<temp<<endl;
    }

    if(i%2==1 && rui[i]+temp<0){
      ans2+=abs(1-(rui[i]+temp));
      temp+=1-(rui[i]+temp);
      //cout<<i<<" "<<temp<<endl;
    }

  }
  if(ans2<0)ans2=INF;
  cout<<min(ans,ans2)<<endl;

}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long H = sc.nextLong();
		long W = sc.nextLong();
		sc.close();

		if (H == 1 || W == 1) {
			System.out.println(1);
			return;
		}

		long total = H * W;
		// if (total % 2 == 0) {
		// System.out.println(total / 2);
		// } else {
		// System.out.println((int) Math.floor(total / 2) + 1);
		// }
		System.out.println((total + 1) / 2);

	}

}


Measured memory_bytes: 21716
import sys
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    N = int(input())
    probability = list(map(float, input().rstrip().split()))

    # dp[i][j] = i枚目までで表がj枚出る確率
    dp = [[0] * (N+1) for _ in range(N+1)]
    dp[0][0] = 1

    for i, p in enumerate(probability, 1):
        for j in range(i+1):
            if j != 0:
                # 表のパターンと裏のパターンの合計
                dp[i][j] = dp[i-1][j] * (1-p) + dp[i-1][j-1] * p
            else:
                # 裏のパターンのみ
                dp[i][j] = dp[i-1][j] * (1-p)
    print(sum(dp[N][(N+1)//2:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 273032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;
vector<int> vis;


void f(int& x, map<int, int>& mp, bool& pairwise, bool& setwise, int& n) {
	int p = 2;
	while (p <= sqrt(x)) {
		if (x % p == 0) {
			mp[p]++;
			if (mp[p] == n) setwise = false;
			if (mp[p] > 1) pairwise = false;
			while (x % p == 0) {
				x /= p;
			}
		}
		p++;
	}
	if (x != 1) {
		mp[x]++;
		if (mp[x] == n) setwise = false;
		if (mp[x] > 1) pairwise = false;
	}
	return;
}

int main()
{
	int n;
	cin >> n;
	
	map<int, int> mp;
	bool setwise = true;
	bool pairwise = true;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		f(x, mp, pairwise, setwise, n);
	}
	if (pairwise) cout << "pairwise coprime";
	else if (setwise) cout << "setwise coprime";
	else cout << "not coprime";
	
	
	

}



Measured memory_bytes: 7196
W, H, N = map(int, input().split())
upper_right = [W, H]
lower_left = [0, 0]
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        lower_left[0] = max(lower_left[0], x)
    elif a == 2:
        upper_right[0] = min(upper_right[0], x)
    elif a == 3:
        lower_left[1] = max(lower_left[1], y)
    else:
        upper_right[1] = min(upper_right[1], y)
if upper_right[0] <= lower_left[0] or upper_right[1] <= lower_left[1]:
    print(0)
else:
    print((upper_right[0] - lower_left[0]) * (upper_right[1] - lower_left[1]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}
ll N,A,B;
vector<ll> v;
bool sat(ll m){
  ll C = A-B;
  vector<ll> w(N);
  rep(i,N) w[i] = v[i] - m*B;
  rep(i,N){
    if(w[i]<0)continue;
    m -= w[i]/C;
    if(w[i]%C != 0)--m;
  }
  return m>=0;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> A >> B;
  v = vector<ll>(N);
  rep(i,N)cin >> v[i];
  sort(all(v),greater<ll>());
  ll l = 0, r = v[0]/B+1;
  while(r-l>1){
    ll m = (r+l)/2;
    if(sat(m)) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  int A, B, K;
  cin >> A >> B >> K;

  int cnt = 0;
  int ans;
  rrep(i, min(A, B), 1) {
    if (A%i==0 && B%i==0) ++cnt;
    if (cnt == K) {
      ans = i;
      break;
    }
  }

  cout << ans << "\n";
}

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

int main(){
    long long a,b,k,x,y;
    cin>>a>>b>>k;
	x=max((long long)0,a-k);
	y=max(b-(k-(a-x)),(long long)0);
    cout<<x<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i, j,a;
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			a = i * j;
			printf("%dx%d=%d\n", i, j, a);
			}
		}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> H(n);
    vector<bool> good(n, true);
    for(int i=0;i<n;i++){
        cin >> H.at(i);
    }
    for(int i=0;i<m;i++){
        int a, b;
        cin  >> a >> b;
        if(H.at(a-1) < H.at(b-1)){
            good.at(a-1) = false;
            // cout << "a<b" << endl;
        }else if(H.at(a-1) > H.at(b-1)){
            good.at(b-1) = false;
            // cout << "a>b" << endl;
        }else{
            good.at(a-1) = false;
            good.at(b-1) = false;
            // cout << "a=b" << endl;
            
        }
    }
    int amount = 0;
    for(int i=0;i<n;i++){
        if(good.at(i)){
            amount++;
            // cout << i << endl;
        }
    }
    cout << amount << endl;
    
}


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

using namespace std;

const double EPS = 1e-8, PI = acos(-1);

inline bool eq(double a, double b) { return fabs(b - a) < EPS; }

using Point = complex< double >;

istream &operator>>(istream &is, Point &p) {
  double a, b;
  is >> a >> b;
  p = Point(a, b);
  return is;
}


double cross(const Point &a, const Point &b) {
  return real(a) * imag(b) - imag(a) * real(b);
}

double dot(const Point &a, const Point &b) {
  return real(a) * real(b) + imag(a) * imag(b);
}

int ccw(const Point &a, Point b, Point c) {
  b = b - a, c = c - a;
  if(cross(b, c) > EPS) return +1;  // "COUNTER_CLOCKWISE"
  if(cross(b, c) < -EPS) return -1; // "CLOCKWISE"
  if(dot(b, c) < 0) return +2;      // "ONLINE_BACK"
  if(norm(b) < norm(c)) return -2;  // "ONLINE_FRONT"
  return 0;                         // "ON_SEGMENT"
}


int main() {
  Point p1, p2;
  cin >> p1 >> p2;
  int Q;
  cin >> Q;
  while(Q--) {
    Point p3;
    cin >> p3;
    auto t = ccw(p1, p2, p3);
    if(t == 1) puts("COUNTER_CLOCKWISE");
    else if(t == -1) puts("CLOCKWISE");
    else if(t == 2) puts("ONLINE_BACK");
    else if(t == -2) puts("ONLINE_FRONT");
    else puts("ON_SEGMENT");
  }
}



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

connect_1 = {}
connect_n = {}
for i in range(m):
    a, b = list(map(int, input().split()))
    if a == 1:
        connect_1[b] = 1
    if b == n:
        connect_n[a] = 1
# print(connect_1.keys(), connect_n.keys())

ans = 'IMPOSSIBLE'
for k in connect_1.keys():
    if k in connect_n.keys():
        ans = 'POSSIBLE'
print(ans)


Measured memory_bytes: 24072
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val p = new Array[Double](N+1)
  for (i <- 1 to N)
    p(i) = in.next().toDouble


  //
  val dp = Array.ofDim[Double](N+1, N+1)

  dp(0)(0) = 1.0
  for (i <- 1 to N)
    for (k <- 0 to N)
      if(k != 0)
        dp(i)(k) = dp(i-1)(k-1) * p(i) + dp(i-1)(k) * (1.0 - p(i))
      else
        dp(i)(k) = dp(i-1)(k) * (1.0 - p(i))

  println(dp(N).slice(N/2+1, N+1).sum)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 113372
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

struct BIT{
	int size;
	vector<llint> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	llint query(int i){
		i++;
		llint ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, llint x){
		i++;
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};


llint n, Q;
llint a[500005];
llint l[500005], r[500005];
BIT bit(500005);
vector<llint> vec[500005];
llint pos[500005];
llint ans[500005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> Q;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= Q; i++){
		cin >> l[i] >> r[i];
		vec[r[i]].push_back(i);
	}
	
	bit.init();
	bit.add(0, n);
	
	for(int i = 1; i <= n; i++){
		bit.add(pos[a[i]], -1);
		pos[a[i]] = i;
		bit.add(pos[a[i]], 1);
		for(int j = 0; j < vec[i].size(); j++){
			llint id = vec[i][j];
			ans[id] = n - bit.query(l[id]-1);
		}
	}
	
	for(int i = 1; i <= Q; i++) cout << ans[i] << "\n";
	flush(cout);
	
	return 0;
}

Measured memory_bytes: 48904
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
string str[2];
int main()
{
  int n;
  string str1,str2;
  int ans[2];
  cin>>n;
  for(int i = 0;i < n;i++){
    cin>>str[0]>>str[1];
    ans[0]=ans[1]= 0;
    for(int i = 0;i <2;i++){
      for(int j = 0;j < str[i].length();j++){
	if(str[i][j]=='m'){
	  if(str[i][j-1]>='2'&&str[i][j-1]<='9'){
	    ans[i] +=1000*(str[i][j-1]-'0');
	  }else{
	    ans[i] +=1000;
	  }
	}else if(str[i][j]=='c'){
	  if(str[i][j-1]>='2'&&str[i][j-1]<='9'){
	    ans[i] +=100*(str[i][j-1]-'0');
	  }else{
	    ans[i] +=100;
	  }
	}else if(str[i][j]=='x'){
	  if(str[i][j-1]>='2'&&str[i][j-1]<='9'){
	    ans[i] +=10*(str[i][j-1]-'0');
	  }else{
	    ans[i] +=10;
	  }
	}else if(str[i][j]=='i'){
	  if(str[i][j-1]>='2'&&str[i][j-1]<='9'){
	    ans[i] +=1*(str[i][j-1]-'0');
	  }else{
	    ans[i] +=1;
	  }
	}
      }
    }
    int sum = ans[0]+ans[1];
    int k;
    if(sum/1000){
      k = sum/1000;
      if(k==1){
	cout <<"m";
      }else
	cout<<k<<"m";
      sum -=k*1000;
    }
    if(sum/100){
      k =sum/100;
      if(k==1){
	cout <<"c";
      }else
	cout<<k<<"c";
      sum -=k*100;
    }
    if(sum/10){
      k =sum/10;
      if(k==1){
	cout <<"x";
      }else
	cout<<k<<"x";
      sum -=k*10;
    }
    if(sum/1){
      k = sum/1;
      if(k==1){
	cout <<"i";
      }else
	cout<<k<<"i";
      sum -=k*1;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
 
  if (n%1111==0 || n/10%111==0 || (n%1000)%111==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  ll n,k,q;
  cin >> n >> k >> q;
  vll a(n,0);
  rep(i,q){
    ll r;
    cin >> r;
    a[r-1] ++;
  }
  rep(i,n){
    ll s = k-q+a[i];
    if(s>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

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

    ll cntR = 0;
    rep(i,0,N){
        if(a[i] == 'R') cntR++;
    }
    ll cntW = N - cntR;
    
    ll ans = 0;
    rep(i,0,cntR){
        if(a[i] == 'W') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n[2];
        cin >> n[0] >> n[1];
        if(n[0] == 0)
            return 0;

        vector<map<int, int> > d(2);
        for(int i=0; i<2; ++i){
            vector<int> a(n[i]);
            for(int j=0; j<n[i]; ++j)
                cin >> a[j];

            for(int j=0; j<n[i]; ++j){
                int sum = 0;
                for(int k=j; k<n[i]; ++k){
                    sum += a[k];
                    ++ d[i][sum];
                }
            }
        }
        
        int ret = 0;
        map<int, int>::iterator it1 = d[0].begin();
        map<int, int>::iterator it2 = d[1].begin();
        while(it1 != d[0].end() && it2 != d[1].end()){
            if(it1->first == it2->first)
                ret += it1->second * it2->second;
            if(it1->first < it2->first)
                ++ it1;
            else
                ++ it2;
        }

        cout << ret << endl;
    }
}

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    sort(all(l));
    int cnt=0;
    if(n<3){
        cout << 0 << "\n";
    }else{
    fr(a,0,n){
        fr(b,a+1,n){
            fr(c,b+1,n){
                if(l[a]==l[b] || l[b]==l[c]) continue;
                if (l[a]+l[b]>l[c]) ++cnt;
            }
        }
    }
    cout << cnt << "\n";
    }
}   



Measured memory_bytes: 3644
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a=0,b=0,c=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b&&b<c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string s;
  cin >> s;
  s += 'T';
  int x, y;
  cin >> x >> y;
  bool dir_is_x = true;

  int W = 8000 * 2 + 100;
  int pos0 = W / 2;
  vector<vector<bool>> dpx(1, vector<bool>(W, false));
  vector<vector<bool>> dpy(1, vector<bool>(W, false));
  dpx[0][pos0] = true;
  dpy[0][pos0] = true;
  int dist = 0;
  rep(i, s.size())
  {
    if (s[i] == 'F')
      dist++;
    else
    {
      if (dir_is_x)
      {
        dpx.push_back(vector<bool>(W, false));
        if (dpx.size() == 2)
        {
          dpx[1][pos0 + dist] = true;
        }
        else
        {
          rep(i, W)
          {
            if (dpx[dpx.size() - 2][i])
            {
              dpx[dpx.size() - 1][i + dist] = true;
              dpx[dpx.size() - 1][i - dist] = true;
            }
          }
        }
      }
      else
      {
        dpy.push_back(vector<bool>(W, false));
        rep(i, W)
        {
          if (dpy[dpy.size() - 2][i])
          {
            dpy[dpy.size() - 1][i + dist] = true;
            dpy[dpy.size() - 1][i - dist] = true;
          }
        }
      }

      dist = 0;
      dir_is_x = !dir_is_x;
    }
  }
  printYesNo(dpx.back()[pos0 + x] && dpy.back()[pos0 + y]);
  return 0;
}

Measured memory_bytes: 16256
#include <stdio.h>
int main(){
    int N, i;
    
    scanf("%11d", &N);
    long long cnt = 0;
    
    for(i = 1; i <= N; i++){
        if((i%3 == 0 && i%5 == 0) || i%3 == 0 || i%5 == 0){
        } else {
            cnt = cnt + i;
        }
    }   

    printf("%lld", cnt);
    
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

    const int MOD = 1000 * 1000 * 1000 + 7;

int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); }

const int N = 1e6+7;
int f[N], inv[N];
void prec() {
    f[0] = 1;
    for (int i = 1; i < N; ++i)
        f[i] = mod(f[i - 1] * i);
    inv[N - 1] = fp(f[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; --i)
        inv[i] = mod(inv[i + 1] * (i + 1));
}
int C(int n, int k) {
    return mod(f[n] * mod(inv[k] * inv[n - k]));
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, m;
    cin >> n >> m;

    prec();
    
    int ans = 0;
    for (int bad = 0; bad <= n; ++bad) {
        int ex = mod(mod(C(n,bad)*C(m,bad))*f[bad]);

        int add = mod(C(m-bad,n-bad)*f[n-bad]);
        add = mod(add*add);

        if (bad&1)
            ans = mod(ans - ex * add);
        else
            ans = mod(ans + ex * add);
        /*
        cout << ex << ' ' << add << endl;
        cout << bad << " : " << mod(ex * add) << endl;
        */
    }   
    cout << ans << endl;
}

Measured memory_bytes: 19276
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

int main(){
    string S;
    cin >> S;
    cout << S.substr(0, 5) << " " << S.substr(6, 7) << " " << S.substr(14,5) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    string s;
    cin >> s;
    int o = 0, x = 0;
    rep(i, s.size()) {
        if (s[i] == 'o') {
            o++;
        } else {
            x++;
        }
    }

    o += 15 - s.size();

    if (o >= 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int maxStep = 0;
  int prev;
  cin >> prev;
  int step = 0;
  for(int i=1;i<n;i++){
    int tmp;
    cin >> tmp;
    if (tmp <= prev){
      step++;
    }else{
      maxStep = maxStep < step ? step:maxStep;
      step = 0;
    }
    prev = tmp;
  }
  maxStep = maxStep < step ? step:maxStep;
  cout << maxStep << endl;
  
  return 0;
}

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

#define ll                                       long long
#define eb                                     emplace_back
#define pii                                     pair<int,int>
#define pll                                      pair<ll,ll>
#define mp                                     map<int,int>
#define _fastio                              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define DB(x)                                cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define Pi                                      acos(-1.0)
#define open                                  freopen("input.txt","r",stdin)         //opening input file
#define close                                  freopen ("output.txt","w",stdout)     //opening output file
#define fori(i,n)                              for(int i=1;i<=n;++i)
#define forn(i,n)                             for(int i=0;i<n;++i)
#define sz(x)                                  int(x.size())
#define error(x)                              cout<<#x<<" "<<x<<endl
#define sorted(v)                            sort(v.begin(),v.end())
int main()
{
    _fastio;
    //open;
    //close;
    int a,b;
    cin>>a>>b;
    a=a-1;
    b=b-1;
    if(b%a==0)
        cout<<b/a;
    else
        cout<<(b/a)+1;
    cout<<endl;
    return 0;
}

/// DO PEN AND PAPERWORK AFTER READING QUESTIONS CAREFULLY
/// Be confident to Solve if others can do.***
/// Common sense: do something instead of nothing
/// Even a single second counts...
/// be super cool, super patient and super focused




Measured memory_bytes: 256
def oper(n):
    res = 100001
    sn = [i for i in range(0, 100001)]
    for i in range(1, 7):
        for j in range(1, 100001):
            sn[j] = min(sn[j], j // (6 ** i) + sn[j % (6 ** i)])

    nn = [i for i in range(0, 100001)]
    for i in range(1, 6):
        for j in range(1, 100001):
            nn[j] = min(nn[j], j // (9 ** i) + nn[j % (9 ** i)])

    for i in range(n + 1):
        res = min(res, sn[i] + nn[n - i])

    return res


if __name__ == "__main__":
    n = input()
    print oper(n)


Measured memory_bytes: 11772
package main

import "fmt"

type Interface interface {
	Push(x interface{})
	Pop() interface{}
}

type pair struct {
	pos  int
	area int
}

type stackPair []pair

func (s *stackPair) Push(x interface{}) {
	item := x.(pair)
	*s = append(*s, item)
}

func (s *stackPair) Pop() interface{} {
	old := *s
	n := len(old)
	item := old[n-1]
	*s = old[0 : n-1]
	return item
}

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	st1 := make(stackPair, 0, 128)
	st2 := make(stackPair, 0, 128)
	for i, c := range s {
		if c == 0x5c {
			st1.Push(pair{i, 0})
		} else if c == 0x2f && len(st1) > 0 {
			left := st1.Pop().(pair).pos
			a := i - left
			ans += a

			a2 := a
			for len(st2) > 0 {
				top := st2.Pop().(pair)
				if left >= top.pos {
					st2.Push(top)
					break
				}
				a2 += top.area
			}
			st2.Push(pair{left, a2})
		}
	}
	fmt.Println(ans)
	fmt.Printf("%d", len(st2))
	for _, e := range st2 {
		fmt.Printf(" %d", e.area)
	}
	fmt.Println()
}



Measured memory_bytes: 3016
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<string.h>
#include<algorithm>
#include<cctype>
#include<map>
#include<set>
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b){
	return a%b==0?b:gcd(b,a%b);
}
int main()
{
	ll a,b;
	scanf("%lld%lld",&a,&b);
	ll u=a*b/gcd(a,b);
	printf("%lld\n",u);
}

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

int main()
{
  char s[200];
  int i;
  scanf("%s", &s);
  for(i = 0; i < strlen(s); ++i)
    s[i] = 'x';
  s[i] = '\0';
  printf("%s\n", s);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
struct card{
	char type;
	int rank;
	int flag;//1--given, 0---no given
} A[52];
char FindType(int i)
{
	switch (i){
		case 0:return 'S';
		case 1:return 'H';
		case 2:return  'C';
		case 3:return 'D';
		default :cout<<"Input Error";
	}
}

int TypeToNum(char type)
{
	switch (type){
		case 'S':return 0;
		case 'H':return 1;
		case 'C':return 2 ;
		case 'D':return 3;
		default :cout<<"Input Error";
				 return -1;
	}	
}

int FindPos(char type,int rank)
{
	return TypeToNum(type)*13+rank-1;
}
int main()
{
	int k,n;
	int pos;
	int rank;
	char type;
	k=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
			A[k].flag=0;
			A[k].rank=j+1;
			A[k].type=FindType(i);
			k++;
		}
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>type>>rank;
		pos=FindPos(type,rank);
		A[pos].flag=1;
	}
	for(int i=0;i<52;i++){
		if (A[i].flag==0)
			cout<<A[i].type<<" "<<A[i].rank<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
package main

import (
	"fmt"
	"math"
)

func minArray(arr []int, nCity int) int {
	var minCapa = 10000000000000000.0
	for i := 0; i < nCity; i++ {
		minCapa = math.Min(minCapa, float64(arr[i]))
	}
	return int(minCapa)
}

func main() {
	const nCity = 5
	var n, a, b, c, d, e int
	fmt.Scan(&n, &a, &b, &c, &d, &e)

	var minCapa = minArray([]int{a, b, c, d, e}, nCity)
	var maxTime int
	if n%minCapa == 0 {
		maxTime = n / minCapa
	} else {
		maxTime = (n / minCapa) + 1
	}

	fmt.Println(maxTime + nCity - 1)
}


Measured memory_bytes: 512