akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class308
    {
        static void Main()
        {
            var nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = nk[0], k = nk[1];
            bool[] frags = new bool[n];
            for(int i = 0; i < k; i++)
            {
                var d = int.Parse(Console.ReadLine());
                var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < a.Length; j++)
                    frags[a[j]-1] = true;
            }
            Console.WriteLine(frags.Count(x => x == false));
        }
    }
}


Measured memory_bytes: 28460
n = int(input())
mod = 10**9+7

def power(a, n, mod):
    bi=str(format(n,"b")) #2進数
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res

a = power(10, n, mod)-power(8, n, mod)
b = power(10, n, mod)-power(9, n, mod)
ans = b*2-a
print(ans%mod)


Measured memory_bytes: 61756
package main
 
import "fmt"
 
func main() {
  var N int
  fmt.Scan(&N)
  
  for i:=0; i <= N/4; i++ {
    for j:=0; j <= N/7; j++ {
      if N == 4 * i + 7 * j {
        fmt.Println("Yes")
        return
      }
    }
  }
  fmt.Println("No")
}

Measured memory_bytes: 512
MAX = 10**9 + 7

def mod_inv(i, mod):
    return pow(i, mod-2, mod)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up = up * (_N - i) % MAX
        low = low * (i + 1) % MAX
    ret = up * mod_inv(low, MAX) % MAX
    return ret

def cum_sum(N):
    return N * (N+1) // 2

def solve2():
    N, M, K = [int(_) for _ in raw_input().split()]
    sumx = 0
    for xi in range(1, N+1):
        sumx = (sumx + cum_sum(N) - (N + 1 - xi) * xi)
    sumx = (sumx * M * M) // 2 %MAX
    sumy = 0
    for yi in range(1, M+1):
        sumy = (sumy + cum_sum(M) - (M + 1 - yi) * yi)
    sumy = (sumy * N * N) // 2 %MAX
    ret = (sumx + sumy) * combination(M*N-2, K-2) % MAX
    print ret

if __name__ == '__main__':
    solve2()


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int A, B; cin >> A >> B;
  int tmp = 1;
  int cnt = 0;

  while(tmp < B) {
    tmp = tmp - 1 + A;
    cnt++;
  }

  cout << cnt << endl;
}

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

long long cnt = 0;
vector<int> G;
int n;
int a[1000000] = {0};
void insertionSort(int a[], int n, int g)
{
  for ( int i = g; i < n; i++ )
  {
    int v = a[i];
	int j = i-g;
	while ( j >= 0 && a[j] > v)
	{
		a[j+g] = a[j];
		j = j-g;
		cnt++;
		a[j+g] = v;
	}
  }
}
void shellSort( int a[], int n)
{
	for( int h = 1; ; )
	{
		if ( h > n)
		{
		break;
		}
		G.push_back(h);
		h=3*h+1;
	}

	int m = G.size();
	for (int i =m-1; i >=0 ; i--)
	{	
		insertionSort (a, n, G[i]);
	}
}
int main()
{	
	cin >> n;
	for ( int i = 0; i < n; i++ )
	{
		cin >> a[i];
	}
	
	shellSort (a,n);

	cout << G.size() << "\n";
	for ( int i = G.size() - 1; i >= 0; i-- )
	{
		cout << G[i] << " ";
	}
	cout << "\n";
	cout << cnt << "\n";
	for ( int i = 0; i < n-1; i++ )
	{
		cout << a[i] << "\n";
	}
	cout << a[n-1] << endl;

	return 0;
}


Measured memory_bytes: 7056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string a;
    string b;
    string c;
    cin >> a;
    cin >> b;
    cin >> c;
    cout << a[0] << b[1] << c[2] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int p[110];
int l1=0,l2=0,l3=0;
int main()
{
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
		if(p[i]<=a)
		l1++;
		else if(p[i]>b)
		l3++;
		else 
		l2++;
	}
	cout<<min(min(l1,l2),l3);
	return 0;
} 

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

using namespace std;

void debug(vector<vector<int> > &a, int n) {
  printf("Debug start\n");
  for (int i=0; i<n; i++) {
    for (int j=0; j<2; j++) {
      printf("%d ", a[i][j]);  
    }
    printf("\n");
  }
  printf("Debug end\n");
}

