akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m, i;
  int a, b, count;
  cin >> n >> m;
  vector<int> height(n, 0);
  vector<int> data(n, 1);
  for (i=0; i<n; i++) {
  	cin >> height.at(i);
  }
  for (i=0; i<m; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (height.at(a) <= height.at(b)) {
      data.at(a) = 0;
    }
    if (height.at(a) >= height.at(b)) {
      data.at(b) = 0;
    }
  }
  for (i=0; i<n; i++) {
    if (data.at(i) == 1) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 4040
n = int(input())
A = list(map(int,input().split()))
Ad = {}
for a in A:
  if a not in Ad:
    Ad[a] = 1
  else:
    Ad[a] += 1
a = len(Ad)
if a == 1:
  for i in Ad.keys():
    if i == 0:
      print('Yes')
    else:
      print('No')
elif n % 3:
  print('No')
elif a == 2:
  x = 0
  for k,v in Ad.items():
    if v != n//3 and v != n//3*2:
      print("No")
      break
    else:
      x ^= k
      if v == n//3*2:
        x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
elif a == 3:
  x = 0
  for k,v in Ad.items():
    if v != n//3:
      print("No")
      break
    else:
      x ^= k
  else:
    if x == 0:
      print('Yes')
    else:
      print('No')
else:
  print('No')


Measured memory_bytes: 14300
use proconio::input;

fn main() {
    abc173_b()
}

fn abc173_b() {
    input!(n: u32);
    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;
    for _ in 0..n {
        input!(s: String);
        match &*s {
            "AC" => ac += 1,
            "WA" => wa += 1,
            "TLE" => tle += 1,
            "RE" => re += 1,
            _ => (),
        }
    }
    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}

Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;


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

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

int main(void){

    int N,D;
    cin >> N >> D;
    int tmp;
    if(N%(2*D+1)==0){
        tmp  = 0;
    }else{
        tmp = 1;
    }
    cout << N / (2*D+1) + tmp << endl;

    return 0;
}

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

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// 0 <= unsigned int <= 4.2e9

int main()
{
    string S; cin >> S;
    if ((S == "AAA") || (S == "BBB"))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define maxN 1005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
pi g1[1000006],g2[1000006];
int arr[maxN][maxN];

int32_t main(){
    fastio;
    string s1;in s1;
    string s2;in s2;
    int c=0;
    for(int i=0;i<3;i++){
        if(s1[i]==s2[i])
            c++;
    }
    out c<<endl;

}


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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])
    b = [int(e) for e in lines[1].split(" ")]

    return (n, b)


def solve(n, b):

    a = []
    a.append(b[0])
    for i in range(1, n-1):
        a.append(min(b[i-1], b[i]))

    a.append(b[n-2])

    return sum(a)


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)


if __name__ == '__main__':

    main()
	


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>

using namespace std;

