akhauriyash/Code-Regression huggingface dataset:
// In tribute to ba4mohandes Akram and Tsunami
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3", "omit-frame-pointer","inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")

#include <bits/stdc++.h>

using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
//const long long mod = 1000000007;
const long long mod = 998244353;
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int mxN = 200010;


int main(int argc, char *argv[]) {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
//	freopen("cube.in", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif

	int t = 1;
//	cin >> t;
	while (t--) {
		int N;
		cin>>N;
		vector<int> cnt(N + 1);
		int x;
		for(int i = 1;i < N;i++) cin>>x, cnt[x]++;
		for(int i = 1;i <= N;i++) cout<<cnt[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
double max(double a,double b){
  if(a<b) return b;
  else return a;
}
int main() {
  int N,K;
  cin>>N>>K;
  double ask;
  vector<double>sai(N);
  vector<double>saisai(N+1);
  rep(i,N){
    double x;
    cin>>x;
    sai[i]=(x+1)/2;
  }
  saisai[0]=0;
  for(int i=1;i<=N;i++){
    saisai[i]=saisai[i-1]+sai[i-1];
  }
  ask=saisai[K];
  for(int i=0;i+K<=N;i++){
    ask=max(ask,saisai[K+i]-saisai[i]);
  }
  cout<< fixed << setprecision(15) <<ask;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

int mn[1 << 26];

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    int cur = 0;
    int dp[n + 1];
    fill(dp, dp + n + 1, INF);
    fill(mn, mn + (1 << 26), INF);
    dp[0] = 0;
    mn[0] = 0;
    for (int i = 0; i < n; i++) {
        cur ^= 1 << (s[i] - 'a');
        dp[i + 1] = min(dp[i + 1], mn[cur] + 1);
        for (int c = 0; c < 26; c++) {
            int nxt = cur ^ (1 << c);
            dp[i + 1] = min(dp[i + 1], mn[nxt] + 1);
        }
        mn[cur] = min(mn[cur], dp[i + 1]);
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 266644
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, bak, cl, qx[909], qy[909], dis[33][33], pas[77][77], x, y, dx[4], dy[4], mn[33][33], ans[77][77][2];
int main()
{
	dx[0] = -1; dy[0] = 0;
	dx[1] = 0; dy[1] = -1;
	dx[2] = +1; dy[2] = 0;
	dx[3] = 0; dy[3] = +1;
		for(;;)
	{
	for(int i = 0; i < 77; i++) for(int j = 0; j < 77; j++) pas[i][j] = 1;
		scanf("%d%d", &n, &m);
		if(!n or !m)
			break;
		//printf("%d %d\n", n, m);
		for(int i = 1; i <= 2 * n - 1; i++)
		{
			if(i & 1)
			{
				for(int j = 1; j < m; j++)
				{
					scanf("%d", &pas[i + 1][j * 2 + 1]);
				}
			}else
			{
				for(int j = 1; j <= m; j++)
				{
					scanf("%d", &pas[i + 1][j * 2]);
				}
			}
		}
		bool flag = true;
		for(int i = 2; i <= 2 * n; i++) for(int j = 2; j <= 2 * m; j++) if(i % 2 == 1 xor j % 2 == 1)
		{
			//	printf("%d %d\n", i,j);
			bak = pas[i][j];
			pas[i][j] = 1;

			qx[cl = 1] = n;
			qy[1] = m;
			for(int i1 = 1; i1 <= n; i1++) for(int j1 = 1; j1 <= m; j1++) dis[i1][j1] = -1;
			dis[n][m] = 0;
			for(int op = 1; op <= cl; op++)
			{
			//	printf("%d\n", op);
				x = qx[op]; y = qy[op];
				for(int d = 0; d < 4; d++)
				{
				//	printf("%d %d\n", x + dx[d], y + dy[d]);
					if(!pas[2 * x + dx[d]][2 * y + dy[d]] and dis[x + dx[d]][y + dy[d]] == -1)
					{
						dis[x + dx[d]][y + dy[d]] = dis[x][y] + 1;
						qx[++cl] = x + dx[d];
						qy[cl] = y + dy[d];
					}
				}
			}
			if(dis[1][1] == -1) {flag = false; break;}
			ans[i][j][0] = dis[i / 2][j / 2];
			ans[i][j][1] = dis[(i + 1) / 2][(j + 1) / 2];
		//	printf("ans[%d][%d][%d] = %d, ans[%d][%d][%d] = %d, \n", i, j,0, ans[i][j][0], i, j, 1, ans[i][j][1]);
			pas[i][j] = bak;
		}
		if(!flag) {printf("-1\n"); continue;}
		for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) mn[i][j] = 0x3fffffff;
		mn[n][m] = 0;
		qx[cl = 1] = n;
		qy[1] = m;
		for(int op = 1; op <= cl; op++)
		{
			x = qx[op]; y = qy[op];
			for(int d = 0; d < 4; d++)if(!pas[x * 2 + dx[d]][y * 2 + dy[d]])
			{
				int tmp = max(1 + mn[x][y], ans[x * 2 + dx[d]][y * 2 + dy[d]][(dx[d] + dy[d]) == 1?1:0]);
				//printf("%d %d %d\n", x, y, tmp);
				if(mn[x + dx[d]][y + dy[d]] > tmp)
				{
					mn[x + dx[d]][y + dy[d]] = tmp;
					qx[++cl] = x + dx[d];
					qy[cl] = y + dy[d];
				}
			}
		}
		printf("%d\n", mn[1][1]);
	}
	fclose(stdin);
	return 0;
}

Measured memory_bytes: 1120
import sys
import time
sys.setrecursionlimit(20000)

def find(tree,x):
    idx = tree[x]
    if(idx== x):
        return x
    else:
        root_idx = find(tree,tree[idx])
        return root_idx

def relate(tree,x,y,z):
    x_root_idx = find(tree,x)
    y_root_idx = find(tree,y)
    if(x_root_idx == y_root_idx):
        return False
    
    if (tree_rank[y_root_idx] < tree_rank[x_root_idx]):
        tree[y_root_idx] = (x_root_idx, z+tree[x][1]-tree[y][1])
    else:
        tree[x_root_idx] = (y_root_idx, -z-tree[x][1]+tree[y][1])
        if(tree_rank[x_root_idx]==tree_rank[y_root_idx]):
            tree_rank[y_root_idx] = tree_rank[y_root_idx] + 1
    #tree[x_root_idx] = (y_root_idx,z-tree[x_root_idx][1]+tree[y_root_idx][1])

def diff(tree,x,y):
    x_idx = find(tree,x)
    y_idx = find(tree,y)
    if not(x_idx == y_idx):
        return "?"
    return tree[y][1] - tree[x][1]

def unite(tree,x,y):
    x_root_idx = find(tree,x)
    y_root_idx = find(tree,y)

    if not (x_root_idx == y_root_idx):
        if(tree_rank[x_root_idx] < tree_rank[y_root_idx]):
            tree[x_root_idx] = y_root_idx
        else:
            tree[y_root_idx] = x_root_idx
            if(tree_rank[x_root_idx] == tree_rank[y_root_idx]):
                tree_rank[x_root_idx] = tree_rank[x_root_idx] + 1

def same(tree,x,y):
    x_root_idx = find(tree,x)
    y_root_idx = find(tree,y)
    if(x_root_idx == y_root_idx):
        return True
    else:
        return False

if __name__ == '__main__':
    #start = time.time()
    N,query_num = map(int, input().split())
    union_find_tree = [i for i in range(N)]
    tree_rank = [0]*N
    for i in range(query_num):
        operate,x,y = map(int, input().split())
        if(operate==0):
            unite(union_find_tree,x,y)
        if(operate==1):
            res = same(union_find_tree,x,y)
            if(res):
                print("1")
            else:
                print("0")
    #elapsed_time = time.time() - start
    #print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")



Measured memory_bytes: 6076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dpsheet
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string x = Console.ReadLine();
            int n = s.Length;
            int m = x.Length;
            string[,] print =new string[n+1,m+1];
            int[,] temp = new int[n+1,m+1 ];
            for (int i = 0; i <= n; i++)
                for (int j = 0; j <= m; j++)
                    temp[i, j] = -1;
            LCS(s, x, n, m, temp,print);
           
        }
        static void Print(string[,] p,string s,int n ,int m)
        {
            if (n == 0 ||m == 0)
                return;
            else if (p[n, m] == "*")
            {
               
                Print(p, s, n - 1, m - 1);
                Console.Write(s[m-1]);

            }
            else if (p[n, m] == "^")
                Print(p, s, n, m-1);
            else
                Print(p, s, n-1, m);
            //Console.WriteLine(r);
        }
        static int LCS(string s, string x, int n,int m,int[,] result,string[,] print)
        {
            for(int i=0;i<=n;i++)
                for(int j = 0; j <= m; j++)
                {
                    if (i == 0 || j == 0) { 
                        result[i, j] = 0;
                        
                    }
                    else
                    {
                        if (s[i - 1] == x[j - 1]) {
                            result[i, j] = result[i - 1, j - 1] + 1;
                            print[i, j] = "*";
                        }
                        else
                           if (result[i, j - 1] > result[i - 1, j])
                        {
                            result[i, j] = result[i, j - 1];
                            print[i, j] = "^";
                        }
                        else
                        { 
                            result[i, j] = result[i - 1, j];
                            print[i, j] = "<";
                        }

                    }
                }
            Print(print, x, n, m);
            return result[n, m];
        }
    }
}


Measured memory_bytes: 117592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <sstream>
#include <numeric>
#include <queue>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    sort(a.begin(),a.end()) ;
    vector<pair<int,int> > b ;
    b.push_back(make_pair(a.at(0), 1)) ;
    int marker = 0 ;
    for (size_t i = 1; i < n; i++)
    {
        if (a.at(i) == a.at(i-1))
        {
            b.at(marker).second += 1 ;
        }else
        {
            b.push_back(make_pair(a.at(i),1)) ;
            marker ++ ;
        }
        
        
    }
    int i = 0 ;
    int j = b.size()-1 ;
    while (i != j){
        if (b.at(i).second == 1)
        {
            i ++ ;
        }else if (b.at(j).second == 1)
        {
            j -- ;
        }

        if (b.at(i).second >1 && b.at(j).second > 1)
        {
            b.at(i).second -- ;
            b.at(j).second -- ;
        }
        
    }
    b.at(i).second %= 2 ;
    int ans = 0 ;
    for (size_t i = 0; i < b.size(); i++)
    {
        ans += b.at(i).second ;
    }
    
    cout << ans << endl; ;

}

