akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int N,M;
vector < ll > a;
vector < int > x,y;
vector < pair < ll,int > > order;

struct UnionFind {

    vector < int > node;
    UnionFind(int n) : node(n, -1) {}

    bool unite(int x, int y) {
        x = root(x); 
        y = root(y);
        if (x != y) {
            if (node[y] < node[x]) swap(x, y);
            node[x] += node[y]; 
            node[y] = x;
        }
        return x != y;
    }

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

    int root(int x) {
        return node[x] < 0 ? x : node[x] = root(node[x]);
    }

    int size(int x) {
        return -node[root(x)];
    }
    
};

int connect_cnt;
UnionFind inst(100010);

bool check (int x) {
    map < int,int >  cnt;
    REP(i,x + 1) {
        int idx = order[i].second;
        cnt[inst.root(idx)]++;
    }
    if (cnt.size() != connect_cnt) return false;

    int ret = 0;
    for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
        ret += itr -> second; 
    }
    if (ret >= (connect_cnt - 1) * 2) return true;
    return false;
}

int main() {

    cin >> N >> M;
    a.resize(N);
    x.resize(M);
    y.resize(M);
    REP(i,N) cin >> a[i];
    REP(i,M) cin >> x[i] >> y[i];

    REP(i,M) inst.unite(x[i], y[i]);

    REP(i,N) order.push_back(make_pair(a[i], i));
    sort(order.begin(), order.end()); 

    set < int > cnt;
    REP(i,N) cnt.insert(inst.root(i));
    connect_cnt = (int) cnt.size();

    if (connect_cnt == 1) {
        cout << 0 << endl;
        return 0;
    }

    if ((connect_cnt - 1) * 2 > N) {
        cout << "Impossible" << endl;
        return 0;
    }

    int l = -1, r = N - 1;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (check(mid)) r = mid;
        else l = mid;
    }

    l = r;

    /******/
    ll sum = 0;
    vector < ll > ans;
    set < int > used;
    REP(i, l + 1) {
        int idx = order[i].second;
        if (used.find(inst.root(idx)) == used.end()) {
            used.insert(inst.root(idx));
            sum += order[i].first;
        } else {
            ans.push_back(order[i].first);
        }
    }
    
    REP(i, connect_cnt - 2) {
        sum += ans[i];
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 8944
#include<stdio.h>

#define M 500005

int n;

int l(int c){
  return c*2;
}

int r(int c){
  return c*2 + 1;
}

void maxHeapify(int *H,int i){
  int lk,rk,lar,temp;

  lk = l(i);
  rk = r(i);

  if((lk <= n) && (H[lk] > H[i])) lar = lk;
  else lar = i;
  if((rk <= n) && (H[rk] > H[lar])) lar = rk;

  if(lar != i){
    temp = H[i];
    H[i] = H[lar];
    H[lar] = temp;
    maxHeapify(H,lar);
  }
}

void buildMaxHeap(int *H){
  int i;
  
  for(i=n/2; i>0; i--) maxHeapify(H,i);
}

int main(){
  int i;
  int H[M];

  scanf("%d",&n);

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

  buildMaxHeap(H);

  for(i=1; i<=n; i++){
    printf(" %d",H[i]);
  }

  printf("\n");
  
  return 0;
}



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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define ve vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

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

Measured memory_bytes: 3668
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] input = new int[n];
		for(int i=0; i<n; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		int max = 0;
		for(int i=1; i<=k; i++) {
			max += input[n-i];
		}
		System.out.println(max);;
	}
}

Measured memory_bytes: 21716
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n-1)]
m = int(input())
uv = [list(map(int,input().split())) for _ in range(m)]

from collections import deque

links = [[] for _ in range(n+1)]
for ind,val in enumerate(ab):
    a,b = val
    links[a].append((ind,b))
    links[b].append((ind,a))

def bfs(start,end):
    parent = [[-1,-1] for _ in range(n+1)]
    d = deque()
    d.append(start)
    done = set()
    while(d):
        tmp = d.popleft()
        done.add(tmp)
        for i in links[tmp]:
            link_ind, j = i
            if(not j in done):
                parent[j] = [tmp,link_ind]
                d.append(j)
    route = []
    while(True):
        route.append(parent[end][1])
        end = parent[end][0]
        if(end == start):
            break
    return route[::-1]

