akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def func(As, x):
    ans = 0
    for a in As:
        ans += a ^ x
    return ans


def add_bit(bits, idx):
    ret = bits[:]
    ret[idx] = 1
    return ret


def arr_to_num(arr):
    num_str = ''.join([str(x) for x in arr])
    return int(num_str, 2)
    

def solve(N, K, As):
    if K == 0:
        return func(As, 0)

    best_x = 0
    IDX_MAX = 42
    idx = IDX_MAX
    bits = [0] * (idx + 1)
    while idx >= 0:
        if arr_to_num(add_bit(bits, IDX_MAX - idx)) > K:
            pass
        else:
            one = 0
            zero = 0
            for a in As:
                if a & (1 << idx): one += 1
                else: zero += 1
            if one >= zero:
                bits[IDX_MAX - idx] = 0
            else:
                bits[IDX_MAX - idx] = 1
        idx -= 1

    best_x = arr_to_num(bits)
    return func(As, best_x)


N, K = map(int, input().split())
As = list(map(int, input().split()))
print(solve(N, K, As))



    





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

int main(){
    int x, y;
    cin >> x >> y;
    if(x < y) cout << min(y - x, abs(x + y) + 1) << endl;
    else cout << min(abs(x + y) + 1, abs(x - y) + 2) << endl;

    return 0;
}

Measured memory_bytes: 256
package main
 
import (
	"sort"
	"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()
	h := scanInt()
 
	a := make([]int, n)
	maxa := 0
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
		maxa = max(maxa, a[i])
		b[i] = scanInt()
	}

	sort.Ints(b)

	c := 0
	for i := 0; i < n; i++ {
		if maxa > b[n-1-i] {
			break
		}

		h -= b[n-1-i]
		c++

		if h <= 0 {
			h = 0
			break
		}
	}

	fmt.Fprintln(wr, c+(h+maxa-1)/maxa)
 
}


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