Measured memory_bytes: 1784
n, k = map(int, input().split())
li = [(int(j) + 1) / 2 for j in input().split()]

if k == 1:
  print(max(li))
else:
  a = 0
  for i in range(n-k+1):
    if i == 0:
      xe = sum(li[0:k])
    else:
      xe = xe - li[i-1] + li[i+k-1]
    a = max(a, xe)
  print(a)

Measured memory_bytes: 23524
#include<bits/stdc++.h>
using namespace std;
int n,p[100010],q[100010];
pair<int,int> dt[200010];
vector <int> des[1000100];
int po;
int dfn[1000100],low[1000100],st[1000100],bel[1000100],tim,js,top;
bool ins[1000100];
void tarjan(int s)
{
    dfn[s]=low[s]=++tim;
    st[++top]=s;ins[s]=true;
    for (int k=0;k<des[s].size();k++)
    {
        if (!dfn[des[s][k]]) {tarjan(des[s][k]);low[s]=min(low[s],low[des[s][k]]);}
        else if (ins[des[s][k]]) low[s]=min(low[s],dfn[des[s][k]]);
    }
    if (dfn[s]==low[s])
    {
        js++;
        while (st[top]!=s)
        {
            bel[st[top]]=js;
            ins[st[top]]=false;top--;
        }
        bel[st[top]]=js;
        ins[st[top]]=false;top--;
    }
}
void build(int root,int l,int r)
{
	po=max(po,root+2*n);
	if (l==r)
	{
		des[root+2*n].push_back((dt[l].second<0)?-dt[l].second+n:dt[l].second);
		return;
	}
	int mid=(l+r)>>1;
	des[root+2*n].push_back(root*2+2*n);
	des[root+2*n].push_back(root*2+1+2*n);
	build(root*2,l,mid);build(root*2+1,mid+1,r);
}
void find(int ql,int qr,int s,int root=1,int pl=1,int pr=2*n)
{
	if ((pl==ql)&&(pr==qr))
	{
		des[s].push_back(root+2*n);
		return;
	}
	int mid=(pl+pr)>>1;
	if (qr<=mid) find(ql,qr,s,root*2,pl,mid);
	else if (ql>mid) find(ql,qr,s,root*2+1,mid+1,pr);
	else
	{
		find(ql,mid,s,root*2,pl,mid);
		find(mid+1,qr,s,root*2+1,mid+1,pr);
	}
	/*for (int i=ql;i<=qr;i++)
	{
		cerr<<s<<' '<<((dt[i].second<0)?-dt[i].second+n:dt[i].second)<<endl;
		des[s].push_back((dt[i].second<0)?-dt[i].second+n:dt[i].second);
	}*/
}
bool check(int lim)
{
	for (int i=1;i<=po;i++) {des[i].clear();dfn[i]=low[i]=bel[i]=0;}tim=js=top=0;
	po=2*n;
	build(1,1,2*n);
	int d=0;
	for (int i=1;i<=2*n;i++)
	{
		while ((d+1<i)&&(dt[i].first-dt[d+1].first>=lim)) d++;
		if (d+1<=i-1) find(d+1,i-1,(dt[i].second<0)?-dt[i].second:dt[i].second+n);
	}
	d=2*n+1;
	for (int i=2*n;i>=1;i--)
	{
		while ((d-1>i)&&(dt[d-1].first-dt[i].first>=lim)) d--;
		if (i+1<=d-1) find(i+1,d-1,(dt[i].second<0)?-dt[i].second:dt[i].second+n);
	}
	for (int i=1;i<=po;i++) if (!dfn[i]) tarjan(i);
	for (int i=1;i<=n;i++) if (bel[i]==bel[i+n]) return false;
	return true;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		dt[i]=make_pair(x,-i);
		dt[i+n]=make_pair(y,i);
	}
	sort(dt+1,dt+2*n+1);
	for (int i=1;i<=2*n;i++)
	{
		if (dt[i].second<0) p[-dt[i].second]=i;
		else q[dt[i].second]=i;
	}
	int l=0,r=1e9+10;
	//cerr<<check(3)<<endl;return 0;
	while (l+1!=r)
	{
		int mid=(l+r)>>1;
		if (check(mid)) l=mid;else r=mid;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 40320
s = input()
q = int(input())
v = 0
fs = ''
rs = ''

for i in range(q):
    t = input().split()
    if t[0] == '1':
        v = v + 1
    elif t[0] == '2':
        if (t[1] == '1') and (v % 2 == 0):
            fs = t[2]+fs
        elif (t[1] == '1') and (v % 2 == 1):
            rs = rs + t[2]
        elif (t[1] == '2') and (v % 2 == 0):
            rs = rs + t[2]
        elif (t[1] == '2') and (v % 2 == 1):
            fs = t[2]+fs

if v % 2 == 0:
    s = fs + s + rs
else:
    s = fs + s + rs
    s = s[::-1]        
            
print (s)


Measured memory_bytes: 4404
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	b := make([]bool, 1e6+1)
	done := map[int]bool{}
	for i := 0; i < n; i++ {
		if done[a[i]] {
			b[a[i]] = true
			continue
		}
		for j := 2; a[i]*j <= 1e6; j++ {
			b[a[i]*j] = true
		}
		done[a[i]] = true
	}

	ans := 0

	for i := 0; i < n; i++ {
		if !b[a[i]] {
			ans++
		}
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 11604
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>

int main(void)
{
    int64_t N, W;
    std::cin >> N >> W;

    int64_t dp[N+1][W+1];
    std::memset(dp, 0, sizeof(dp));

    std::cout << std::endl;

    for (int64_t i = 1; i <= N; ++i) {
        int64_t w, v;
        std::cin >> w >> v;
        for (int64_t j = 1; j <= W; ++j) {
            auto& prev_dp = dp[i-1];
            if (w > j) {
                dp[i][j] = prev_dp[j];
            } else {
                int64_t surplus_w = j-w;
                dp[i][j] = std::max(prev_dp[j], v + prev_dp[surplus_w]);
            }
        }
    }

    std::cout << dp[N][W] << std::endl;

    return 0;
}

Measured memory_bytes: 79104
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N, K):
    MOD = 10**9 + 7
    C = Combination(2000, MOD)
    M = Mod(MOD)
    R = N-K
    for i in range(1, K+1):
        print(M.mul(C(R+1, i), C(K-1, i-1)))


def main():
    N, K = read_int_n()
    slv(N, K)

if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  int numOfPeople=0;
  for (int i=0; i<n; i++) {
    int l, r;
    cin >> l >> r;
    numOfPeople += r-l+1;
  }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        
        for (int i = 0; i < n; i++) {
            ary[i] = sc.nextInt();
        }
        
        n = sc.nextInt();
        int[] t = new int[n];
        
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
        }
        
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (isContain(t[i], ary)) {
                res++;
            }
        }
        
        System.out.println(res);
    }
    
    public static boolean isContain(int num, int[] ary) {
        int j = 0;
        while (j < ary.length) {
            if (num == ary[j]) {
                return true;
            }
            j++;
        }
        return false;
    }
}