links_key = [0] * (n-1)
for i,se in enumerate(uv):
    start,end = se
    route = bfs(start,end)
    for j in route:
        links_key[j] =(links_key[j] | 1<<i)

dp = [[0] * (2**m) for _ in range(n)]
dp[0][0] = 1

for i in range(n-1):
     for j in range(2**m):
         dp[i+1][j] += dp[i][j]
         dp[i+1][(j|links_key[i])] += dp[i][j]

print(dp[-1][-1])

Measured memory_bytes: 445208
N = int(input())
A = list(map(int,input().split()))
sm = sum(A)

for i in range(1,N):
    A[i] += A[i-1]

ans = float('inf')

for a in A[:-1]:
    if ans > abs(2*a - sm):
        ans = abs(2*a - sm)

print(ans)

Measured memory_bytes: 23800
#include<cstdio>
using namespace std;
int ans;
bool bo(int x)
{
	int xx=0;
	for(int i=1;i<=x;++i)
	if(x%i==0)
		++xx;
	if(xx==8)
		return true;
	else
		return false;
}
int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i+=2)
	if(bo(i))
		++ans;
	printf("%d",ans);
	return 0;
}

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

int main(){
    int m;
    cin >> m;
    if(m >= 64)cout << 64 << endl;
    else if(m >= 32)cout << 32 << endl;
    else if(m >= 16)cout << 16 << endl;
    else if(m >= 8)cout << 8 << endl;
    else if(m >= 4)cout << 4 << endl;
    else if(m >= 2)cout << 2 << endl;
    else cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

char let[] = "MARCH";
char str[20];
ll cnt[6];
int n;

int main () {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf(" %s", str);
		for (int j = 0; j < 5; j++)
			if (str[0] == let[j])
				cnt[j]++;
	}

	ll res = 0;
	for (int i = 0; i < 5; i++) for (int j = i+1; j < 5; j++) for (int k = j+1; k < 5; k++)
		res += cnt[i]*cnt[j]*cnt[k];
	printf("%lld\n", res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  int x;
  x = (a+b)/2;
  double X;
  double A = a;
  double B = b;
  X = (A+B)/2;
  
  double changex = x;
  
  double different;
  different = X - changex;
  
  double plus;
  plus = different *2;
    
  cout << x+plus << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[6]:


N = int(input())
A = list(map(int, input().split()))


# In[7]:


f = 0
height = 0
for a in A:
    if height >= a:
        f += height - a
    else:
        height = a
print(f)


# In[ ]:






Measured memory_bytes: 32372
import sys

sys.setrecursionlimit(10 ** 9)
if __name__ == '__main__':
    n = int(input())
    tree = [[] for i in range(n)]
    for i in range(n - 1):
        a, b = map(int, input().split())
        tree[a - 1].append([b - 1, i])

    ans = 0
    for i in tree:
        ans = max(ans, len(i))

    ans = [0] * (n - 1)


    def solve(cur_index, color):
        cnt = 1

        for to, j in tree[cur_index]:
            if cnt == color:
                cnt += 1
            ans[j] = cnt
            solve(to, cnt)
            cnt += 1


    solve(0, 0)
    print(max(ans))
    print(*ans, sep="\n")

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

int main(){
  int n;
  cin >> n;
  ll x = 1;
  vector<ll> t(n), a(n);
  rep(i, n) {
    cin >> t[i] >> a[i];
  }
  for(int i = 1; i < n; ++i) {
    x = max((a[i - 1] * x + a[i] - 1) / a[i], (t[i - 1] * x + t[i] - 1) / t[i] );
  }
  cout << x * t[n - 1] + x * a[n - 1] << endl;


}

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  
  char c='s';
  string cc="es";
  int len=s.size();
  
  if(s[len-1]!='s'){
    s+=c;
  }
  if(s[len-1]=='s'){
    s+=cc;
  }
  
    cout << s;
}


Measured memory_bytes: 3628
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace tmnfipc2020
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_tmnfipc2020A();
            Console.Out.Flush();
        }

        public static void solve_tmnfipc2020B()
        {
        }

        public static void solve_tmnfipc2020A()
        {
            Console.WriteLine(Console.ReadLine().Substring(0, 3));
        }
    }
}

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