class Shop {
 public:
  ll price;
  int maxnum;
  bool operator < (const Shop &s) const {
    return price < s.price;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  Shop shop[N];
  for (int i = 0; i < N; i++) {
    cin >> shop[i].price >> shop[i].maxnum;
  }
  sort(shop, shop+N);
  int i = 0;
  ll min_price = 0;
  while (true) {
    if (M > shop[i].maxnum) {
      M -= shop[i].maxnum;
      min_price += shop[i].maxnum * shop[i].price;
    } else {
      min_price += M * shop[i].price;
      break;
    }
    i++;
  }
  cout << min_price << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int a, b;

	std::cin >> a >> b;

	if (b == 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	if (b <= a) {
		std::cout << 1 << std::endl;
		return 0;
	}

	b -= a;

	int count = 1;
	while (b > 0) {
		b++;
		b -= a;
		count++;
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
let (>>=) xs f = List.map f xs |> List.concat
let rec replicate_m n xs =
  if n <= 0 then [[]]
  else replicate_m (n-1) xs >>= fun xs' -> List.map (fun y -> y :: xs') xs

let () =
  Scanf.scanf "%d" @@ fun n ->
  let f = Array.init n (fun _ -> Array.init 10 (fun _ -> Scanf.scanf " %d" ((=) 1))) in
  let p = Array.init n (fun _ -> Array.init 11 (fun _ -> Scanf.scanf " %d" (fun x -> x))) in
  replicate_m 10 [false; true] |> List.tl
  |> List.map (fun scheds ->
      f |> Array.mapi (fun i scheds' ->
        let dups =
          scheds |> List.mapi (fun j v -> if v && scheds'.(j) then 1 else 0)
          |> List.fold_left (+) 0
        in p.(i).(dups))
      |> Array.fold_left (+) 0)
  |> List.fold_left max (-10101010101010)
  |> Printf.printf "%d\n"

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N, M; cin >> N >> M;

    vector<int> H(N);
    rep(i, N) cin >> H[i];

    vector<int> is_ng(N);
    rep(i, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (H[a] <= H[b]) {
            is_ng[a] += 1;
        }
        if (H[a] >= H[b]) {
            is_ng[b] += 1;
        }
    }
    int ans = 0;
    rep(i, N) {
        if (is_ng[i] == 0) {
            ans += 1;
        }
    }

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

Measured memory_bytes: 3988
fn a() {
    input!{
        n: u32
    }

    println!("{}", match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        _ => "bon"
    });
}

use proconio::{input};

fn main() {
    a();
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

int main()
{
      
         int n,l[10000],i,j=1,k,d[200005];
         cin>>n>>k;
         for(i=0;i<n;i++)   cin>>l[i];
         d[0]=0;
         for(i=1;i<=n;i++){
             d[i]=d[i-1]+l[i-1];
             if(d[i]<=k)
                j++;
           // cout<<d[i];
         }
         cout<<j;
         
    
}

Measured memory_bytes: 256
import kotlin.math.abs

fun main() {
    c()
}

fun a() {
    val s = readLine()!!
    fun aa(): Int {
        if (s == "RRR") return 3
        if (s.take(2) == "RR" || s.takeLast(2) == "RR") return 2
        if (s.any { it == 'R' }) return 1
        return 0
    }
    aa().toLong().print()
}

fun b() {
    val N = readLong()
    val L = readLongList().sorted()
    var ans = 0L
    L.forEachIndexed { i, l ->
        L.drop(i + 1).forEachIndexed { j, m ->
            L.drop(i + j + 2).forEachIndexed { k, n ->
                if (l + m > n) {
                    if (l != m && l != n && m != n) {
                        ans++
                    }
                }
            }
        }
    }
    ans.print()
}

fun c() {
    val (_X, K, D) = readLongList()
    val X = abs(_X)
    if (X / D >= K) {
        (X - D * K).print()
    } else {
        val rem = K - X / D
        if (rem % 2 == 0L) {
            (X % D).print()
        } else {
            (D - X % D).print()
        }
    }

}

fun readLong() = readLine()!!.toLong()
fun readLongList() = readLine()!!.split(" ").map { it.toLong() }

fun Long.bitEach(action: (Int) -> Unit) {
    (0 until Long.SIZE_BITS).forEach { action(((this shr it) and 1).toInt()) }
}

fun Long.bitFilter(bit: Int) = (0 until Long.SIZE_BITS).filter { ((this shr it) and 1) == 1L }

fun <T1, T2> pairs(first: Iterable<T1>, second: Iterable<T2>) = first.flatMap { t1 -> second.map { t2 -> t1 to t2 } }

fun Long.primeSequence() = sequence<Long> {
    var n = this@primeSequence
    if (n % 2L == 0L) {
        yield(2L)
        n /= 2L
    }
    var i = 3L
    while (n > 0) {
        if (n % i == 0L) {
            yield(i)
            n /= i
        }
        i += 2L
    }
}

fun Long.print() {
    println(this)
}

Measured memory_bytes: 36388
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

int Cnt[xx + 10];

signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int n , k;
  cin >> n >> k;
  vector<int>a(n);
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }

  for(int j = 0;j < 50 && k ;j++){

    for(int i=0;i<n;i++){
      int l = max(0ll , i - a[i]);
      int r = min(n-1 , i + a[i]);
      Cnt[l]++;
      Cnt[r+1]--;
    }
    for(int i=1;i < n;i++){
      Cnt[i] += Cnt[i-1];
    }
    for(int i=0;i<n;i++){
      a[i] = Cnt[i];
    }
    clr(Cnt);
    k--;
    dg(a);
  }
  for(int i=0;i < n;i++){
    cout << a[i] <<" \n"[i == n-1];
  }
}

Measured memory_bytes: 5964
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    d = deque(['a'])
    while len(d[0])<N:
        s = d.popleft()
        diff = ord(max(s)) - ord('a')
        for i in range(diff+2):
            x = ord('a')
            d.append(s+chr(x+i))
    while len(d)!=0:
        print(d.popleft())

if __name__ == '__main__':
    main()


Measured memory_bytes: 11868
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main() {
  
    int n,m ;
    cin>>n>>m ;

    int a[n],b[n] ;
    int 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 tmp = 900000000 ;
        int ans = 0 ;
        for (int j = 0; j < m; j++)
        {
            if((abs(a[i]-c[j])+abs(b[i]-d[j]))<tmp){
                tmp = abs(a[i]-c[j])+abs(b[i]-d[j]) ;
                //cout << abs(a[i]-c[j])+abs(b[i]-d[j]) << endl ;
                ans = j+1 ;
            } 
        }        
        cout << ans << endl ;
    }
    
  return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    vector<vector<int>> c(3, vector<int>(3));
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> c[i][j];
        }
    }
    
    for(int x = -300; x <= 300; ++x){
        for(int y = -300; y <= 300; ++y){
            for(int z = -300; z <= 300; ++z){
                bool flag = true;
                for(int i = 0; i < 3; ++i){
                    if((c[0][i] - x != c[1][i] - y) || (c[1][i] - y != c[2][i])){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 256
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    a = numinput()
    a.sort()
    print('%d %d %d' % (a[0], a[1], a[2]))

if __name__ == "__main__":
    main()



Measured memory_bytes: 5596
#include <cstdio>

int main (){
    int N,M,C;
    scanf("%d %d %d",&N,&M,&C);
    int b[M];
    for (int i = 0; i < M; i++){
        scanf("%d",&b[i]);
    }
    int a[M][N];
    for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
        scanf("%d",&a[j][i]);
    }
    }
    int count=0;
    int point;
    for (int i = 0; i < N; i++){
        point=0;
        for (int j = 0; j < M; j++){
            point+=b[j]*a[j][i];
        }
        if(point+C>0) count++;
    }
    printf("%d",count);
}

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

vector<int> rotate(vector<int> num, int a, int b, int c, int d){
    tmp = num[a]; 
    num[a] = num[b]; 
    num[b] = num[c]; 
    num[c] = num[d]; 
    num[d] = tmp;
    return num;
}
  
int main(){
  vector<int> num(6);
  string q;
  int i;
  for(i = 0; i < 6; i++)scanf("%d", &num[i]);
  cin >> q;
  for(i = 0; i < q.size(); i++){
    if(q[i] == 'N') num = rotate(num, 0, 1, 5, 4);
    else if(q[i] == 'S') num = rotate(num, 0, 4, 5, 1);
    else if(q[i] == 'E')num = rotate(num, 0, 3, 5, 2);
    else num = rotate(num, 0, 2, 5, 3);
  }
  printf("%d\n", num[0]);
}


Measured memory_bytes: 3308
fun main() {
    val (n, mw) = readLine()!!.split(' ').map { it.toInt() }
    val xs = (0 until n).map {
        val (w, v) = readLine()!!.split(' ').map { it.toInt() }
        w to v
    }

    val w0 = xs[0].first

    val map = Array(4) { mutableListOf<Int>() }
    for (i in 0 until n) {
        val j = xs[i].first - w0
        val v = xs[i].second
        map[j].add(v)
    }

    for (i in 0 until 4) {
        map[i].sortDescending()
    }

    fun dfs(cur: Int, tw: Int, tv: Int): Int {
        if (cur == 4) return tv

        var w = tw
        var v = tv

        var r = dfs(cur + 1, w, v)

        for (i in map[cur].indices) {
            if (w + w0 + cur > mw) break
            w += w0 + cur
            v += map[cur][i]
            r = r.coerceAtLeast(dfs(cur + 1, w, v))
        }

        return r
    }

    println(dfs(0, 0, 0))
}


Measured memory_bytes: 39264
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int n , a , b;
    cin >> n >> a >> b ;
    if(a + b - 1 > n){
        cout << -1;
        return ;
    }
    
    if(b == 1){
        if(a != n){
            cout << -1;
        }else{
            rep(i , n) cout << i + 1 << ' ';
        }
        return ;
    }

    vector<int> v(b, 1);
    v[0] = a ;
    int idx = 0 , cur = a + b;
    while(cur <= n){
        v[1 + idx]++;
        if(v[1 + idx] > a){
            cout << -1;
            return; 
        }
        cur++;
        idx = (idx + 1) % (b - 1);
    }
    cur = n ;
    rep(i , b){
        vector<int> tmp;
        rep(_ , v[i]) tmp.pb(cur--);
        reverse(all(tmp));
        trav(x , tmp) cout << x << ' ' ;
    }
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 6452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N;
  M = 0;
  
  for (int i = 1; i <= N; i += 2){
    int a;
    a = 0;
    
    for (int j = 1; j <= i; j++){
      if (i % j == 0)
        a++;
    }
    if(a == 8)
      M++;
  }
  cout << M << endl;
}

Measured memory_bytes: 256
n=input()
k=int(input())
m=len(n)

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

dp[0][0][0]=1
for i in range(m):
  keta=int(n[i])
  for j in range(3):
    dp[i+1][j+1][1]+=9*dp[i][j][1]
    dp[i+1][j][1]+=dp[i][j][1]
    
    if keta>0:
      dp[i+1][j+1][1]+=dp[i][j][0]*(keta-1)
      dp[i+1][j][1]+=dp[i][j][0]
      dp[i+1][j+1][0]+=dp[i][j][0]
    else:
      dp[i+1][j][0]+=dp[i][j][0]
      
  dp[i+1][3][1]+=dp[i][3][1]
  dp[i+1][3][keta>0]+=dp[i][3][0]
print(dp[m][k][0]+dp[m][k][1])

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N+1);
	int i, j;
	A[0] = 0;
	for(i = 1; i < N + 1; i++) {
		cin >> A[i];
	}
	A.push_back(0);
	int l = 0, money = 0, m;
	for(i = 0; i < N + 1; i++) {
		money += abs(A[i] - A[i + 1]);
	}
	m = money;
	for(i = 1; i < N + 1; i++) {
		money -= abs(A[i] - A[i - 1]);
		money -= abs(A[i + 1] - A[i]);
		money += abs(A[i + 1] - A[i - 1]);
		cout << money << endl;
		money = m;
	}
}