Measured memory_bytes: 40356
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  int h,w,H,W;
  std::cin >> h >> w >> H >> W;
  std::cout << (h-H)*(w-W) << '\n';
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VPI = vector<PII>;
using VPL = vector<PLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
	//i=m -> n-1(昇順)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)
	//i=m -> n(降順)

int main(){
  string s;
  cin >> s;
  int n = s.size();
  VLL a(n);
  REP(i,0,n){
    a[i] = s[i] - '0';
  }
  
  LL ans = 0;
  REP(i,0,1<<(n-1)){
    LL cnt = a[0];
    RREP(j,n-2,0){
      if(((i >> j) & 1) == 0){
        cnt *= 10;
        cnt += a[n-j-1];
      }
      else{
        ans += cnt;
        cnt = a[n-j-1];
      }
    }
    ans += cnt;
  }
        
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3628
import itertools
while 1:
    t,s = map(int,raw_input().split())
    if t == 0: break
    ans = s if s <= t else 0
    s = str(s)
    nums = [s] if ans > 0 else []
    n = len(s)
    reject = False
    for split in xrange(1,n):
        for cuts in itertools.combinations(range(1,n),split):
            cuts = [0]+list(cuts)+[n]
            tmp = sum(int(s[i:j]) for i,j in zip(cuts,cuts[1:]))
            if   tmp == ans: reject = True
            elif t >= tmp > ans:
                ans = tmp
                nums = [s[i:j] for i,j in zip(cuts,cuts[1:])]
                reject = False
    if reject: print "rejected"
    elif len(nums) == 0: print "error"
    else: print ans, " ".join(nums)

Measured memory_bytes: 4400
maxN = int(input())

if maxN < 10: print(maxN)
elif maxN < 100: print("9")
elif maxN < 1000: print(9 + maxN-99)
elif maxN < 10000: print(909)
elif maxN < 100000: print(909 + maxN-9999)
else: print(90909)

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (b <= n) cout << (a*(b-1))/b - a*((b-1)/b) << endl;
  else cout << (a*n)/b - a*(n/b) << endl;
  return 0;
}