int main() {
  int n;
  scanf("%d", &n);
  vector<vector<int> > ab(n);
  vector<vector<int> > cd(n);
  for (int i=0; i<n; i++) {
    for (int j=0; j<2; j++) {
      int x;
      scanf("%d", &x);
      ab[i].push_back(x);
    }
  }

  for (int i=0; i<n; i++) {
    for (int j=0; j<2; j++) {
      int x;
      scanf("%d", &x);
      cd[i].push_back(x);
    }
  }

  sort(ab.begin(), ab.end(), [](const std::vector< int >& a, const std::vector< int >& b){ return a[1] > b[1]; } );
  sort(cd.begin(), cd.end(), [](const std::vector< int >& a, const std::vector< int >& b){ return a[0] < b[0]; } );

  int ans = 0;
  vector<bool> ab_check(n);
  for (int i=0; i<n; i++) {
    ab_check[i] = true;
  }

  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (cd[i][0] > ab[j][0] && cd[i][1] > ab[j][1] && ab_check[j]) {
        ans++;
        ab_check[j] = false;
        break;
      }
    }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#define _PI (3.141592653589793)
int main()
{
	int A, B, C, K;
	std::cin >> A >> B >> C >> K;
	int remain = K;
	int sum = 0;
	if (A >= remain) {
		sum += remain;
		remain = 0;
	}
	else {
		sum += A;
		remain -= A;
	}
	if (B >= remain) {
		remain = 0;
	}
	else {
		remain -= B;
	}
	sum -= remain;
	std::cout << sum << std::endl;
	return 0;
}

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

const ll HMAX = 1000;
const ll WMAX = 1000;
const ll MOD = 1e9 + 7;

vector<vector<char>> a(HMAX + 1, vector<char>(WMAX + 1, '#'));
vector<vector<ll>> num(HMAX, vector<ll>(WMAX, -1));

ll dfs(ll i, ll j) {
  if (num[i][j] != -1) return num[i][j];

  ll cnt = 0;
  if (a[i + 1][j] == '.') cnt += dfs(i + 1, j) % MOD;
  if (a[i][j + 1] == '.') cnt += dfs(i, j + 1) % MOD;

  num[i][j] = cnt % MOD;
  return num[i][j];
}

int main() {
  ll h, w;
  cin >> h >> w;

  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
    cin >> a[i][j];
    }
  }

  num[h - 1][w - 1] = 1;
  cout << dfs(0, 0) << endl;
}