Measured memory_bytes: 1656
n, m = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i).sort!

dists = (m - 1).times.with_object(Array.new(m - 1, 0)) do |i, a|
  a[i] = xs[i + 1] - xs[i]
end

puts xs.last - xs.first - (dists.max(n - 1).inject(:+) || 0)


Measured memory_bytes: 10480
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    System.out.println(Math.min(N * A, B));
    sc.close();
  }
}


Measured memory_bytes: 23764
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int x) {
        int N = 1000 * 1000;
        vector<bool> isPrime(N, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i < N; ++i) {
            if (isPrime[i]) {
                for (int j = i + i; j < N; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        for (int i = x; i < N; ++i) {
            if (isPrime[i]) {
                return i;
            }
        }
        return -1;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int x;
    cin >> x;
    Solution sol;
    cout << sol.solve(x) << "\n";

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


/////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int n;
    cin >> n;
    vector<int> x(n),y(n),h(n);
    ll X,Y,HH;
    tuple<ll,ll,ll> t;
    for (int i = 0;i < n;i++){
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] >= 1){
            t = make_tuple(x[i],y[i],h[i]);
        }
    }

    ll cnt = 0;
    for (int cx = 0;cx <= 100;cx++){
        for (int cy = 0;cy <= 100;cy++){
            ll H = get<2>(t) + abs(cx - get<0>(t)) + abs(cy - get<1>(t));
            H = max(H,0LL);
            bool flag = true;
            for (int i = 0;i < n;i++){
                ll V = H - abs(x[i] - cx) - abs(y[i] - cy);
                V = max(V,0LL);
                if (V != h[i]){
                    flag = false;
                    break;
                }
            }
            if (flag){
                X = cx;
                Y = cy;
                HH = H;
                cnt++;
            }
        }
    }
    if (cnt == 1){
        cout << X << " " << Y << " " << HH << endl;;
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
imos = [0 for _ in range(n+1)]
for _ in range(m):
  l, r = map(int, input().split())
  imos[l-1] += 1
  imos[r] -= 1

ans = 1 if imos[0] == m else 0
for i in range(1, n+1):
  imos[i] += imos[i-1]
  if imos[i] == m:
    ans += 1
print(ans)


Measured memory_bytes: 7080
def gcd(x,y):
    if y == 0:
        return x
    return gcd(y, x%y)

K = int(input())
sum = 0
for a in range(1,K-1):
    for b in range(a+1,K):
        for c in range(b+1,K+1):
            sum += gcd(gcd(a,b),c) * 6

for a in range(1,K+1):
    for b in range(1,K+1):
        sum += gcd(gcd(a,b),b) * 3

for i in range(1,K+1):
    sum -=2*i
    
print(sum)


Measured memory_bytes: 9200
#include <iostream>
#include <map>

using namespace std;

int main() {
	// your code goes here
	map<int, int> v;
	int n; cin >> n;
	int m, l, k, sum, s;
	
	for(int i=1; i<=n ;i++){
		cin >> v[i];
	}
	
	cin >> m;
	
	for(int i=0; i<m; i++){
		sum = 0;
		cin >> l >> k;
		s = v[l];
		v[l] = k;
		for(int j=1; j<=n; j++) sum += v[j];
		cout << sum << endl;
		v[l] = s;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,n) for(int i = 1; i <= n; i++)
#define c(ans) cout<<ans<<endl;
using namespace std;
typedef long long ll;
typedef vector<int> v;
const int maxn=1e5+5;

int main(){
	int n;
	while(cin>>n){
		char c[5]={'M','A','R','C','H'};
		map<char,ll> mp;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			mp[s[0]]++;
		}
		ll ans=0;
		for(int i=0;i<5;i++)
			for(int j=i+1;j<5;j++)
				for(int k=j+1;k<5;k++)
					ans+=mp[c[i]]*mp[c[j]]*mp[c[k]];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e18);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    string s;
    cin >> s;
    rep0(i, s.size())if(s[i] == '?')s[i] = 'D';
    pf(s);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    string s;
    cin>>s;
    int a=-1,z;
    REPARR(i,s){
        if(s[i]=='A' && a<0)a=i;
        if(s[i]=='Z')z=i;
    }
    cout<<z-a+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin>>n;
    int min1=1e9;
    for(int i=1; i<=sqrt(n); ++i){
        if(n%i==0){
            string s=to_string(n/i);
            int sl=s.length();
            min1=min(min1,sl);
        }
    }
    cout<<min1<<endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;

const int MAX = 2000005;
ll modFact[MAX];
ll modInv[MAX];
ll modFactInv[MAX];

// calc nCr % mod
ll comb(int n, int r) {
  return modFact[n] * (modFactInv[r] * modFactInv[n - r] % MOD) % MOD;
}

int main() {
  modFact[0] = modFact[1] = 1;
  modFactInv[0] = modFactInv[1] = 1;
  modInv[1] = 1;
  REP(i, 2, MAX) {
    modFact[i] = modFact[i - 1] * i % MOD;
    modInv[i] = MOD - modInv[MOD % i] * (MOD / i) % MOD;
    modFactInv[i] = modFactInv[i - 1] * modInv[i] % MOD;
  }

  int n, k;
  cin >> n >> k;

  ll ans = 0;
  rep(i, min(n, k + 1)) {
    ans = (ans + comb(n - 1, n - 1 - i) * comb(n, n - i) % MOD) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 47104
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Ma = sc.nextInt();
        int Mb = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        int[] c = new int[N];
        int asum = 0, bsum = 0;
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
            asum += a[i];
            bsum += b[i];
        }
        int[][][] dp = new int[N + 1][asum + 1][bsum + 1];
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < asum + 1; j++) {
                Arrays.fill(dp[i][j], Integer.MAX_VALUE / 2);
            }
        }
        dp[0][0][0] = 0;
        for (int i = 1; i < N + 1; i++) {
            for (int j = 0; j < asum + 1; j++) {
                for (int k = 0; k < bsum + 1; k++) {
                    dp[i][j][k] = dp[i - 1][j][k];
                    if (j >= a[i - 1] && k >= b[i - 1]) {
                        dp[i][j][k] = Math.min(dp[i][j][k], dp[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]);
                    }
                }
            }
        }
        int min = Integer.MAX_VALUE / 2;
        for (int i = 1; i < asum + 1; i++) {
            for (int j = 1; j < bsum + 1; j++) {
                if (i * Mb == j * Ma) {
                    min = Math.min(min, dp[N][i][j]);
                }
            }
        }
        if (min < Integer.MAX_VALUE / 2) {
            System.out.println(min);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 31888
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  cout<<fixed<<setprecision(7);
  long double l;
  cin>>l;
  cout<<l*l*l/27<<endl;
}


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

const int N = 100000;

int main() {
    ll n; cin >> n;
    ll tmp;
    ll total = 0;
    vector<ll> a(N+1,0); 
    rep(i,n) {
        cin >> tmp;
        a[tmp]++;
        total += tmp;
    }
    ll q; cin >> q;
    vector<ll> b(q);
    vector<ll> c(q);
    rep(i,q) cin >> b[i] >> c[i];

    vector<ll> ans(q,0);
    rep(i,q) {
        total -= b[i] * a[b[i]];
        total += c[i] * a[b[i]];
        a[c[i]] += a[b[i]];
        a[b[i]] = 0;
        ans[i] = total;
    }

    for(ll x: ans) cout << x << endl;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

char s[500][500];
int pre1[3000][3000] = {0}, pre2[3000][3000] = {0};
const int shift = 1000;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  auto inside = [](int x, int n) { return x >= 0 and x < n; };
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int i = 0; i + 1 < 3000; ++i) for (int j = 0; j + 1 < 3000; ++j) {
    pre1[i + 1][j + 1] = pre1[i][j] + 
    (inside(i - shift, n) and inside(j - shift, m) ? 
    s[i - shift][j - shift] == '#' : 0);
  }
  for (int i = 0; i + 1 < 3000; ++i) for (int j = 1; j < 3000; ++j) {
    pre2[i + 1][j - 1] = pre2[i][j] + 
    (inside(i - shift, n) and inside(j - shift, m) ?
    s[i - shift][j - shift] == '#' : 0);
  }
  LL diag = 0;
  auto S = [&](int i, int j) {
    i -= shift, j -= shift;
    if (inside(i, n) and inside(j, m)) return int(s[i][j] == '#');
    else return 0;
  };
  auto go1 = [&](int i, int j, int d) {
    i += shift, j += shift;
    diag += S(i, j + 2 * d) + S(i - d, j + d) + S(i + 2 * d, j) + S(i + d, j - d);
    return pre1[i + 1][j + 2 * d + 1] - pre1[i - d][j + d] +
           pre1[i + 2 * d + 1][j + 1] - pre1[i + d][j - d];
  };
  auto go2 = [&](int i, int j, int d) {
    i += shift, j += shift;
    diag += S(i + 2 * d, j) + S(i + d, j + d) + S(i, j - 2 * d) + S(i - d, j - d);
    return pre2[i + 2 * d + 1][j - 1] - pre2[i + d][j + d] + 
           pre2[i + 1][j - 2 * d - 1] - pre2[i - d][j - d]; 
  };
  LL ans = 0;
  for (int d = 1; d < 700; ++d) {
    for (int i = 0; i + d < n; ++i) {
      for (int j = 0; j + d < m; ++j) {
        if (s[i][j] == '#' and s[i + d][j + d] == '#') {
          ans += go1(i, j, d);
        }
      }
    }
  }
  for (int d = 1; d < 700; ++d) {
    for (int i = 0; i + d < n; ++i) {
      for (int j = m - 1; j - d >= 0; --j) {
        if (s[i][j] == '#' and s[i + d][j - d] == '#') {
          ans += go2(i, j, d);
        }
      }
    }
  }
  cout << ans - diag / 2 << '\n';
}


Measured memory_bytes: 70656
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

C=[]
for i in range(N):
    C.append(min(A[i+1]+A[i],B[i]))
    if B[i]>A[i]:
        A[i+1]=A[i+1]-(B[i]-A[i])
        if A[i+1]<0:
            A[i+1]=0

print(sum(C))

Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin>>N>>K;

    int sum=0;
    int A[N];
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    int F[N];
    rep(i,N){
        cin>>F[i];
    }

    sort(A,A+N,std::greater<int>());

    sort(F,F+N);


    int NG=-1;
    int OK=2*10000000000000;
    while(OK-NG>1){
        int mid=(OK+NG)/2;
        int sum=0;
        rep(i,N){
            int x=(mid)/F[i];
            sum+=max(0LL,A[i]-x);
        }
        if(sum<=K){
            OK=mid;
        }else NG=mid;
    }
    cout << OK << endl;
    

    



}


Measured memory_bytes: 6800
#include<stdio.h>
main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=0&&0<=b){puts("Zero");return 0;}//区间里有0，0乘任何数都得0
	if(0<a){puts("Positive");return 0;}//区间不沾负数
	int cnt=b-a+1;//有cnt个负数（因为筛选2轮下来只会是a<=b<=0的情况）
	if(cnt%2)puts("Negative");//有奇数个负数
	else puts("Positive");//有偶数个负数，负负得正
}/**/

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
    int A,B;
    cin >> A >> B;

  	int ans = -1;
  	for (int X=1; X<1200; X++)
    {
      if ((int(double(X) * 0.08) == A) && (int(double(X) * 0.1) == B))
      {
        ans = X;
        break;
      }      
    }
  cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<queue>