int
main(int argc, const char *argv[])
{
    int n;
    vector<int> vx, vy;
    cin >> n;
    for (int i = 0; i < n; ++i) { int x; cin >> x; vx.push_back(x); }
    for (int i = 0; i < n; ++i) { int y; cin >> y; vy.push_back(y); }
    double r1 = 0, r2 = 0, r3 = 0, r4 = 0;
    for (int i = 0; i < vx.size(); ++i) {
        double abs_r = abs(vx[i] - vy[i]);
        r1 += abs_r;
        r2 += abs_r * abs_r;
        r3 += abs_r * abs_r * abs_r;
        r4 = r4 > abs_r ? r4 : abs_r;
    }
    printf("%.6lf\n%.6lf\n%.6lf\n%.6lf\n", r1, sqrt(r2), pow(r3, 1.0/3), r4);

    return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    long double a;
    cin >> a;
    cout << setprecision(20) << (a*a*a)/27.0 << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4")
    #pragma GCC optimize("unroll-loops")
    #include <iostream>
    #include <cstring>
    #include <string>
    #include <vector>
    #include <queue>
    #include <map>
    #include <set>
    #include <stdio.h>
    #include <fstream>
    #include <cmath>
    #include <stdlib.h>
    #include <iomanip>
    #include <algorithm>
    #include <limits.h>
    #include <stack>
    #include <cmath>
    #include <math.h>
    #include <array>
    using namespace std;
    #define FAST_IO ios::sync_with_stdio(false);
    #define DEBUG_VIS(x) cerr<<"vis "<<x<<endl;
    #define DEBUG_REACH cerr<<"reach here"<<endl;
    #define DEBUG_SEQ(x) cerr<<x<<" ";
    #define SET_ZERO(x) memset(x,0,sizeof(x));
    #define SET_NEGONE(x) memset(x,-1,sizeof(x));
    #define SET_INF(x) memset(x,127,sizeof(x));
    #define SET_NEGINF(x) memset(x,128,sizeof(x));
    #define IS_INF(x) x < 2100000000
    typedef pair<int,int> pii;
    typedef pair<long long,long long> pll;
    typedef pair<double,double> pdd;
    typedef long long ll;
    typedef unsigned int uint;
    typedef unsigned long long ull;
    const int maxn = 1e2 + 10;
    template <class T> T mymin(const T a,const T b){return a < b ? a : b;}
    template <class T> T mymax(const T a,const T b){return a > b ? a : b;}
    string s;
    map<pair<string,string>,int> mp1,mp2;
    int main(){
  
        FAST_IO
        int n;
        cin>>n>>s;
        string s1 = s.substr(0,n);
        string s2 = s.substr(n,n);
        for(int i = 0; i < (1 << n); i++){
            string lb,lr,rb,rr;
            for(int j = 0; j < n; j++){
                if(i & (1 << j)) lb += s1[j];
                else lr += s1[j];
                if(i & (1 << j)) rr += s2[j];
                else rb += s2[j];
            }
            reverse(lr.begin(),lr.end());
            reverse(rr.begin(),rr.end());
            mp1[make_pair(lr,lb)]++;
            mp2[make_pair(rb,rr)]++;
        }
        ull ans = 0;
        for(auto it : mp1){
            ans += (ull) it.second * mp2[it.first];
        }
        cout<<ans<<endl;
        return 0;
    }


Measured memory_bytes: 103424
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int array[200000];

	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		scanf("%d", &array[i]);
	}

	int max_t = array[1] - array[0];
	int min_t = array[0];

	for (int i = 1; i < n; i++){
		max_t = max(max_t, array[i] - min_t);
		min_t = min(min_t, array[i]);
	}

	cout << max_t << endl;

	return (0);
}

Measured memory_bytes: 1988
package main

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

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

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	k := nextInt()

	a := make([]int, n)
	sum := 0

	for i := 0; i < n; i++ {
		a[i] = nextInt()
		sum += a[i]
	}

	ans := divCeil(sum, (n + k))

	for i := 0; i < 10000; i++ {
		wk := 0
		da := []int{}

		for j := 0; j < n; j++ {
			d := divCeil(a[j], ans)
			wk += d
			if d > 1 {
				da = append(da, divCeil(a[j], d-1))
				//fmt.Fprintln(out, "[DEBUG]", divCeil(a[j], d-1))
			}
		}
		sort.Ints(da)
		//fmt.Fprintln(out, "[DEBUG]", wk, n+k, "---------------------")
		if wk <= n+k {
			break
		}
		ans = da[wk-(n+k)-1]
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

// 挿入ソート配列
type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}
func divCeil(shi, bo int) int {
	ans := shi / bo
	if shi%bo != 0 {
		ans++
	}
	return ans
}


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

const long long big=1000000000000000000LL;
long long arr[100000];

int main(void) {
    int n;
    scanf("%d",&n);
    long long ret=1;
    for(int i=0;i<n;i++) {
        scanf("%lld",&arr[i]);
        if (arr[i]==0) {
            printf("0");
            return 0;
        }
    }
    for(int i=0;i<n;i++) {
        long long x=arr[i];
        if (x!=0&&ret>big/x) {
            printf("-1");
            return 0;
        }
        ret*=x;
    }
    printf("%lld",ret);
}