Measured memory_bytes: 9216
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const M=input[0].split(' ')[1]-0;
  var parent=new Array(N+1).fill(0);
  for(var i=1;i<=M;i++){
    if(root(input[i].split(' ')[0]-0)!==root(input[i].split(' ')[1]-0)){
       parent[root(input[i].split(' ')[1]-0)]=root(input[i].split(' ')[0])-0;
    }
  }
  console.log(parent.reduce((acc,cur)=>{
    return acc+(cur===0?1:0);
  },0)-1);
  
  function root(node){
    var array=[];
    var point=node;
    while(parent[point]!==0){
      array.push(point);
      point=parent[point];
    }
    array.forEach(e=>{
      parent[e]=point;
    });
    return point;
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 57048
import bisect as bs
n = int(input())
l = sorted(list(map(int,input().split())))

count = 0
for i in range(n):
  for j in range(i+1,n):
    index = bs.bisect_left(l,l[i]+l[j])
    count += index - j - 1
    
print(count)

Measured memory_bytes: 42972
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

const int MAXN = 3e3 + 10;
const double PI = acos(-1.0);

int n, L;
double r[MAXN];

int main() {
	scanf("%d%d", &n, &L);
	for (int i = 1, x; i <= n; ++i) scanf("%d", &x), r[i] = 2.0 * x * PI / L;
	std::sort(r + 1, r + n + 1);
	double X = 0, Y = 0;
	for  (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j) {
			double mid = (r[i] + r[j]) / 2, awa = mid + PI;
			X += cos(mid) * (n + i - 1 - j), Y += sin(mid) * (n + i - 1 - j);
			X += cos(awa) * (j - i - 1), Y += sin(awa) * (j - i - 1);
		}
	double tot = 1.0 * n * (n - 1) * (n - 2) / 6;
	printf("%.15lf %.15lf\n", X / tot, Y / tot);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

ll k,a,b;
cin >> k >> a >> b;

if(b < a+3 || a >= k) {
    cout << k+1 << endl;
    return 0;
}

if((k-a+1) % 2 == 0) {
    cout << a + (b-a)*(k-a+1)/2 << endl;
}
else {
    cout << a + (b-a)*(k-a)/2 + 1 << endl;
}

return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def encode(s):
    code = [0] * 26
    for i in range(10):
        code[ord(s[i]) - ord('a')] += 1
    return code

def codeEqual(code1, code2):
    for i in range(26):
        if code1[i] != code2[i]:
            return False
    return True

def solve(N: int, s: "List[str]"):
    list_code = []
    for i in range(N):
        code = encode(s[i])
        list_code += [code]
    list_code = sorted(list_code)
    # count same string
    list_same = []
    count = 1
    for i in range(N-1):
        if codeEqual(list_code[i], list_code[i+1]):
            count += 1
        else:
            list_same += [count]
            count = 1
    if count > 1:
        list_same += [count]
    # count pairs
    final_count = 0
    for same in list_same:
        if same > 1:
            final_count += same * (same - 1) // 2
    print(final_count)
            
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40412
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

vector<ll> arr(100005);

void solve() {
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll k;
		cin >> k;
		sum += k;
		arr[k]++;
	}

	int test;
	cin >> test;
	while(test--) {
		ll a, b;
		cin >> a >> b;
		sum -= arr[a] * a;
		sum += arr[a] * b;
		arr[b] += arr[a];
		arr[a] = 0;
		cout << sum << endl;
	}
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3844
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        long count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long a[]=new long[n+1];
        long b[]=new long[n];
        for (int i=0;i<n+1;++i) a[i]=sc.nextLong();
        for (int i=0;i<n;++i) b[i]=sc.nextLong();

        for (int i=0;i<n;++i)
        {
            long rp=b[i]-a[i];
            if (rp<=0)
            {
                count+=b[i];
            }else
            {
                count+=a[i];
                long rp2=a[i+1]-rp;
                if (rp2<=0)
                {
                    count+=a[i+1];
                    a[i+1]=0;
                }else
                {
                    a[i+1]=rp2;
                    count+=rp;
                }
            }
        }
        System.out.println(count);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
}


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

import sys
from bisect import bisect_left
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_max(mn, mx, func):
    """ 条件を満たす最大値を見つける二分探索 """

    ok = mn
    ng = mx
    while ok+1 < ng:
        mid = (ok+ng) // 2
        if func(mid):
            # 上を探しに行く
            ok = mid
        else:
            # 下を探しに行く
            ng = mid
    return ok

# 右手と左手(a,b)の和がx以上となる組の数
def calc(x):
    # 各aについて、条件を満たす数を数える
    ans = 0
    for a in A:
        # 式変形： a + b >= x → b >= x - a
        ans += N - bisect_left(A, x - a)
    return ans >= M

N, M = MAP()
A = LIST()

A.sort()
res = bisearch_max(0, 10**10+1, calc)

ans = m = 0
acc = [0] + list(accumulate(A))
for a in A:
    idx = bisect_left(A, res - a)
    cnt = N - idx
    # 幸福度
    ans += a * cnt + (acc[N] - acc[idx])
    # 握手の回数
    m += cnt

# 同値でMを超えた分の調整
ans -= res * (m - M)
print(ans)


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    string S;
    cin >> S;
    bool isEasy = true;
    REP(i, S.length()) {
        if(i % 2 == 0) {
            if(S[i] == 'L') {
                isEasy = false;
                break;
            }
        }
        else {
            if(S[i] == 'R') {
                isEasy = false;
                break;
            }
        }
    }

    printf("%s\n", isEasy ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,m,a[100010],rui[100010];
map<int,int> r;

signed main(){
    I(n); I(m); REP(i,n) I(a[i]);
    REP(i,n) rui[i+1] = (rui[i] + a[i]) % m;
    int ret = 0;
    r[0] = 1;
    REP(i,n){
        auto v = rui[i+1];

        ret += r[v];
        r[v]++;
    }
    cout << ret << endl;
}

Measured memory_bytes: 5760
#coding: utf-8
K,S=map(int,input().split(" "))
answer=0
for X in range(K+1):
  if S-X>2*K:
    continue
  for Y in range(K+1):
    if S-(X+Y)<=K and S-(X+Y)>=0:
      answer+=1
print(answer)

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	string a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		cout<<a[i];
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

ll n;
string seven = "7", five = "5", three = "3";

int num_753(string x)
{
   int res = 0;
   if (stoll(x) > n)
      return 0;
   else
   {
      if (x.find("7") == string::npos || x.find("5") == string::npos || x.find("3") == string::npos)
         res = 0;
      else
         res = 1;

      res += num_753(x + seven);
      res += num_753(x + five);
      res += num_753(x + three);
   }
   return res;
}

int main()
{
   cin >> n;
   string x = "0";
   cout << num_753(x) << endl;
   return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll n;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cout << n * n * n;
    return 0;
}

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

using namespace std;

const int Inf = 0x7fffffff;
int n , minl = Inf;

inline int getsum(int x) {
	register int sum = 0;
	while(x) {
		sum += (x%10);
		x /= 10;
	}
	return sum;
}

int main() {
	
	scanf("%d",&n);
	
	for(register int i=1; i<=(n>>1); i++) {
		register int j = n - i;
		register int tmp = getsum(i) + getsum(j);
		minl = min(minl,tmp);
	}
	
	printf("%d\n",minl);
	
	return 0;
	
}

Measured memory_bytes: 256
s = input()
l = list(s)
i = 0
r = []
while i < len(l):
    if len(r) == 0:
        if s[i] == 'B':
            pass
        else:
            r.append(s[i])
    else:
        if s[i] == 'B':
            r.pop()
        else:
            r.append(s[i])
    i += 1
print(''.join(r))

Measured memory_bytes: 3060
n=int(input())
l=list(map(int,input().split()))
table=[0 for _ in range(n)]
table[0]=l[0]
table[1]=abs(l[1]-l[0])+l[0]
#print(l,table)
for i in range(2,n):
    table[i]=min(table[i-1]+abs(l[i]-l[i-1]),table[i-2]+abs(l[i]-l[i-2]))
#print(table)
print(table[-1]-l[0])

Measured memory_bytes: 13908
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

/*
struct SegmentTree{
  
  vector<lol> SumV(1000005,0);
  vector<lol> MaxV(1000005,0);
  vector<lol> MinV(1000005,0);
  int N;
  
  void update(int i,int x){
    i += N - 1;
    minv[i] = x;
    maxv[i] = x;
    sumv[i] = x;
    while(i > 0){
      i = (i - 1)/2;
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
    }
  }
  
  void add(int i,int x){
    i += N - 1;
    sumv[i] += x;
    maxv[i] += x;
    minv[i] += x;
    while(i > 0){
      i = (i - 1)/2;
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
    }
  }
  
  int getmax(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return -INF;
    if(a <= l && r <= b) return maxv[k];
    else{
      int c1 = getmax(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmax(a,b,2*k+2,(l+r)/2,r);
      return max(c1,c2);
    }
  }
  
  int getmin(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return minv[k];
    else{
      int c1 = getmin(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmin(a,b,2*k+2,(l+r)/2,r);
      return min(c1,c2);
    }
  }
  
  int getsum(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return sumv[k];
    else{
      int c1 = getsum(a,b,2*k+1,l,(l+r)/2);
      int c2 = getsum(a,b,2*k+2,(l+r)/2,r);
      return c1+c2;
    }
  }
}
*/

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}


signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  string s[h + 5];
  rep(i, h){
    cin >> s[i];
  }

  lol ans = 0;
  rep(bit1, (1 << h)){
    rep(bit2, (1 << w)){

      int sum = 0;
      rep(i, h){
	rep(j, w){
	  if(!(bit1 & (1 << i)) && !(bit2 & (1 << j))){
	    if(s[i][j] == '#'){
	      sum ++;
	    }
	  }
	}
      }

      if(sum == k){
	ans ++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3640
N, M, X, Y =list(map(int,input().split()))
x = [i for i in map(int, input().split())]        
y =[i for i in map(int, input().split())]
x_max =max(x)
y_min =min(y)

# X<Z<=Y を満たす数を列挙
for Z in range(X+1,Y+1):

  # x1, x2, ... , xn < Z <= y1, y2, ... , yn の判定
  if x_max<Z and Z<=y_min:
    print('No War')
    exit()

# 条件を満たすZが存在しない場合
print('War')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cmath>
#include <iomanip>
#include <cstdio>
using namespace std;

typedef long long ll;

const int maxn = 1e5+5;
int N,M;
int pre[maxn];
int size[maxn];
ll ans[maxn];
int l[maxn];
int r[maxn];

int find(int x)
{
    return pre[x] == x ? x : pre[x] = find(pre[x]); //这里一开始写错了，写成了x = find。。
}

void join(int a, int b)
{
    a = find(a), b = find(b);
    if(a != b)
    {
        size[a] += size[b];
        size[b] = 0;
       pre[b] = a;
    }
}
int main(){
	cin>>N>>M;

	for(int i=0;i<maxn;i++)
		pre[i] = i,size[i]=1;
	 memset(ans, 0, sizeof(ans));
		
	for(int i=1;i<=M;i++)
		scanf("%d%d", &l[i], &r[i]);
	ll cnt = N;
	ans[M+1] = cnt*(cnt-1)/2;
	for(int i = M;i>=2;i--){
		int x = find(l[i]);
		int y = find(r[i]);
		if(x!=y){
			ans[i] = ans[i+1]-size[x]*size[y];
			join(l[i],r[i]);
		}
		else 
			ans[i] = ans[i+1];
	}
	
	for(int i=2;i<=M+1;i++)
		  printf("%lld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    set<int>s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <algorithm>
#include <complex>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <istream>
//-----------------------------------------------------define--------------------------------------------------------------------//
#define PB push_buck
#define MP make_pair
#define MAX 100000000
//-------------------------------------------------------typedef----------------------------------------------------------------//
typedef long long ll;

using namespace std;

queue <int> v;
//------------------------------------------------------------------------------------------------------------------------------//
int main() {
	int n,sum=0,r;
	int t[10000], m, p[100], x[10000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> p[i] >> x[i];
			r = sum - t[p[i] - 1] + x[i];
			v.push(r);
	}
		while (!v.empty()) {
			int a=v.front(); v.pop();
			cout << a << endl;
		}


}

Measured memory_bytes: 256
/*
给定一个H行W列的矩阵，在某一个方格上有一个方块，初始位置在(sr, sc)
有两个人Ta和Ao，他们要玩一个游戏，他们每个人都有一个长度为N的字符串，
Ta的字符串为S，Ao的字符串为S,S和T都由四个字母构成：LRUD
游戏包含N步，第i步的进程如下：
  1、首先Ta移动方块，他可以按Si指定的方向移动，或者不移动
  2、Ao移动方块，他也可以按Ti制定的方向移动，或者不移动
如果目标方格不存在，则方块将被移出矩阵，游戏结束，尽管此时移动的次数不足N
Ta想在N步内从矩阵中移出方块，而Ao想在N步后方块依然在矩阵中。 
当两个游戏者都采取最优方案，确定到最后方块是否还在矩阵内。
数据范围：
2<=H,W,N<=2*10^5 
*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int h, w, sr, sc, n, step[4];
string s, t;
int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int i;
	cin>>h>>w>>n;
	cin>>sr>>sc;
	cin>>s>>t;
	step[0]=step[2]=sr, step[1]=step[3]=sc;
	for(i=0; i<n; i++){
		if(s[i]=='U'){
			step[0]--;
			if(step[0]<1){
				cout<<"NO"<<endl;
				return 0;
			}
		}
		if(t[i]=='D' && step[0]<h){
			step[0]++;
		}
		if(s[i]=='R'){
			step[1]++;
			if(step[1]>w){
				cout<<"NO"<<endl;
				return 0;
			}
		}
		if(t[i]=='L' && step[1]>1){
			step[1]--;
		}
		if(s[i]=='D'){
			step[2]++;
			if(step[2]>h){
				cout<<"NO"<<endl;
				return 0;
			}
		}
		if(t[i]=='U' && step[2]>1){
			step[2]--;
		}
		if(s[i]=='L'){
			step[3]--;
			if(step[3]<1){
				cout<<"NO"<<endl;
				return 0;
			}
		}
		if(t[i]=='R' && step[3]<w){
			step[3]++;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 920
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, a, t;

int main()
{
	//File("");
	n = gi <int> ();
	LL l = 1, r = 1;
	for (int i = 1; i <= n; i+=1)
	{
		t = gi <int> (), a = gi <int> ();
		LL x = (l - 1) / t + 1, y = (r - 1) / a + 1;
		x = max(x, y);
		l = x * t, r = x * a;
	}
	printf("%lld\n", l + r);
	return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll modfact[2001];

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res*a%MOD;
		a = a*a%MOD;
		n >>= 1;
	}
	return res;
}

ll modinv(ll n){
	return modpow(modfact[n], MOD-2);
}

ll nCr(ll n, ll r){
	return (modfact[n]*modinv(n-r)%MOD)*modinv(r)%MOD;
}

int main(){
	int n, k;
	cin >> n >> k;
	modfact[0] = 1;
	for (int i = 1; i <= 2000; i++){
		modfact[i] = modfact[i-1]*i%MOD;
	}
	for (int i = 1; i <= k; i++){
		if (n-k < i-1) cout << 0 << endl;
		else cout << nCr(n-k+1, i)*nCr(k-1, i-1)%MOD << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int a, b, c, d, r;
  cin >> a >> b >> c >> d;
  cout << max(0, min(b, d) - max(a, c)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a, b, ans;
    cin >> a >> b;
    if ((a + b) % 2 != 0)
    {
        ans = abs((a + b) / 2 + 1);
    }
    else ans = (a + b) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S =[]
for _ in range(H):
    a = input()
    S.append(a)
count =0
for i in range(H):
    for j in range(W):
        if S[i][j] =='.':
            count += 1
from collections import deque

seen = [[False]*(W) for _ in range(H)]
seen[0][0] = True
dq = deque([(0,0,1)])
d = [(1,0),(0,1),(0,-1),(-1,0)]
while dq:
    x,y,cnt = dq.popleft()
    if x ==H-1 and y ==W-1:
        print(count-cnt);exit()
    for dx,dy in d:
        if 0<=x+dx<H and 0<=y+dy<W and seen[x+dx][y+dy] ==False and S[x+dx][y+dy]=='.':
            seen[x+dx][y+dy] = True
            dq.append((x+dx,y+dy,cnt+1))
print(-1)

Measured memory_bytes: 74412
# include "cstdio"
# include "iostream"
# include "algorithm" 

using namespace std; 

int main(){
	int num,t,sum=0;
	scanf("%d",&num); 
	t=num;
	while(t>0){
		sum+=t%10;
		t/=10; 
	} 
	if(num%sum==0){ 
		printf("Yes"); 
	}else{
		printf("No"); 
	} 
	return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  ll X,Y;
  cin>>X>>Y;
  int ct=0;
  while(1){
    if(X>Y) break;
    ct++;
    X*=2;
  }
  cout<< ct<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

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

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	int A;
	int mina = INF;
	int minc = 0;
	int sum = 0;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A;
		sum += abs(A);
		chmin(mina, abs(A));
		if (A < 0)
		{
			minc++;
		}
	}

	if (minc % 2 == 0)
	{
		cout << sum << endl;
	}
	else
	{
		cout << sum - mina * 2 << endl;
	}

	return 0;
}

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

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define pii pair<int, int>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

/*-----------------------------------------------------MATH------------------------------------------------*/

const int inf = 1e9;
const int MAXN = 2e5 + 10;
ll mod = 1e9;
vector<int> c(18, 0);
vector<int> ans;
vector<int> fact;
void solve() {
    ll n, m;
    cin>>n>>m;
    vector<int> ar(n, 0);
    ll nok=1;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        a/=2;
        ar[i]=a;
        nok=lcm(nok, a);
    }
    for(int i=0;i<n;i++){
        if((nok/ar[i])%2==0){
            cout<<0<<endl;
            return;
        }
    }
    cout<<(m/nok +1 )/2;

}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n = 1;
    for (int i = 0; i < n; i++) solve();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



//-------------------------------------------------


int main()
{
  int n ;
  cin >> n ;
  int ans = 0 ;
  vector<int> vec1(n) ;
  vector<int> vec2(n) ;
  REP(i,n){
    cin >> vec1.at(i) ;
  }
  REP(i,n){
    cin >> vec2.at(i) ;
  }
  REP(i,n){
    if(vec1.at(i)>=vec2.at(i)){
      ans += vec1.at(i)-vec2.at(i) ;
    }
  }
  cout <<ans <<endl;

  return 0 ;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL H,W;cin >> H >> W;
    if(H == 1 || W == 1)cout << 1 << endl;
    else{
        if(H % 2 == 0){
            LL t = W*H/2;
            cout << t << endl;
        }
        else{
            LL t = (W+2-1)/2;
            LL s = W/2;
            t *= (H/2 + 1);
            s *= (H/2);
            cout << t + s << endl;
        }
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

int r(int s,int n){
  if(n == 0) return s;
  double tmp = s * 1.05;
  s = ((int)tmp+999)/1000*1000;
  return r(s,n-1);
}

int main(){
  int n; cin>>n;
  cout << r(100000,n) << endl;
  
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 998244353;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll fac[MAX_N], inv[MAX_N], fiv[MAX_N]; //fiv:inv(fac(i))

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}

void C_init(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	fiv[0] = fiv[1] = 1;
	rep(i, 2, n + 1) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fiv[i] = fiv[i - 1] * inv[i] % mod;
	}
}

ll C(int a, int b) { //assume a >= b
	if(a < b || a < 0 || b < 0) return 0;
	return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}

int N; ll A, B, K;

void solve() {
	cin >> N >> A >> B >> K;
	C_init(N);
	ll res = 0;
	for(int a = 0; a <= N; a++) {
		if(K - A * a < 0 || (K - A * a) % B) continue;
		int b = (K - A * a) / B;
		ADD(res, C(N, a) * C(N, b) % mod);
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

# define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll ar[n];
    map<ll,ll> mp;
    ll sum=0;
    for(ll i=0;i<n;i++){
        cin>>ar[i];
        mp[ar[i]]++;
        sum+=ar[i];
    }
    ll q;
    cin>>q;
    ll x,y;
    while(q--){
        cin>>x>>y;
        sum+=(y-x)*mp[x];
        mp[y]+=mp[x];
        mp[x]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 10340
N,K = map(int, raw_input().split())
P = [-1]*N
for _ in range(K):
    A,B = map(int, raw_input().split())
    P[A-1] = B-1
T = [[[0]*3 for i in range(3)] for j in range(N)]
for i in range(3):
    if P[0]==-1 or P[0]==i:
        for j in range(3):
            if P[1]==-1 or P[1]==j:
                T[1][i][j] = 1
for i in range(2, N):
    for j in range(3):
        if P[i]==-1 or P[i]==j:
            for k in range(3):
                for l in range(3):
                    if k!=j or l!=j:
                        T[i][k][j] += T[i-1][l][k]
                        T[i][k][j] %= 10000
#print T
print sum(sum(t) for t in T[N-1])%10000

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    int n,m;
    cin>>n;
    Vi a(n);
    map<int,int> mpa;
    REP(i,0,n){
        cin>>a[i];
        mpa[a[i]]++;
    }
    cin>>m;
    Vi b(m);
    map<int,int> mpb;
    REP(i,0,m){
        cin>>b[i];
        mpb[b[i]]++;
    }
    bool check=true;
    for(auto x : mpb){
        if(mpa[x.first]<x.second) check=false;
    }
    YESNO(check);
    return 0;
}

Measured memory_bytes: 28416
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n = sc.nextInt();
        char c[]=sc.nextString().toCharArray();
        int n=c.length;
        int d[]=new int[n],v=0;
        
        for (int i = 0; i+1 < c.length; i++) {
			if(c[i]=='B' && c[i+1]=='C') {
				d[v]=1;
				i++;
			} else if(c[i]=='A'){
				d[v]=2;
			} 
			v++;
		}
        long ans=0;
//        db(d);
        for (int i = 0,a=0; i < v; i++) {
			if(d[i]==2)a++;
			else if(d[i]==1)ans+=a;
			else a=0;
		}
        
        out.println(ans);
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}
//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int b,l,r;
    P(int b, int l, int r) {
        this.b=b;
        this.l=l;
        this.r=r;
    }

    public int compareTo(P p){
        return -(max(r,l)) + max(p.l,p.r);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 26324