void solve(long long W, long long a, long long b){
    if(a > b) swap(a, b);
    cout << max(b - a - W, 0LL) << endl;
}

int main(){
    long long W;
    scanf("%lld",&W);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(W, a, b);
    return 0;
}


Measured memory_bytes: 256
H, W, M = map(int, input().split())
row = [0]*H  # 行
column = [0]*W  # 列

target = set()
for _ in range(M):
    # h行, w列に爆破対象がある
    h, w = map(lambda x: int(x)-1, input().split())
    row[h] += 1
    column[w] += 1
    target.add((h, w))

max_row_value = max(row)
max_column_value = max(column)
max_row_idx = []
max_column_idx = []

for i in range(H):
    if row[i] == max_row_value:
        max_row_idx.append(i)
for j in range(W):
    if column[j] == max_column_value:
        max_column_idx.append(j)

# なければ出力して即終了
# print(max_row_idx)
# print(max_column_idx)
# print(target)
for r in max_row_idx:
    for c in max_column_idx:
        if (r, c) not in target:
            # この式がFalseになるのは，(r, c)に爆発対象があるときのみ，それはたかだか10**5回程度
            # 必ず上記の条件式がTrueになるときがくる
            # (r, c) in targetがTrueになるのは10**5回程度なので！
            print(max_row_value+max_column_value)
            exit()

print(max_row_value+max_column_value-1)


Measured memory_bytes: 177204
/*
  AtCoder Beginner Contest 082
  D - FT Robot
*/

#include<iostream>
#include<string>
#include<vector>
using namespace std;

string s;
int x, y;
vector<int> xs, ys;
vector<vector<bool>> dpx, dpy;

int main() {
  cin >> s;
  cin >> x >> y;

  int l = s.length();

  // x軸とy軸を独立に考えることができる
  int buf = 0;
  bool dir = true; // true: x, false: y
  for (int i = 0; i < l; ++i) {
    if (s[i] == 'T') {
      if (dir) xs.push_back(buf);
      else ys.push_back(buf);

      dir = !dir;
      buf = 0;
    }
    else {
      buf += 1;
    }
  }

  if (buf != 0) {
    if (dir) xs.push_back(buf);
    else ys.push_back(buf);
  }

  // 各軸ごとにDPをする
  dpx = vector<vector<bool>>(xs.size() + 1, vector<bool>(2 * l + 1, false));
  dpx[1][l + xs[0]] = true;
  for (int i = 1; i < xs.size(); ++i) {
    for (int p = 0; p <= 2 * l; ++p) {
      if (dpx[i][p]) {
        dpx[i + 1][p + xs[i]] = true;
        dpx[i + 1][p - xs[i]] = true;
      }
    }
  }

  dpy = vector<vector<bool>>(ys.size() + 1, vector<bool>(2 * l + 1, false));
  dpy[0][l] = true;
  for (int i = 0; i < ys.size(); ++i) {
    for (int p = 0; p <= 2 * l; ++p) {
      if (dpy[i][p]) {
        dpy[i + 1][p + ys[i]] = true;
        dpy[i + 1][p - ys[i]] = true;
      }
    }
  }

  if (dpx[xs.size()][x + l] && dpy[ys.size()][y + l]) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 16128
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := a + b/2
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        String s = sc.next();
        char s1[] = s.substring(0, n).toCharArray();
        char s2[] = new StringBuilder(s.substring(n, 2 * n)).reverse().toString().toCharArray();

        Map<String, Long> map1 = new HashMap<>();
        Map<String, Long> map2 = new HashMap<>();
        for (int i = 0; i < (1 << n); i++) {
            StringBuilder red1 = new StringBuilder();
            StringBuilder blue1 = new StringBuilder();
            StringBuilder red2 = new StringBuilder();
            StringBuilder blue2 = new StringBuilder();
            for (int j = 0; j < n; j++) {
                if ((i >> j) % 2 == 1) {
                    red1.append(s1[j]);
                    blue2.append(s2[j]);
                } else {
                    blue1.append(s1[j]);
                    red2.append(s2[j]);
                }
            }

            String key1 = red1.toString() + ":" + blue1.toString();
            map1.compute(key1, (k, v) -> v == null ? 1 : v + 1);
            String key2 = red2.toString() + ":" + blue2.toString();
            map2.compute(key2, (k, v) -> v == null ? 1 : v + 1);
        }

        long sum = 0;
        for (Map.Entry<String, Long> entry : map1.entrySet()) {
            String key = entry.getKey();
            sum += entry.getValue() * map2.getOrDefault(key, 0L);
        }
        System.out.println(sum);
    }

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