Measured memory_bytes: 4504
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, A, B, C, D;

// int main() {
//     fastio();
//     cin >> N >> A >> B >> C >> D;
//     ll tmp, r = (N - 1) * C, l = (N - 1) * D;
//     ll target = B - A + l;
//     ll diff = l - r;
//     REP(i, N-1) {
//         tmp = i*(D+C);
//         if(tmp <= target && target <= tmp + diff) {
//             cout << "YES\n";
//             return 0;
//         }
//     }
//     cout << "NO\n";
// 	return 0;
// }

int main() {
    fastio();
    cin >> N >> A >> B >> C >> D;
    ll tmp, L = (N - 1) * C, R = (N - 1) * D;
    ll diff = R - L;
    ll target = abs(B - A) + R;
    cout << (target <= (N - 2) * (C + D) + diff && target % (C + D) <= diff ? "YES" : "NO") << "\n"; 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

  /* クイックソートを行う */
void QSort(long x[ ], long left, long right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(long x[ ], int i, int j)
{
    long temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int search(long a[],long target,int left,int right){
  int m;
  if(left>right) return 0;
  m=(left+right)/2;
  if(target==a[m]) return 1;
  else if(left==right) return 0;
  else if(target<a[m]){
    return search(a,target,left,m-1);
  }
  else{
    return search(a,target,m+1,right);
  }
}

int main(){
  int n,i,j;
  long a[200000],x[200000],max=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  QSort(a, 0, n - 1);
  max=a[n-1];
  for(i=0;i<n-1;i++){
    if(labs(a[i]-(a[n-1]/2))<=max){
      j=a[i];
      max=labs(a[i]-(a[n-1]/2));
    }
  }
  printf("%ld %ld\n",a[n-1],j);
}

Measured memory_bytes: 896
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let A = rl().as_bytes().to_owned();
    let B = rl().as_bytes().to_owned();
    let C = rl().as_bytes().to_owned();
    let mut k = 0;

    for i in 0..N {
        let mut x = vec![A[i], B[i], C[i]];
        x.sort();

        if x[0] == x[1] {
            if x[1] == x[2] {
                continue;
            }
            k += 1;
            continue;
        }
        if x[1] == x[2] {
            k += 1;
            continue;
        }
        k += 2;
    }

    println!("{}", k)
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

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


Measured memory_bytes: 256
n = gets.to_i
array = []
n.times do
  array << gets.to_i
end

array_sort = array.sort{ |a, b| b <=> a }
max1 = array_sort[0]
max2 = array_sort[1]

n.times do |i|
  x = array[i]
  if x == max1
    p max2
  else
    p max1
  end
end



Measured memory_bytes: 8224
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,K;
int A[20];
//int maxA[20];
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,N){
        scanf("%lld",&A[i]);
        //if(i==0)maxA[i]=-1;//maxA+1以上じゃないと見えない
        //else maxA[i]=max(A[i-1],maxA[i-1]);
    }
    int ans=LLINF;
    rep(i,1<<N){
        //Kこ以上を選ぶ全ての建物の選び方について、その建物は必ず見えるようにする
        int cnt=0;
        rep(j,N){
            if((i>>j)%2==1)cnt++;
        }
        if(cnt<K)continue;
        int newmax=-1;
        int money=0;
        rep(j,N){
            if((i>>j)%2==1){//この建物が見えるようにしたい
                money+=max((int)0,newmax-A[j]+1);
                newmax=max(newmax,A[j]+max((int)0,newmax-A[j]+1));
            }else{
                newmax=max(newmax,A[j]);
            }
        }
        ans=min(ans,money);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end());

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(n);
    V vec(10,-1);
    REP(i,n)cin>>vec[i];

    int sum=0;
    REP(a,(vec[0]==-1?1:3))REP(b,(vec[1]==-1?1:3))REP(c,(vec[2]==-1?1:3))REP(d,(vec[3]==-1?1:3))REP(e,(vec[4]==-1?1:3))REP(f,(vec[5]==-1?1:3))REP(g,(vec[6]==-1?1:3))REP(h,(vec[7]==-1?1:3))REP(i,(vec[8]==-1?1:3))REP(j,(vec[9]==-1?1:3)){
        bool flag=false;
        if(vec[0]!=-1){
            if(vec[0]%2==0&&a==0)flag=true;
            if(vec[0]%2==1&&a!=0)flag=true;
        }
        if(vec[1]!=-1){
            if(vec[1]%2==0&&b==0)flag=true;
            if(vec[1]%2==1&&b!=0)flag=true;
        }
        if(vec[2]!=-1){
            if(vec[2]%2==0&&c==0)flag=true;
            if(vec[2]%2==1&&c!=0)flag=true;
        }
        if(vec[3]!=-1){
            if(vec[3]%2==0&&d==0)flag=true;
            if(vec[3]%2==1&&d!=0)flag=true;
        }
        if(vec[4]!=-1){
            if(vec[4]%2==0&&e==0)flag=true;
            if(vec[4]%2==1&&e!=0)flag=true;
        }
        if(vec[5]!=-1){
            if(vec[5]%2==0&&f==0)flag=true;
            if(vec[5]%2==1&&f!=0)flag=true;
        }
        if(vec[6]!=-1){
            if(vec[6]%2==0&&g==0)flag=true;
            if(vec[6]%2==1&&g!=0)flag=true;
        }
        if(vec[7]!=-1){
            if(vec[7]%2==0&&h==0)flag=true;
            if(vec[7]%2==1&&h!=0)flag=true;
        }
        if(vec[8]!=-1){
            if(vec[8]%2==0&&i==0)flag=true;
            if(vec[8]%2==1&&i!=0)flag=true;
        }
        if(vec[9]!=-1){
            if(vec[9]%2==0&&j==0)flag=true;
            if(vec[9]%2==1&&j!=0)flag=true;
        }


        if(flag)sum++;
    }
    
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;

ll GCD(ll a,ll b){
    ll r=b%a;
    while(r!=0){
        b=a;
        a=r;
        r=b%a;
    }
    return a;
}

int main(){
    ll A,B,C,D;
    ll E,F,G,H,I,J,con,K,L,lcm;
    cin>>A>>B>>C>>D;
    if(C>D){
        con=C;
        C=D;D=con;
    }
    F=B/C;
    E=(A-1)/C;
    G=(A-1)/D;
    H=B/D;
    lcm=C*D/GCD(C,D);
    I=B/lcm;
    J=(A-1)/lcm;
    K=B-F-H+I;
    L=(A-1)-E-G+J;
    cout<<K-L<<endl;

}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define int long long
#define Rep(i, n, a) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, n, 0)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1000000007;

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

    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    bool f = false;
    rep(i, n - 1) f = f || (c * i - d * (n - i - 1)) <= (b - a) && (b - a) <= d * i - c * (n - i - 1);
    cout << (f ? "YES" : "NO") << endl;
}

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

typedef long long lglg;

bool seen[3000] = {};
bool globalseen[3000] = {};
vector<int> edges[3000];
vector<int> cycle;

int dfs(int x) {
	if (seen[x]) return x;
	if (globalseen[x]) return -1;
	seen[x] = globalseen[x] = true;
	cycle.push_back(x);
	for (int y : edges[x]) {
		int val = dfs(y);
		if (val != -1) return val;
	}
	seen[x] = false;
	cycle.pop_back();
	return -1;
}

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

	int N, M; cin >> N >> M;
	for (int i=0; i<M; ++i) {
		int a, b; cin >> a >> b;
		edges[a].push_back(b);
	}

	bool success = false;
	for (int x=1; x<=N; ++x) {
		int val = dfs(x);
		if (val != -1) {
			success = true;
			vector<int> newcycle;
			bool found = false;
			for (int i : cycle) {
				if (i == val) found = true;
				if (found) newcycle.push_back(i);
			}
			cycle = newcycle;
			while (true) {
				bool inCycle[N+1] = {};
				for (int i : cycle) inCycle[i] = true;
				int induced = -1;
				for (int i : cycle) {
					int adj = 0; for (int j : edges[i]) if (inCycle[j]) ++adj;
					if (adj >= 2) {
						induced = i;
						break;
					}
				}
				if (induced == -1) break;
				int nextind;
				for (int i=0; i<cycle.size(); ++i) {
					if (cycle[i] == induced) {
						nextind = cycle[(i+1)%cycle.size()];
						break;
					}
				}
				vector<int> newcycle;
				newcycle.push_back(induced);
				for (int j : edges[induced]) {
					if (inCycle[j] && j != nextind) {
						newcycle.push_back(j);
						break;
					}
				}
				int i=0;
				bool found = false;
				int lookingfor = newcycle.back();
				while (true) {
					if (cycle[i] == lookingfor) found = true;
					else if (found) {
						if (cycle[i] == induced) break;
						newcycle.push_back(cycle[i]);
					}
					++i;
					i %= cycle.size();
				}
				cycle = newcycle;
			}
			cout << cycle.size() << '\n';
			for (int i : cycle) cout << i << '\n';
			break;
		}
	}
	if (!success) cout << -1;
}

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