Measured memory_bytes: 3608
def main():

    SA = list(input())
    SB = list(input())
    SC = list(input())
    d = {"a":0, "b":1, "c":2}
    inv = {0:"A", 1:"B", 2:"C"}
    S = [SA, SB, SC]
    i = 0
    while True:
        if len(S[i]) == 0:
            return inv[i]
        i = d[S[i].pop(0)]



if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=(a>b)?(a):(b);
#define chmin(a, b) (a)=(a<b)?(a):(b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  ll N, X, Y;
  cin >> N >> X >> Y;
  X--; Y--;
  
  
  ll cnt[2222]={};
  for(i=0; i<N; i++)
    for(j=i+1; j<N; j++)
      cnt[min(j-i, abs(X-i)+1+abs(Y-j))]++;
  
  for(i=1; i<N; i++) pt(cnt[i]);
  
  
  
}




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

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    int curw=0;
    bool flag=true;
    for(int h=0; h<H; h++) {
        string str;
        cin >> str;
        char pre;
        for(int w=0; w<W; w++) {
            if(curw>w) {
                if(str[w]=='#') {
                    flag=false;
                    break;
                }
            } else if(curw==w) {
                if(str[w]!='#') {
                    flag=false;
                    break;
                } else {
                    pre='#';
                }
            } else {
                if(pre=='#' && str[w]=='#') {
                    curw++;
                } else if(str[w]!='#') {
                    pre='.';
                } else {
                    flag=false;
                    break;
                }
            }
        }
    }
    
    if(flag) {
        cout << "Possible"  << endl;
    } else {
        cout << "Impossible" << endl;
    }
    

    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include <stdlib.h>