Measured memory_bytes: 157456
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	c := make([][]int, 3)
	c[0], c[1], c[2] = iSScan(3), iSScan(3), iSScan(3)
	f := false
	for i := 0; i <= c[0][0]; i++ {
		for j := 0; j <= c[1][0]; j++ {
			for k := 0; k <= c[2][0]; k++ {
				p, q, r := c[0][0]-i, c[1][1]-j, c[2][2]-k
				if c[0][1] == i+q && c[0][2] == i+r {
					if c[1][0] == j+p && c[1][2] == j+r {
						if c[2][0] == k+p && c[2][1] == k+q {
							f = true
						}
					}
				}
			}
		}
	}
	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
import collections
N = int(input())
A = list(map(int,input().split()))
ans = sum(A)
d = collections.Counter(A)
Q = int(input())
for i in range(Q):
    B,C = map(int,input().split())
    b = d[B]
    ans = ans + (C-B)*b
    print(ans)
    d[B] = 0
    d[C] = d[C] + b

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

int main()
{
  // 入力
  int K;
  string S, Result;
  cin >> K >> S;
  
  if( K < S.size() )
  {
    Result = S.substr( 0, K );
    Result += "...";
  }
  else
  {
    Result = S;
  }
  cout << Result << endl;
  return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
SA = list(input())
SB = list(input())
SC = list(input())

# initialize
x = 'a'

while True:
    if x == 'a':
        if len(SA) == 0:
            print('A')
            exit()
        x=SA[0]
        SA.remove(x)
    elif x == 'b':
        if len(SB) == 0:
            print('B')
            exit()
        x=SB[0]
        SB.remove(x)

    else:
        if len(SC) == 0:
            print('C')
            exit()
        x=SC[0]
        SC.remove(x)


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n;cin>>n;
    V<ll>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int q;cin>>q;
    while(q--){
        int k;cin>>k;
        cout<<lower_bound(all(a),k)-a.begin()<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































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

int main(){
  string o, e;
  cin >> o >> e;
  int n = min(o.length(), e.length());
  rep(i, n){
    cout << o[i] << e[i];
  }
  if(o.length() > e.length()) cout << o[o.length() - 1];
  else if(o.length() < e.length())  cout << e[e.length() - 1];
  cout << endl;
}

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


def solve(tc):
    n = int(stdin.readline().strip())
    x = n / 1.08
    if int(math.floor(x)*1.08)==n:
        print(int(x))
        return
    if int(math.ceil(x)*1.08)==n:
        print(int(x+1))
        return
    print(":(")


LOCAL_TEST = not __debug__
if LOCAL_TEST:
    infile = __file__.split('.')[0] + "-test.in"
    stdin = open(infile, 'r')

tcs = (int(stdin.readline().strip()) if LOCAL_TEST else 1)
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Measured memory_bytes: 3064
k = int(input())

gcd_cnt = {}

for n in range(k, 0, -1):
    div_all = (k // n) ** 3
    div_dup = 0
    for m in range(n * 2, k + 1, n):
        div_dup += gcd_cnt[m]
    gcd_cnt[n] = div_all - div_dup

ans = 0
for gcd in gcd_cnt.keys():
    ans += gcd * gcd_cnt[gcd]

print(ans)


Measured memory_bytes: 8988
#include<cstdio>

using namespace std;

int a[10][10];

inline int Head(int x){
	int tail;
	while(x){
		tail = x % 10;
		x /= 10;
	}
	return tail;
}

inline int Tail(int x){
	return x % 10;
}

int main(){
	//freopen("in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		a[Head(i)][Tail(i)]++;
	}
	int res = 0;
	for(int i = 1;i <= 9;i++){
		for(int j = 1;j <= 9;j++){
			res += a[i][j] * a[j][i];
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long lint;

lint N;
const int MAX_N = 100005;
lint a[MAX_N],b[MAX_N];
lint s[MAX_N*2],cnt[MAX_N*2];

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

	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i];
		s[2*i] = a[i];
		s[2*i+1] = b[i];
	}
	sort(s,s+2*N);
	lint t;
	for(int i=0;i<N;i++){
		t = lower_bound(s,s+2*N,a[i]) - s;
		a[i] = t+cnt[t];
		cnt[t]++;
		t = lower_bound(s,s+2*N,b[i]) - s;
		b[i] = t+cnt[t];
		cnt[t]++;
	}

	for(int i=0;i<N;i++){
		if(b[i]==N-1){
			swap(a,b);
			break;
		}
	}

	lint sum = 0;
	for(int i=0;i<N;i++){
		sum += s[i];
	}

	bool ok = true;
	for(int i=0;i<N;i++){
		if(a[i]>=N){
			ok = false;
			break;
		}
	}

	if(ok){
		cout << sum << endl;
		return 0;
	}

	for(int i=0;i<N;i++){
		if(a[i]<N&&b[i]<N){
			ok = true;
			break;
		}
	}
	if(ok){
		cout << sum << endl;
		return 0;
	}

	ok = true;
	for(int i=0;i<N;i++){
		if(a[i]==N-1){
			if(b[i]==N){
				ok = false;
				break;
			}
		}
	}

	if(ok){
		cout << sum + s[N] - s[N-1] << endl;
		return 0;
	}

	cout << sum + min(s[N]-s[N-2],s[N+1]-s[N-1]) << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <numeric>

using namespace std;

int u[111];

typedef long long ll;
const int maxn = (int) 1e5 + 1;
const int inf = (int)1e9+7;


int a[maxn], b[111];

int cnt[maxn];

string s, t;

int ans = 0, sum1, sum2, sum3;

ll n, k;

int dp[maxn];

vector < ll > v, g;

ll now = 0;

bool isprime(ll x){
    for(ll i = 2; i <= sqrt(x); i++){
        if(x % i == 0){
            return 0;
        }
    }
    return 1;
}

ll GCD(ll u, ll v) {
    while ( v != 0) {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}
int main(){
    cin >> n >> k;
     now = GCD(n, k);
    for(ll i = 1; i <= sqrt(now); i++){
        if(now % i == 0){
            v.push_back(i);
            v.push_back(now / i);
        }
    }
    if(ll(sqrt(now)) * ll(sqrt(now)) == now)
        v.pop_back();
    sort(v.begin(), v.end());
    for(ll i : v)
        if(isprime(i)){
            ans++;
        }
    cout << ans;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};

bool solve(){
    int h,w,r,c;
    cin >> h >> w >> r >> c;
    if(h == 0) return false;

    vector<vector<vector<int>>> wall(h+2, vector<vector<int>>(w+2, vector<int>(4)));
    for(int i=0; i<2*h+1; i++){
        if(i%2 == 0){
            for(int j=0; j<w; j++){
                int c;
                cin >> c;
                wall[i/2][j+1][0] = wall[i/2+1][j+1][2] = c;
            }
        }else{
            for(int j=0; j<w+1; j++){
                int c;
                cin >> c;
                wall[i/2+1][j][1] = wall[i/2+1][j+1][3] = c;
            }
        }
    }

    vector<vector<bool>> win(h+2, vector<bool>(w+2, true));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            win[i][j] = false;
        }
    }
    queue<pair<int,int>> wait;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            for(int s=0; s<4; s++){
                for(int t=0; t<4; t++){
                    if(s == t) continue;
                    if(win[i+dy[s]][j+dx[s]] and win[i+dy[t]][j+dx[t]]){
                        wait.push({i, j});
                        break;
                    } 
                }
            }
        }
    }

    while(!wait.empty()){
        int y = wait.front().first;
        int x = wait.front().second;
        wait.pop();
        if(win[y][x]) continue;
        bool iswin = false;
        for(int s=0; s<4; s++){
            for(int t=0; t<4; t++){
                if(s == t) continue;
                if(wall[y][x][s] != wall[y][x][t] and
                        win[y+dy[s]][x+dx[s]] and win[y+dy[t]][x+dx[t]]){
                    iswin = true;
                }
            }
        }
        if(!iswin) continue;
        win[y][x] = true;
        for(int d=0; d<4; d++){
            if(!win[y+dy[d]][x+dx[d]]){
                wait.push({y+dy[d], x+dx[d]});
            }
        }
    }

    bool ans = win[r][c];
    for(int d=0; d<4; d++){
        ans = ans or (wall[r][c][d] == 0 and win[r+dy[d]][c+dx[d]]);
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return true;
}

int main(){
    while(solve()){}
    return 0;
}


Measured memory_bytes: 17004
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  long a,b,k;
  cin>>a>>b>>k;

  rep(i,k){
    b += a/2;
    a /= 2;
    swap(a,b);
  }

  if(k%2==1) swap(a,b);

  cout << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,a;
    scanf("%d %d",&i,&a);
    if (i>=0&&a>=0)
    if(i<=10&&a<=10)
        {
    if(i<a)
        printf("0\n");

    else if(i=a)
        printf("10\n");
    else
    printf("10\n");
    }
    return 0;
}

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