using namespace std;
int main()
{
	deque<long long int> v;
	int n; cin >> n; int a[2000000], b[2000000]; int c[400000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] != 6) {
			cin >> b[i];
			if (a[i] == 0)
				cin >> c[i];
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) {
			if (b[i] == 1) {
				v.push_back(c[i]);
			}
			else
				v.push_front(c[i]);
		}
		if (a[i] == 1)
			cout << v[b[i]] << endl;
		if (a[i] == 2) {
			if (b[i] == 1) {
				v.pop_back();
			}
			else
				v.pop_front();
		}
	}
}


Measured memory_bytes: 10980
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
#define INF 1145141919810893
signed main(){
    int N;
    int now1,now2;
    int T[1010],A[1010];
    int rate;
    cin >> N ;
    REP(i,N){cin >> T[i] >> A[i];}
    REP(i,N){
        if(i==0){
            now1=T[0];now2=A[0];
        }else{
            if(T[i]==now1 && A[i]>=now2){
                now2=A[i];
            }else if(T[i]==now1 && A[i]>=now2){
                now1=T[i];
            }else{
                rate=max(now1/T[i],now2/A[i])-2;
                while(rate*T[i]<now1 || rate*A[i]<now2){
                    rate++;
                }
                now1=rate*T[i];
                now2=rate*A[i];
            }
        }
    }
    cout << now1+now2 << endl;
	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]