using namespace std;

int main() {
    int N;
    long long INF = 1LL << 60;
    cin >> N;
    long long h[100010];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    long long dp[100010];
    for(int i = 0; i < 100010; i++){
        dp[i] = INF;
    }

    dp[0] = 0;

    for(int i = 1; i < N; i++){
        if(dp[i] > dp[i - 1] + abs(h[i] - h[i - 1])){
            dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        }

        if(i > 1){
            if(dp[i] >  dp[i - 2] + abs(h[i] - h[i - 2])){
                dp[i] = dp[i - 2] + abs(h[i] - h[i - 2]);
            }
        }

    }

        cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main() {
	string s;
	cin >> s;
	LL sum=0LL;

	FOR(index, 0, pow(2,s.length()-1)) {
		int last = 0;
		string ss;
		REP(i, s.length() - 1) {
			if ((index&(1 << i)) != 0) {
				ss=(s.substr(last, i+1 - last));
				//debug(ss);
				sum += stoll(ss);
				last = i+1;
			}
		}
		ss=(s.substr(last));
		//debug(ss);
		sum += stoll(ss);
		//debug(a);
	}
	cout << sum << endl;

}	


Measured memory_bytes: 512
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline


def main():
    """ main """
    N = int(input())
    REDS = [tuple(map(int, input().split())) for _ in range(N)]
    BLUES = [tuple(map(int, input().split())) for _ in range(N)]
    REDS.sort(reverse=True)
    BLUES.sort(key=itemgetter(1))

    ans = 0
    for ax,ay in REDS:
        bs = [(bx,by) for bx,by in BLUES if ax < bx and ay < by]
        if 0<len(bs):
            BLUES.remove(bs[0])
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int res,k,n,h;
  vector<int> vec();
  
  cin >> n >> k;
  
  for(int i=0;i<n;++i){
    cin >> h;
    if(h>=k){
      ++res;
    }
  }
  cout << res << endl;
  }

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int a[N],n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	if(a[n/2]==a[n/2+1])puts("0");
	else printf("%d",a[n/2+1]-a[n/2]);
	return 0;
}