def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    adj = [[] for _ in range(N)]
    for i in range(M):
        A, B  = map(int, input().split())
        adj[A-1].append(B-1)
        adj[B-1].append(A-1)
    
    ans = 0
    for i in range(N):
        flag = True
        for u in adj[i]:
            if H[i] <= H[u]:
                flag = False
        if flag:
            ans += 1
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 29364
h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
ans = 0
for i in range(2 ** w):
    for j in range(2 ** h):
        a = format(i,"b").zfill(w)
        b = format(j,"b").zfill(h)
        cnt = 0
        for f in range(w):
            for g in range(h):
                if b[g] == "0" and a[f] == "0" and s[g][f] == "#":
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 9144
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  cin>>N>>H;
  cout<<N+H/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<numeric>
#include<iomanip>

using namespace std;
using ll = long long;

double dist(pair<int, int> p1, pair<int, int> p2) {
    int diffX = p1.first - p2.first;
    int diffY = p1.second - p2.second;
    return sqrt(diffX*diffX + diffY*diffY);
}

int main() {
    int n, x, y;
    cin >> n;
    vector<pair<int, int>> input;
    for (int i=0; i<n; ++i) {
        cin >> x >> y;
        input.push_back(make_pair(x, y));
    }
    vector<int> permu(n);
    iota(permu.begin(), permu.end(), 0);
    double sum = 0.0;
    int count = 0;
    do {
        for (int i=0; i<n-1; ++i) {
            double tempDist = dist(input[permu[i]], input[permu[i+1]]);
            sum += tempDist;
        }
        ++count;
    }while(next_permutation(permu.begin(), permu.end() ));
    cout << fixed << setprecision(8) << sum/count << endl;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll l, r, d;
    cin >> l >> r >> d;
    l--;
    cout << r / d - l / d << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>

#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll

using namespace std;
typedef long long ll;
typedef long double ld;

int a, b, c, d;
unordered_map<int, int> was;

int inf = 1e18;

int get_ans(int n);

int chk(int ans, int x1, int n, int add, int x) {
	if(abs(n - x1 * x) >= ans / d + x)
		return ans;
	int y = get_ans(x1);
	if(y > ans)
		return ans;
	return min(ans, y + add + abs(n - x1 * x) * d);
}

int get_ans(int n) {
	if(was.count(n))
		return was[n];
	if(n == 0) 
		return 0;
	int ans = inf;
	if(n <= inf / d)
		ans = d * n;
	int x1 = n / 2;
	ans = chk(ans, x1, n, a, 2);
	// ans = min(ans, get_ans(x1) + a + abs(n - x1 * 2) * d);
	if(x1 + 1 != n)
		ans = chk(ans, x1 + 1, n, a, 2);
		// ans = min(ans, get_ans(x1 + 1) + a + abs(n - (x1 + 1) * 2) * d);

	x1 = n / 3;
	// ans = min(ans, get_ans(x1) + b + abs(n - x1 * 3) * d);
	ans = chk(ans, x1, n, b, 3);
	if(x1 + 1 != n)
		ans = chk(ans, x1 + 1, n, b, 3);
		// ans = min(ans, get_ans(x1 + 1) + b + abs(n - (x1 + 1) * 3) * d);
	
	x1 = n / 5;
	ans = chk(ans, x1, n, c, 5);
	// ans = min(ans, get_ans(x1) + c + abs(n - x1 * 5) * d);
	if(x1 + 1 != n)
		ans = chk(ans, x1 + 1, n, c, 5);
		// ans = min(ans, get_ans(x1 + 1) + c + abs(n - (x1 + 1) * 5) * d);
	was[n] = ans;
	return ans;
}

signed main() {
	#ifdef PC
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while(t--) {
		int n;
		was.clear();
		cin >> n >> a >> b >> c >> d;
		cout << get_ans(n) << '\n';
	}


	return 0;
}

Measured memory_bytes: 4280
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

void ayush(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

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

ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
ll mulmod(ll a, ll b, ll mod) 
{ 
    ll res = 0; 
    a = a % mod; 
    while (b > 0) 
    { 
        if (b % 2 == 1) res = (res + a) % mod; 
        a = (a * 2) % mod; 
        b /= 2; 
    }  
    return res % mod; 
} 

int binarySearch(long long int arr[], int l, long long int r, long long int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        // If the element is present at the middle 
        // itself 
        if (arr[mid] == x) 
            return mid; 
  
        // If element is smaller than mid, then 
        // it can only be present in left subarray 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        // Else the element can only be present 
        // in right subarray 
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    // We reach here when element is not 
    // present in array 
    return -1; 
}

int main(){
    ayush();
    fastio;

    ll t; t=1;
    while(t--){
        ll n; cin>>n;
      	ll ans=pow(n,1)+pow(n,2)+pow(n,3);
        cout<<ans;
    }   
    return 0;
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
 

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

	ll N,ans=1;
	string S;
	cin >> N >> S;
	ll cnt[26]={};
	FOR(i,0,S.size()){
		cnt[S[i]-'a']++;
	}
	FOR(i,0,26){
		(ans*=cnt[i]+1)%=MOD;
	}
	ans = (ans-1+MOD)%MOD;
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;


int main(){
    ll z[3][100],n,K,in[50][6],c;
    ll ans=0;
    
    scanf("%lld%lld",&n,&K);
    
    for(int i=0;i<n;i++){
        for(int j=0;j<6;j++){
            scanf("%lld",&in[i][j]);
            z[j%3][i*2+(j/3)]=in[i][j];
        }
    }
    
    for(int i=0;i<3;i++)
        sort(z[i],z[i]+n*2);
    
    for(int i=0;i<n*2-1;i++)
        for(int j=0;j<n*2-1;j++)
            for(int k=0;k<2*n-1;k++){
                c=0;
                for(int l=0;l<n;l++){
                        c+=(in[l][0]<=z[0][i] && z[0][i+1]<=in[l][3] &&
                            in[l][1]<=z[1][j] && z[1][j+1]<=in[l][4] &&
                            in[l][2]<=z[2][k] && z[2][k+1]<=in[l][5]
                            );
                }
                if(c>=K){
                    ans+=(z[0][i+1]-z[0][i])*(z[1][j+1]-z[1][j])*(z[2][k+1]-z[2][k]);
                }
            }
    
    printf("%lld\n",ans);
    
    return 0;
}

Measured memory_bytes: 1208
// 復習
// cf.) https://atcoder.jp/contests/abc064/submissions/7474666

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

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

    int n; cin >> n;
    int wizard = 0;
    set<int> st;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        if (a >= 3200) wizard++;
        else st.insert(a / 400);
    }
    int colors = st.size();
    cout << (colors ? colors : 1) << " " << colors + wizard << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
    #define REP(i, n) FOR(i, 0, n)
    #define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
    #define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
    #define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
    #define fi first
    #define se second
    #define ll long long
    #define int long long
    #define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
     
    #define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
    #define dv(name, value) cerr << (name) << " is " << (value) << endl
    #define da(itr, v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl
     
    int gcd(int vEd, int vIng) {
      if (vEd % vIng == 0) {
        return vIng;
      }
     
      gcd(vIng, vEd % vIng);
    }
     
    signed main(){
      int K; cin >> K;
      int sum = 0;
     
      FOR(x, 1, K+1){
        FOR(y, 1, K+1){
          FOR(z, 1, K+1){
            sum += gcd(gcd(x, y), z);
          }
        }
      }
     
      cout << sum << endl;
    }

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	vector<string> S(3,"");
	rep (i, 3) cin >> S[i];

	int res = -1;	
	char hand = S[0][0];
	S[0] = S[0].substr(1);

	while(true){
		int n = (int)(hand - 'a');
		if (S[n].empty()){
			res = n;
			break;
		} // end if
		hand = S[n][0];
		S[n] = S[n].substr(1);
 	} // end while

	cout << (char)('A' + res) << endl;
	
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) cout << "a < b" << endl;
  else if (a > b) cout << "a > b" << endl;
  else cout << "a == b" << endl;

  return 0;
}