if list1.count(a) == 1:
    if list1.count(b) == 1:
        print("Yes")
    else:
        print("No")
if list2.count(a) == 1:
    if list2.count(b) == 1:
        print("Yes")
    else:
        print("No")
if list3.count(a) == 1:
    if list3.count(b) == 1:
        print("Yes")
    else:
        print("No")

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

int main()
{
    long n;
    long long ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            for(int k = 1; k <= n; k++)
            {
                ans += __gcd(i, __gcd(j,k));
            }
    cout << ans;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main()
{
    int N;
    vector<int> odd;
    vector<int> even;
    vector<int> a, b;

    cin >> N;
    a.resize(N);
    b.resize(N);
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        a[i] = A;
        b[i] = A;
    }

    map<int, int> m;
    sort(b.begin(), b.end());
    for (int i = 0; i < N; i++)
    {
        m[b[i]] = i;
    }

    int ans = 0;

    for (int i = 0; i < N; i++)
    {
        if(m[a[i]] % 2 == 0 && i % 2 == 1)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
//		int A = sc.nextInt();
//		int B = sc.nextInt();
//		int C = sc.nextInt();
		
		ArrayList<Integer> list_a = new ArrayList<Integer>();//モンスター
		ArrayList<Integer> list_b = new ArrayList<Integer>();//討伐数
		ArrayList<Integer> list_c = new ArrayList<Integer>();//討伐数


		int ans = 0;

		for(int i = 0 ;i < N;i++){
			list_a.add(sc.nextInt());
		}

		for(int i = 0 ;i < N;i++){
			int w = sc.nextInt();
			list_b.add(w);
			ans = ans + w;
		}

		for(int i = 0 ;i < N-1;i++){
			list_c.add(sc.nextInt());
		}

		for(int i = 0;i < N-1;i++) {
			if(list_a.get(i+1) - list_a.get(i) == 1) {
				ans = ans + list_c.get(list_a.get(i)-1);
			}
		}
	
		System.out.println(ans);

   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 23124
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <functional>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using pci = pair<char, int>;
using vpci = vector<pci>;
using vb = vector<bool>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(int i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define INF 1e10;

int main(){
  int M,N;
  cin>>N>>M;
  vector<int> v(M);
  REP(i,M)cin>>v[i];
  vector<bool> under;
  REP(i,N) under.push_back(true);

  for(auto item:v) under[item]=false;

  int cnt=0;
  while (under.size()!=1) {
    vector<bool> tmp;
    for(int i=0;i<under.size();i+=2){
      if(under[i]&&under[i+1]) cnt++;
      tmp.push_back(under[i]||under[i+1]);
    }
    under=tmp;
  }
  out(cnt);
  
	return 0;
}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds; 
 
typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;
typedef pair<ll, ll> pll;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define mini(a) *min_element(all(a))
#define maxi(a) *max_element(all(a))
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define FOR(i, j, k, in) for(ll i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(ll i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define rrepc(v) for(auto it=v.rbegin(); it!=v.rend(); it--)
#define T ll t; cin>>t; while(t--)

ll gen(){
    ll temp;
    cin>>temp;
    return temp;
}

ll power(ll a, ll b, ll m){    
    ll res=1;
    while(b>0){
        if(b&1){
            res=(res*a)%m;
            b--;
        }
        a=(a*a)%m;
        b=b>>1;
    }
    return res;
}

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

#define inpt(v) generate(all(v),gen)
#define sum(v) accumulate(all(v),0LL)
#define vpll vector<pll>
#define umap unordered_map
#define uset unordered_set
#define print(v) rep(i,0,n) cout<<v[i]<<" ";

int32_t main(){
  FAST

    ll n,m,b;
    cin>>n>>m>>b;

    vll row(n,0), col(m,0);

    set<pll>st;
    rep(i,0,b){
        ll x,y;
        cin>>x>>y;

        row[x-1]++;
        col[y-1]++;
        st.insert({x,y});
    }    
    
    vll rmax, cmax;
    ll rmx = maxi(row), cmx = maxi(col);
    rep(i,0,n)
        if(rmx ==  row[i])
            rmax.pb(i+1); 

    rep(i,0,m)
        if(cmx ==  col[i])
            cmax.pb(i+1); 

    int f = 0;
    rep(i,0,rmax.size()){
        rep(j,0,cmax.size()){
            if(st.find({rmax[i], cmax[j]}) == st.end()){
                f = 1;
                break;
            }
        }
        if(f) break;
    }

    if(f) cout<<rmx+cmx;
    else cout<<rmx+cmx-1;


  return 0;
}

Measured memory_bytes: 35056
d={}
s=[]

n=int(input())
nums=list(map(int,input().split()))

for a in nums:    
    if not a in d:
        d[a]=1
    else:
        d[a]+=1
    s.append(a)
    
allcount=0

for count in d.values():
    allcount+=int(count*(count-1)/2)

for num in s:
    print(allcount-d[num]+1)

Measured memory_bytes: 26268
A = int(input())

if(A<=111):
    print("111")
elif(A<=222):
        print("222")
elif(A<=333):
    print("333")
elif(A<=444):
    print("444")
elif(A<=555):
    print("555")
elif(A<=666):
    print("666")
elif(A<=777):
    print("777")
elif(A<=888):
    print("888")
else:
    print("999")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

bool compare(const pair<lli,lli> &a,const pair<lli,lli> &b){
	return a.second < b.second;
}

signed main(){
 
	lli n;
	cin>>n;

	vector<pair<lli,lli>> p;
	REP(i,0,n){
		lli a,b;
		cin>>a>>b;
		p.push_back(make_pair(a,b));
	}

	sort(p.begin(),p.end(),compare);

	if(DEBUG){
		REP(i,0,n){
			cout<<p[i].first<<" "<<p[i].second<<endl;
		}
	}

	lli nowTime=0;
	REP(i,0,n){
		nowTime += p[i].first;
		if(nowTime>p[i].second){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main(){
    vector<int> time(1010,0);
    int a,b;
    cin >> a >> b;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int st,en;
        cin >> st >> en;
        time[st]++;
        time[en]--;
    }
    for(int i = 1; i < 1010; i++){
        time[i] += time[i-1];
    }
    bool flag = true;
    for(int i = a; i < b; i++) if(time[i] != 0) flag = false;
    
    cout << (flag?0:1) << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
using namespace std;
int main(){
	int n; cin >> n;
	int sum = 0;
	for( int i = 1; i <= n; i++)
		sum += i;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 764