using namespace std;

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

  vector<int> a(n);
  int cnt0 = 0, cnt2 = 0, cnt4 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 4 == 0) cnt4++;
    else if (a[i] % 2 == 0) cnt2++;
    else cnt0++;
  }

  if (cnt0 == 0) {
    cout << "Yes\n";
  } else {
    if (cnt0 - cnt4 <= 0) {
      cout << "Yes\n";
    } else if (cnt0 - cnt4 == 1) {
      if (cnt2 == 0) {
        cout << "Yes\n";
      } else {
        cout << "No\n";
      }
    } else {
      cout << "No\n";
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll N,K;
  cin >> N >> K;
  vector<ll> P(N);
  for (size_t i = 0; i < N; i++)
  {
    cin >> P[i];
  }
  sort(P.begin(),P.end());
  ll ans = 0;
  for (size_t i = 0; i < K; i++)
  {
    ans += P[i];
  }
  cout <<ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 100002



int32_t main()
{   
    io
    
    int n, k, q;
    cin>>n>>k>>q;

    int a[n+1]={0};

    int x;
    int incs=0;


    while(q--)
    {
        cin>>x;
        a[x]++;
        incs++;
    }

    for(int i=1;i<=n;i++)
    {   

        if(a[i]-incs+k<=0)
        {
            cout<<"No"<<endl;
        }
        else
            cout<<"Yes"<<endl;

    }







return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <bits/stdint-intn.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int64_t k, a, b;
  std::cin >> k >> a >> b;

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


Measured memory_bytes: 3632
# https://img.atcoder.jp/abc123/editorial.pdf
# 問題D: Cake 123 解法 #2 - 「ある条件」を満たす最大106307通りを全部ソート

def solve(X, Y, Z, K, A, B, C):
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    ABC = []
    for i1, a in enumerate(A, start=1):
       for i2, b in enumerate(B, start=1):
           for i3, c in enumerate(C, start=1):
               if i1 * i2 * i3 <= K:
                   ABC.append(a + b + c)
               else:
                   break
    ABC.sort(reverse=True)
    ABC = ABC[:K]

    print("\n".join(map(str, ABC)))

if __name__ == "__main__":
    X, Y, Z, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    solve(X, Y, Z, K, A, B, C)

Measured memory_bytes: 8708
using System;

namespace ARC069_D___Menagerie
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static string solver()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var talk = new int[N];
            for (int i = 0; i < N; i++) talk[i] = S[i] == 'o' ? 1 : -1;
            if (check(talk, 1, 1) != "") return check(talk, 1, 1);
            if (check(talk, 1, -1) != "") return check(talk, 1, -1);
            if (check(talk, -1, 1)!="") return check(talk, -1, 1);
            if (check(talk, -1, -1)!="") return check(talk, -1, -1);
            return "-1";
        }
        static string check(int[] talk, int first, int second)
        {
            var N = talk.Length;
            var arrangement = new int[N];
            var result = new System.Text.StringBuilder();
            arrangement[0] = first;
            arrangement[1] = second;
            for (int i = 1; i < talk.Length - 1; i++) arrangement[i + 1] = arrangement[i - 1] * arrangement[i] * talk[i];
            if (arrangement[N - 1] * arrangement[N - 2] * talk[N - 1] != arrangement[0]) return "";
            if (arrangement[0] * arrangement[1] * talk[0] != arrangement[N - 1]) return "";
            for (int i = 0; i < N; i++) result.Append(arrangement[i] == 1 ? "S" : "W");
            return result.ToString();
        }
    }
}