Measured memory_bytes: 512
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    XYH = [[int(i) for i in input().split()] for j in range(N)]
    XYH.sort(reverse=True, key=lambda p: p[2])

    for cy in range(101):
        for cx in range(101):
            ch = XYH[0][2] + abs(XYH[0][0] - cx) + abs(XYH[0][1] - cy)
            for x, y, h in XYH[1:]:
                if h != max(ch - abs(x - cx) - abs(y - cy), 0):
                    break
            else:
                if ch != 0:
                    return print(cx, cy, ch)
    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41200
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "OK" << endl ; else cout << "NG" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll k,a,b ;
	cin >> k >> a >> b ;
	yorn((a-1)/k!=b/k) ;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector <int> c(n-1);
  vector <int> s(n-1);
  vector <int> f(n-1);
  for(int i=0;i<n-1;i++)
    cin>>c.at(i)>>s.at(i)>>f.at(i);
  for(int i=0;i<n;i++){
    int t=0;
    for(int j=i;j<n-1;j++)
      t=(max(s.at(j),t)+f.at(j)-1)/f.at(j)*f.at(j)+c.at(j);
    cout<<t<<endl;
  }
}

Measured memory_bytes: 3596
/*..............Bismillahir Rahmanir Rahim.............*/
/**
*     => Md. Sajjat Hosen
*     => Department of Computer Science and Engineering
*     => Bangabandhu Sheikh Mujibur Rahman Science and Technology University
**/

/*..................! TRY ONCE MORE !..................*/

/*...Part - 01...*/

#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