Measured memory_bytes: 3088
N, K = [int(a) for a in input().split()]

num_count = (N-N%K)//K
ans = min(abs(N - num_count*K), abs(N - (num_count+1)*K))
if num_count > 0:
    ans = min(abs(N - (num_count-1)*K), ans)
print(ans)

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

int main() {
    int W, H;
    while(1) {
        cin >> H >> W;
        if (H == 0){
            break;
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << "#";
            }
            cout << "\n";
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#define INF 1000000001

using namespace std;

int cnt=0;

void merge(int a[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++) L[i]=a[left+i];
  for(int i=0;i<n2;i++) R[i]=a[mid+i];
  L[n1]=INF; R[n2]=INF;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      a[k]=L[i];
      i++;
    }else{
      a[k]=R[j];
      j++;
    }
  }
}

void mergeSort(int a[],int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(a,left,mid);
    mergeSort(a,mid,right);
    merge(a,left,mid,right);
  }
}

int main(){
  int n; cin >> n;
  int s[n];
  for(int i=0;i<n;i++) cin >>s[i];
  mergeSort(s,0,n);
  for(int i=0;i<n;i++){
    if(i) cout <<" "<<s[i];
    else cout <<s[i];
  }
  cout << endl;
  cout << cnt << endl;
}

Measured memory_bytes: 6876
#pragma GCC optimize("O2")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<limits.h>
#include<ctime>
#define N 5000001
typedef long long ll;
const int inf=0x3fffffff;
const int maxn=2017;
using namespace std;
inline int read()
{
    int f=1,x=0;char ch=getchar();
    while(ch>'9'|ch<'0')
    {
        if(ch=='-')
        f=-1;
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return f*x;
}
int a[N],b[N];
map<ll,int>sum;
int main()
{
	int n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		sum[a[i]]++;
	}
	int k=read();
	for(int i=1;i<=k;i++)
	{
		b[i]=read();
		if(--sum[b[i]]<0)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 15616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	cin>>n>>m;
	int a[1000];
	int s=0;
	for(int i=0; i<n; i++){
		cin>>a[i]; s+=a[i];
	}
	int cnt=0;
	for(int i=0; i<n; i++){
		if(4*m*a[i]>=s) cnt++;
	}
	if(cnt>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	even := 0
	odd := 0
	for i := 1; i <= K; i++ {
		if i%2 == 0 {
			even++
		} else {
			odd++
		}
	}
	fmt.Println(even * odd)
}


Measured memory_bytes: 640