Measured memory_bytes: 14816
import itertools
N, M, Q = map(int, input().split())
max = 0
s = ''
for i in range(M):
    s += str(i)
l = list(itertools.combinations_with_replacement(s, N))
m = [list(map(int, input().split())) for i in range(Q)]
for x in l:
    count = 0
    for y in m:
        if int(x[y[1] - 1]) - int(x[y[0] - 1]) == y[2]:
            count += y[3]
    if count > max:
        max = count
print(max)

Measured memory_bytes: 21564
//Robs Code
#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define all(x) x.begin(),x.end()
#define ed cout<<"\n";
#define pb push_back
#define pii pair<int,int>
#define _1 first
#define _2 second
#define maxi 100000007
/**********************************************************/
using namespace std;
int i,j,k,n,m,q,t,a,b,cnt[2],sum,tot;
signed main() 
{
    speed;
    string s;
    cin>>s;
    n=s.length();
    string s1="01",s2="10";
    for(i=0;i<n;i++){
        cnt[0]+=abs(s[i]-s1[i%2]);
        cnt[1]+=abs(s[i]-s2[i%2]);
    }
    cout<<min(cnt[0],cnt[1]);
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>

int n;
long long a[150];

signed main() {
  a[0] = 2;
  a[1] = 1;
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i)
    a[i] = a[i - 1] + a[i - 2];
  printf("%lld\n", a[n]);
  return 0;
}


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