inline int Int(){int x ; scanf("%d",&x) ; return x ;}
inline ll Long(){ll x ; scanf("%lld",&x) ; return x ;}
inline float Float(){float x ; scanf("%f",&x) ; return x ;}
inline double Double(){double x ; scanf("%lf",&x); return x;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/



int main(){
    //freopen("input.txt","r",stdin);
    int test = 1 , tc = 0 ;
    int n, m, ans = 0;
    while(test--){
        n = Int;
        m  = Int;
        n--;
        m--;
        if(n > 0){
            ans += (n*(n + 1)) / 2;
        }
        if(m > 0){
            ans += (m*(m + 1)) / 2;
        }
        printf("%d\n", ans);
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/

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

int main (){
    int n, k ;
    cin >> n >> k ;
    vector<int> h (n) ;
    rep(i, n)  cin >> h[i] ;
    int ans = 0;
    rep(i, n)  if(h[i] >= k) ans++ ;
    cout << ans << endl ;
}

Measured memory_bytes: 3700
def main():
    from math import floor,ceil
    N = int(input())
    A = list(map(int,input().split()))
    for i in range(N):
        A[i] -= i+1
    
    def f(b):
        res = 0
        for a in A:
            res += abs(a-b)
        return res
    INF = 10**9+10
    l = -INF
    r = INF
    min_saddness = 10**15
    while l < r-2:
        m1 = (r-l)*2//3+l
        m2 = (r-l)//3+l
        tmp1 = f(m1)
        tmp2 = f(m2)

        if tmp2 < tmp1:
            r = m1
        else:
            l = m2
    print(f((l+r)//2))

main()

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

int main(){
  int n;
  cin >> n;
  vector<int>kazu(n);
  for(int i=0;i<n;i++)
    cin >> kazu.at(i);
  int ans=0;
  for(int i=0;i<n-2;i++){
    if((kazu.at(i)>kazu.at(i+1)&&kazu.at(i+2)<kazu.at(i+1))||(kazu.at(i)<kazu.at(i+1)&&kazu.at(i+2)>kazu.at(i+1)))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

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

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5;
const int INF = 1e9;

int n, ans[N], a[N], b[N];
vector <pii> g[N];

void dfs(int v, int pr, int col) {
	int cntCol = 1;
	for(pii it : g[v]) {
		int to = it.F;
		int id = it.S;
		if(to == pr) continue;
		if(cntCol == col) ++cntCol;
		ans[id] = cntCol;
		dfs(to, v, cntCol);
		++cntCol;
	}
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	fo(i, 1, n - 1, 1) {
		cin >> a[i]	>> b[i];
		g[a[i]].pb(mkp(b[i], i));
		g[b[i]].pb(mkp(a[i], i));
	}
	int mxE = -1, v = -1;
	fo(i, 1, n, 1) {
		if(mxE < sz(g[i])) {
			mxE = sz(g[i]);
			v = i;
		}
	}
	dfs(v, -1, 0);
	cout << mxE <<'\n';
	//show(mxE);
	fo(i, 1, n - 1, 1) {
		cout << ans[i] <<'\n';
	}
	return 0;
}












Measured memory_bytes: 13184
while n = gets.to_i
  break if n==0
  a = Array.new(n).map{Array.new(n,"0")}
  k = 1
  i = n/2
  j = n/2-1
  while k<=n*n
    i+=1;j+=1
    if i<n && j<n
      if a[i][j]=="0"
        a[i][j]=k.to_s
        k+=1
      else
	j-=2
      end
    end
    if i>=n && j>=n
      i=-1
      j=-1
    elsif i>=n 
      i=-1
      j-=1
    elsif j>=n
      i-=1
      j=-1
    end
  end
  for i in 0..n-1
    for j in 0..n-1
      print(" "*(4-a[i][j].length),a[i][j])
    end
    print("\n")
  end
end


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

int main() {
    int a,b,t;
    cin>>a>>b>>t;
    cout<<b*(t/a)<<endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    
    int A[N], B[N], C[M], D[M];
    for(int i = 0; i < N; ++i){ cin >> A[i] >> B[i]; }
    for(int i = 0; i < M; ++i){ cin >> C[i] >> D[i]; }

    for(int i = 0; i < N; ++i){
        int maxNum = INT_MAX;
        int ans;
        for(int j = 0; j < M; ++j){
            int temp = abs(A[i] - C[j]) + abs(B[i] - D[j]);
            if(maxNum > temp){ 
                maxNum = temp; 
                ans = j+1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long x;
  cin >> x;
  if(x%11==0){
    cout << x/11*2 << endl;
  }
  else if(x%11<=6){
    cout << x/11*2+1 << endl;
  }
  else{
    cout << x/11*2+2 << endl;
  }
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int x[N + 3], y[M + 3];
    repi(i, 0, N)
    {
        cin >> x[i];
    }
    repi(i, 0, M)
    {
        cin >> y[i];
    }
    sort(x, x + N);
    sort(y, y + M);
    int flag = 0;
    for (int i = X + 1; i <= Y; i++)
    {
        if (i > x[N - 1] && i <= y[0])
        {
            flag = 1;
        }
    }
    if (flag == 1)
    {
        cout << "No War";
    }
    else
    {
        cout << "War";
    }
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

int n;
int ans = 0;

int main() {
  cin >> n;

  ans = 24 + (24-n);

  cout << ans << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int d[N];
    for(int i =0; i < N; i++){
        cin >> d[i];
    }
    int sum = 0;
    for(int i =0; i < N -1; i++){
        for(int j = i + 1; j < N; j++){
            sum += d[i]*d[j];
        }
    }
    cout << sum << endl;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    mint a = 10;
    a = a.pow(N);

    mint b = 9;
    mint bb = 2;
    b = bb * b.pow(N);

    mint c = 8;
    c = c.pow(N);

    cout << a - b + c << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define LL long long
#define lc (x << 1)
#define rc (x << 1 | 1)
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

int n, m, top, idx, dfn_idx, cnt_scc;
int id[N], cor[N], dfn[N], low[N];
int bel[N], s[N], ins[N], st[N];
pair<int, int> c[N];

std::vector<int> v[N];

struct node {int x, p;} a[N];

int cmp(const node &a, const node &b) {return a.x < b.x;}

void addedge(int x, int y) {v[x].push_back(y);}

void build(int x, int l, int r) {
	id[x] = ++idx;
	v[id[x]].clear();
	if (l == r) {
		addedge(id[x], cor[l]);
		return;
	}
	int m = (l + r) >> 1;
	build(lc, l, m);
	build(rc, m + 1, r);
	addedge(id[x], id[lc]);
	addedge(id[x], id[rc]);
}

void modify(int x, int l, int r, int s, int t, int p) {
	if (s <= l && r <= t) {addedge(p, id[x]); return;}
	int m = (l + r) >> 1;
	if (s <= m) modify(lc, l, m, s, t, p);
	if (m < t) modify(rc, m + 1, r, s, t, p);
}

void tarjan(int x) {
	dfn[x] = low[x] = ++dfn_idx;
	ins[x] = 1; st[++top] = x;
	for (int i = 0; i < v[x].size(); i++) {
		int y = v[x][i];
		if (!dfn[y]) {
			tarjan(y);
			low[x] = min(low[x], low[y]);
		} else if (ins[y]) low[x] = min(low[x], dfn[y]);
	}
	if (dfn[x] == low[x]) {
		int p; cnt_scc++;
		do {
			p = st[top--];
			bel[p] = cnt_scc;
			ins[p] = 0;
		} while (p != x);
	}
}

int check(int d) {
	idx = 2 * n;
	build(1, 1, 2 * n);
	for (int i = 1; i <= 2 * n; i++) {
		v[i].clear();
		int pl = upper_bound(s + 1, s + 2 * n + 1, s[i] - d) - s;
		int pr = lower_bound(s + 1, s + 2 * n + 1, s[i] + d) - s; pr--;
		if (pl <= i - 1) modify(1, 1, 2 * n, pl, i - 1, i);
		if (i + 1 <= pr) modify(1, 1, 2 * n, i + 1, pr, i);
	}
	cnt_scc = dfn_idx = 0;
	for (int i = 1; i <= idx; i++) dfn[i] = 0;
	for (int i = 1; i <= 2 * n; i++) if (!dfn[i]) tarjan(i);
	for (int i = 1; i <= 2 * n; i++) if (bel[i] == bel[cor[i]]) return 0;
	return 1;
}

int main() {
	read(n);
	for (int i = 1; i <= n; i++) {
		read(a[2 * i - 1].x), read(a[2 * i].x);
		a[2 * i - 1].p = i; a[2 * i].p = i;
	}
	sort(a + 1, a + 2 * n + 1, cmp);
	for (int i = 1; i <= n; i++) c[i] = make_pair(0, 0);
	for (int i = 1; i <= 2 * n; i++) {
		int x = a[i].p;
		if (!c[x].first) c[x].first = i;
		else c[x].second = i;
		s[i] = a[i].x;
	}
	for (int i = 1; i <= n; i++) {
		cor[c[i].first] = c[i].second;
		cor[c[i].second] = c[i].first;
	}
	//for (int i = 1; i <= 2 * n; i++) printf("%d ", s[i]); printf("\n");
	//for (int i = 1; i <= n; i++) printf("%d %d\n", c[i].first, c[i].second);
	//for (int i = 1; i <= 2 * n; i++) printf("%d ", cor[i]); printf("\n");
	int l = 0, r = a[2 * n].x, ans = 0;
	while (l <= r) {
		m = (l + r) >> 1;
		if (check(m)) {
			ans = m;
			l = m + 1;
		} else r = m - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    LL n,k;

    void solve(){
        cin >> n >> k;
        LL ans = 0;
        for(int i=k+1; i<=n; ++i){
            ans+= n/i*(i-k);
            ans+= max(0ll,n%i-k+1);
        }
        if(k==0)ans-=n;
        cout<< ans <<"\n";
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    Problem::Solver sol;
    sol.solve();
    Problem::Writer::write();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstdlib> 
#include<fstream> 
using namespace std;
int n,m,k;
int num=0;
int main(){
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i*m+j*n-2*i*j==k){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    from builtins import int, map, list, print, sorted
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, C = sorted(input_number_list())
    ans = 0
    isOK = True
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        a = A / 2
        b = B / 2
        c = C / 2
        tA = b + c
        tB = a + c
        tC = a + b
        tA, tB, tC = sorted([tA, tB, tC])
        if tA == A and tB == B and tC == C:
            isOK = False
            break
        A = tA
        B = tB
        C = tC
        ans += 1
    print([-1, ans][isOK])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import copy

if __name__ == '__main__':

	while True:
		n = int(input())
		if n == 0:
			break

		line = list(map(int,input().split()))
		num = len(line)

		ans = copy.deepcopy(line)
		tmp = [0]*num
		cnt = 0

		for i,j in enumerate(ans):
			tmp[i] = line.count(j)

		while True:
			if ans == tmp:
				print(cnt)
				print(*ans)
				break
			else:
				ans = copy.deepcopy(tmp)
				for i,j in enumerate(ans):
					tmp[i] = ans.count(j)

				cnt += 1




Measured memory_bytes: 6336
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
if (N-1) % 2 == 0:
    ans = sum(A[1:(N-1)//2]) * 2 + A[0] + A[(N-1) // 2]
else:
    ans = A[0] + sum(A[1:N // 2 ]) * 2
print(ans)

Measured memory_bytes: 31436