int main()
{
    int u,v,i;
    char s[10000],t[10000];
    scanf("%s %s", s,t);
    u=strlen(s);
    v=strlen(t);
    if(u+1==v)
    {
        for(i=0; s[i]; i++)
        {
            if(s[i]!=t[i])
            {
                printf("No\n");
                return 0;

            }
        }
    }
    else
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> d;
vector<vector<int>> A;

void input() {
    cin >> N >> K;
    d.resize(K);
    A.resize(K, vector<int>());
    for(int i = 0; i < K; i++) {
        cin >> d[i];
        A[i].resize(d[i]);
        for(int j = 0; j < d[i]; j++) {
            cin >> A[i][j];
        }
    }
}

void solve() {
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        bool have = false;
        for(auto v : A) {
            for(auto p : v) {
                if(p == i) have = true;
            }
        }
        if(!have) ans++;
    }
    cout << ans << endl;
}

int main() {
    input();
    solve();
}

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

int dist(int D, vector<int> a, vector<int> b){
  int res = 0;
  rep(i,D){
    res += (a[i] - b[i]) * (a[i] - b[i]);
  }
  return res;
}

bool issqrt(int a){
  return int(pow(int(sqrt(a)),2)) == a;
}

int main() {
  int N,D;
  cin >> N >> D;
  vector<vector<int>> X(N);
  
  rep(i,N){
    rep(j,D){
      int tmp;
      cin >> tmp;
      X[i].push_back(tmp);
    }
  }

  int ans=0;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j<N; j++){
      if(issqrt(dist(D, X[i], X[j]))){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3700
package main

import (
	"fmt"
)

func main() {
	var a int
	var b int
	fmt.Scan(&a, &b)
	plus := a + b
	diff := a - b
	math := a * b

	if plus > diff {
		if plus > math {
			fmt.Println(plus)
		} else {
			fmt.Println(math)
		}
	} else {
		if diff > math {
			fmt.Println(diff)
		} else {
			fmt.Println(math)
		}
	}
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

	vector<int> h;

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

	string canMultiplies = "No";
	for (int i = 1; i <= 9; i++)
	{
		if (N % i == 0 && N / i < 10) {
			canMultiplies = "Yes";
			break;
		}
	}

	cout << canMultiplies << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	ll X, K, D;
	cin >> X >> K >> D;
	X = abs(X);
	if (X / D > K) {
		cout << X - K * D;
	}
	else {
		K -= X / D;
		X -= (X / D) * D;
		if (K % 2 == 0)
			cout << X;
		else
			cout << abs(X - D);
	}
}


Measured memory_bytes: 3628
fun main(args : Array<String>){
    val(N_,M) = readLine()!!.split(" ").map(String::toLong)
    val N = N_.toInt()
    var ab_ = Array(N){ readLine()!!.split(" ").map(String::toLong).toTypedArray()}
    ab_.sortBy{it[0]}
    var Mnow = M
    var ans:Long = 0
    var abindex = 0
//    for(i in 0 until ab_.size){
//        println("${ab_[i][0]} ${ab_[i][1]}")
//    }
    while(Mnow>0 && abindex < N){
        var(a,b) = ab_[abindex]
        if(Mnow > b){
            Mnow -= b
            ans += a*b
        }else{
            ans += Mnow*a
            Mnow = 0
            break
        }
        abindex++
    }
    if(Mnow>0){
        throw Exception()
    }else{
        println(ans)
    }
}


Measured memory_bytes: 82916
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

signed main() {
  ll A, B, C;
  cin >> A >> B >> C;
  if (A + B + C <= 21) {
    COUT("win");
  } else {
    COUT("bust");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

vector<pair<int,int>> v;

void solve(){

    ll n,m;
    cin >> n >> m;
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        v.eb(make_pair(b-1,a));
    }
    sort(v.begin(), v.end());
    ll pre = v[0].first;
    ll ans = 1;
    for(ll i=1; i<v.size(); i++){
        ll x,y;
        x = v[i].second;
        y = v[i].first;
        if(x<=pre&&pre<=y){
            continue;
        }
        else{
            pre = y;
            ans++;
        }   
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  ++n;
  vl a(n), l(n), r(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    l[i] = a[i];
    if (i < 60) r[i] = 1LL << i;
    else r[i] = 1LL << 60;
  }
  l[0] = max(l[0], 1LL);
  r[n - 1] = min(r[n - 1], a[n - 1]);
  bool fail = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (l[i] > r[i]) fail = 1;
    else if (i) {
      l[i - 1] = max(l[i - 1], a[i - 1] + (l[i] + 1) / 2);
      r[i - 1] = min(r[i - 1], a[i - 1] + r[i]);
    } 
  }
  ll ma = 0;
  for (int i = 0; i < n; ++i) {
//    cerr << l[i] << ' ' << r[i] << endl;
    if (l[i] > r[i]) fail = 1;
    ma += r[i];
    if (i + 1 < n) r[i + 1] = min(r[i + 1], 2 * (r[i] - a[i]));
  }
  if (fail) cout << -1 << endl;
  else cout << ma << endl;
  return 0;
}


Measured memory_bytes: 5576
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
void print_int(int n)
{
    printf("%d\n",n);
}

void swap(int * a, int * b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

void sort(int a[], int n)
{
    for(int i = 1; i < n; i++)
    {
        int j = i-1;
        while(j >= 0 && a[j+1] > a[j])
        {
            swap(&a[j+1],&a[j]);
            j--;
        }
        
    }
    
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        print_int(a[i]);
    }
    
}


char s[200000];
int main(void)
{
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    int min = n;
    int black = 0, white = 0;
    int flag = -1;
    int temp;

    for(int i = 0; i < n; i++)
    {
        if(s[i] == '.')
            white++;
    }
    min = n - white;
    if(n <= 1)
        min = 0;

    for(int i = 0; i < n; i++)
    {
        if(s[i] == '#')
        {
            white -= i - flag - 1;
            temp = white + black;
            black++;
            flag = i;
            if(temp < min)
            min = temp;
        }
        
    }
    


    print_int(min);
    



    

    return 0;

}

Measured memory_bytes: 384
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
int main(){
	int n,q,b,ans=0,mid,left,right;
	std::vector<int> S,T;
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>b;
		S.push_back(b);
	}
	if(S.size()%2==1)mid=(S.size()/2)+1;
	else mid=(S.size()/2);
	std::cin>>q;
	for(int i=0;i<q;i++){
		std::cin>>b;
		T.push_back(b);
	}
	std::vector<int>::iterator it=T.begin();
	for(std::vector<int>::iterator it=T.begin();it!=T.end();++it){
		left=0;right=S.size();
		while(left<right){
			if(S[mid]==*it){
				ans++;
				break;
			}
			else if(*it<S[mid]){
				right=mid;
			}
			else left=mid+1;
			mid = (left + right) / 2;
	    }
	}
	std::cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3464
def call(n):
    ret = ""
    for i in range(1, int(n)+1):
        if 0 == i % 3:
            ret += " " + str(i)
        elif -1 != str(i).find("3"):
            ret += " " + str(i)

    return ret

if __name__ == "__main__":
    n = input()
    ret = call(n)
    print (ret)


Measured memory_bytes: 5628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    LL sum = 0;
    VL A(N);

    REP(i,N){
        cin >> A[i];
        sum += A[i];
    }

    VL acc(N+1);
    LL ans = LINF;

    FOR(i,1,N+1){
        acc[i] = A[i-1]+acc[i-1];
        LL dif = abs((sum - acc[i]) - acc[i]);
        if(dif < ans){
            ans = dif;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3456
import java.util.*;


public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int sum = 0;
		for(int i = 0; i<m; i++){
			int a = sc.nextInt();
			sum += a;
		} 
		if(n >= sum){
			System.out.println(n-sum);
		}else{
			System.out.println(-1);
		}

		sc.close();		
	}

}

Measured memory_bytes: 46244
#include<stdio.h>
int n,q,S[100000],T[50000];
int binarysearch(int x){
int left,right,midle;
left=0;
right=n;
while(left<right){
  midle=(left+right)/2;
  if(S[midle]==x) return 1;
  else if(x<S[midle]) right=midle;
  else left=midle+1;
}

  return 0;
}
int main(){
  int i,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    count+=binarysearch(T[i]);
  }
  printf("%d\n",count);

return 0;
}



Measured memory_bytes: 2284
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
t = LI()
m = I()
p = []
x = []
for i in range(m):
    tmp = LI()
    p.append(tmp.pop(0)-1)
    x.append(tmp.pop(0))

for i in range(m):
    sum = 0
    for j in range(n):
        if j == p[i]:
            sum += x[i]
        else:
            sum += t[j]
    print(sum)

Measured memory_bytes: 3064
#include<stdio.h>

int leap(int year){
  int result=0;  //leap=1

  if(year%4==0){
    result=1;
    if(year%100==0){
      result=0;
      if(year%400==0)
	result=1;
    }
  }
  if(result)
    printf("%d\n",year);

  return result;
}

int main(void){
  int a,b,i,f,t,k=0;

  while(scanf("%d%d",&a,&b)!=EOF){
    if(a==0&&b==0)
      break;
    if(k)
      puts("");

    f=1;
    for(i=a;i<=b;i++){
      t=leap(i);
      if(t==1)
	f=0;
    }
    if(f)
      puts("NA");
    k=1;
  }
  return 0;
}
    

Measured memory_bytes: 0