akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main(){
    int n, a[100005] = {}, b[100005] = {};
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        if (i % 2 == 0)a[t]++;
        else b[t]++;
    }
    int a1 = 0, a2 = 0, b1 = 0, b2 = 0, a1num = 0, a2num = 0, b1num = 0, b2num = 0;
    for (int i = 1; i <= 100000; i++) {
        if (a2 < a[i]) {
            if (a1 < a[i]) {
                a2 = a1;
                a2num = a1num;
                a1 = a[i];
                a1num = i;
            }
            else {
                a2 = a[i];
                a2num = i;
            }
        }
        if (b2 < b[i]) {
            if (b1 < b[i]) {
                b2 = b1;
                b2num = b1num;
                b1 = b[i];
                b1num = i;
            }
            else {
                b2 = b[i];
                b2num = i;
            }
        }
    }
    if (a1num != b1num) {
        cout << n / 2 - a1 + n / 2 - b1 << endl;
    }
    else {
        if (a2 < b2) {
            cout << n / 2 - a1 + n / 2 - b2 << endl;
        }
        else {
            cout << n / 2 - a2 + n / 2 - b1 << endl;
        }
    }
    return 0;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        ans += max(0, v[i]-c[i]);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
def f(x):
    a=0
    while x!=0:
        a += x%10
        x = int(x/10)
    return a
n,a,b = map(int,input().split())
sum = 0
for i in range(1,n+1):
    if a <= f(i) <= b:
        sum += i
print(sum)

Measured memory_bytes: 3060
n=int(input())
a=0
l = {}
for i in range(1,10):
  for j in range(1,10):
    l[(i,j)] = 0

if n > 10:
  for i in range(1,10):
    l[(i,i)] = 1
  a = 9
  for i in range(10,n+1):
    s = str(i)
    if s[-1] != '0':
      a += 2*l[(int(s[-1]),int(s[0]))]
      l[(int(s[0]),int(s[-1]))] += 1
      if s[-1] == s[0]:
        a += 1
else:
  a = n

print(a)

Measured memory_bytes: 41196
#include <iostream>
#include <cmath>

using namespace std;

//13 = 1101

void binary(int *a, int n, int count){
  int i = 0;
  int m = n;
  while(n > 0){
    a[i] = n%2;
    n /= 2;
    i++;
  }
  //cout << "n=" << m <<endl;
  for(i=0; i<10; i++)
    if(a[i] == -1)
      a[i] = 0;
  /*for(i=0; i<count; i++)
    cout << a[i] << " " ;
    cout << endl;*/
}


void initialization(int *a, int num){
  for(int i=0; i<num; i++)
    a[i] = 0;
}


int main(){
  int N, M;
  cin >> N >> M;
  int k[M];
  int s[M][N];
  int i, j, l;
  for(i=0; i<M; i++){
    cin >> k[i];
    for(j=0; j<k[i]; j++)
      cin >> s[i][j];
  }
  int p[M];
  for(i=0; i<M; i++)
    cin >> p[i];

  int count = 0;
  int count_on[M] = {0};
  int bit_arr[10];
  int all_on_flag = 0;
  for(i=0; i<pow(2, N); i++){
    //bit_arr[]を-1で初期化する
    initialization(bit_arr, 10);
    initialization(count_on, M);
    //iを二進数表記でbit_arrに格納する
    binary(bit_arr, i, pow(2, N) );
    //電球jを見ていく
    for(j=0; j<M; j++){
      //電球jに接続されたスイッチlを見ていく
      for(l=0; l<k[j] ; l++)
	if(bit_arr[ s[j][l]-1 ] == 1){
	  count_on[j]++;
	  //cout << "電球"<<j+1 << " : スイッチ" <<s[j][l]<< endl;
	}
      if(count_on[j]%2 == p[j])
	continue;
      else
	break;
    }
    if(j == M && count_on[j-1]%2 == p[j-1])
      count++;
  }

  cout << count << endl;
    
  return 0;
}


Measured memory_bytes: 256
N = int(input())
mod_num =int(1.0e+9+7)

all_num = pow(10,N,mod=mod_num)
not09_num = pow(9,N,mod=mod_num)
both09_num = pow(8,N,mod=mod_num)
print((all_num-not09_num*2+both09_num)%mod_num)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
long int N,K,H[200001];

int main(){
    cin >> N >> K;
    for (int i=0;i<N;i++) cin >> H[i];
    
    sort(H,H+N);
    long int count;
    for (int i= 0;i<N-K;i++) count += H[i];
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::max;
use std::io;

fn main() {
    let input = input_number();
    let _n = input[0] as usize;
    let ai = input_number();

    if let Some(_) = ai.iter().find(|x| **x == 0) {
        println!("0");
        return;
    }

    let mut result = 1u64;
    let checker = 1000000000000000000u64;
    for value in ai {
        if value <= checker / result {
            result = result * value;
        } else {
            println!("-1");
            return;
        }
    }
    println!("{}", result);
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn input_number() -> Vec<u64> {
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<u64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (char, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: char = iter.next().unwrap().chars().nth(0).unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    (c, n)
}


Measured memory_bytes: 4852
<?php
	$n = trim(fgets(STDIN));
	$s = trim(fgets(STDIN));
	$t = trim(fgets(STDIN));
	$f = false;
	
	for($i=0; $i<$n; $i++){
	    if(substr($s, $i) == substr($t, 0, $n - $i)){
	        echo $n + $i;
	        $f = true;
	        break;
	    }
	}
	if(!$f) echo $n * 2;
?>

Measured memory_bytes: 4728
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

a,b = map(int, input().split())

if b % a == 0:
    print(a+b)
else:
    print(b-a)






Measured memory_bytes: 9152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		for (int i = 0; i < s.length(); i++) {
			if (i % 2 == 0) {
				if (s.charAt(i) == 'L') {
					System.out.println("No");
					return;
				}
			} else {
				if (s.charAt(i) == 'R') {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int a[509],n,k;
bool solve(int v) {
	vector<long long>vv;
	vector<long long>ss;
	for(int i=0;i<n;i++) vv.push_back(a[i]%v);
	sort(vv.begin(),vv.end());
	ss.push_back(0);
	for(int i=0;i<n;i++) ss.push_back(ss.back()+vv[i]);
	for(int i=0;i<n;i++) {
		long long a=ss[i],b=1ll*(n-i)*v-(ss[n]-ss[i]);
		if(max(a,b)<=k) return 1;
	}
	return 0;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int s=0,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		s+=a[i];
	}
	for(int i=1;i*i<=s;i++)
		if(s%i==0) {
			if(solve(i)) ans=max(ans,i);
			if(solve(s/i)) ans=max(ans,s/i);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2019-12-13 15:05:09
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int ans = N;
    for (int i = 0; i < N-1; i++) {
        if (S[i] == S[i+1]) ans--;
    }

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


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];
bool p[125252];
bool q[125252];

void fail(){
  puts("-1");
  exit(0);
}

vi ch[125252];

int dfs(int x){
  int ret = 1;
  for(int to : ch[x]){
    int sz = dfs(to);
    if(!p[sz])fail();
    q[sz] = q[n-sz] = true;
    ret += sz;
  }
  return ret;
}

int main(){
  scanf("%s",s);
  n = strlen(s);
  p[0] = false;
  REP(i,n)p[i+1] = s[i]=='1';
  if(p[0] || p[n])fail();
  if(!p[1])fail();
  REP(i,n+1)if(p[i] != p[n-i])fail();
  vi children(1,0);
  FOR(i,1,n){
    if(p[i+1] || i==n-1){
      // connect
      ch[i] = children;
      children = vi();
    }
    children.push_back(i);
  }
  assert(children.size() == 1);
  int root = children.back();
  // check
  dfs(root);
  REP(i,n+1)if(p[i]!=q[i])fail();
  // ok
  REP(i,n)for(int j:ch[i]){
    printf("%d %d\n",i+1,j+1);
  }
  return 0;
}


Measured memory_bytes: 10880
N, Y = map(int, input().split())

ans = [-1, -1, -1]
for i in range(Y//1000+1):
    for j in range(Y//5000+1):
        k = (Y - 10000*i - 5000*j)//1000
        if k < 0:
            break
        if i + j + k == N:
            ans = i, j, k
# print(10000*ans[0] + 5000*ans[1] + 1000*ans[2])
print(*ans)


Measured memory_bytes: 40668
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int K,T;
int a[100];
int max_num;
int idx;
int ans;

int main(void){

	scanf("%d%d",&K,&T);

	for (int i = 0; i < T; ++i){
		scanf("%d",a+i);
		if(max_num<a[i]){
			max_num=a[i];
			idx=i;
		}
	}

	for (int i = 0; i < K; i++){
		a[idx]--;
		int max_tmp=0,idx_tmp;
		for(int j=0;j<T;j++){
			if(idx!=j){
				if(max_tmp<a[j]){
					max_tmp=a[j];
					idx_tmp=j;
				}
			}
		}
		if(max_tmp>0){
			max_num=max_tmp;
			idx=idx_tmp;
		}else{
			if(a[idx]>0){
				ans++;
			}
		}
	}


	printf("%d\n",ans);					

	return 0;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,k = map(int, input().split())

bp = []
for i in range(30):
    bp.append(1/2**i)

res = 0
for i in range(1,n+1):
    if i>=k:
        res += 1/n
        continue
    x = i
    cnt = 0
    while x<k:
        x *= 2
        cnt += 1
    res += bp[cnt]/n

print("{:.12f}".format(res))


Measured memory_bytes: 2940
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		String s = sc.next();
 		//AとB両方含む
      	if(s.contains("A") && s.contains("B")){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
     }
}

Measured memory_bytes: 35584
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h,w,k,a=0,u[300][300],ok,L;
vector<ll> v,v1;
string s[300];
int main(void){
    cin>>h>>w>>k;
    for(int i=0;i<h;i++){
        cin>>s[i];
        ok=0;
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                v.push_back(i);
                ok=1;
                break;
            }
        }
        if(ok==0){
            v1.push_back(i);
        }
    }
    for(int i=0;i<v.size();i++){
        L=0;
        for(int j=0;j<w;j++){
            if(s[v[i]][j]=='.'){
                if(L==0)u[v[i]][j]=a+1;
                else u[v[i]][j]=a;
            }
            else{
                a++;
                u[v[i]][j]=a;
                L=1;
            }
        }
    }
    if(v[0]!=0){
        for(int i=0;i<w;i++){
            u[v1[0]][i]=u[v[0]][i];
        }
    }
    for(auto x:v1){
        if(u[x][0]==0){
            for(int i=0;i<w;i++){
                u[x][i]=u[x-1][i];
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<u[i][j]<<" ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>

#define MAX 11

int main(){
    int a;
    char boja[MAX];
    
    scanf("%d%s", &a, boja);
    if(a<3200)
        printf("red\n");
    else
        printf("%s\n", boja);
    
    exit(EXIT_SUCCESS);
}


Measured memory_bytes: 128
/*
  Contest 077
  B - Around Square
  Rakesh Kumar --> 11/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    const int t = static_cast<int>(std::sqrt(n));
    std::cout << t * t << std::endl;

    return 0;
}


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

int main()
{
    int N,K,Q;
    std::cin >> N >> K >> Q;
    int ans[Q];
    int A[N];
    for(int i=0;i<Q;i++){
        std::cin >> ans[i];
    }

    for(int i=0; i<N; i++){
       A[i]=0;
    }

    for(int i=0; i<Q; i++){
        A[ans[i]-1]+=1;
    }

    for(int i=0; i<N; i++){
        if(A[i]+K-Q<=0){
            std::cout << "No" << std::endl;
        } else{
            std::cout << "Yes" << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i,o=0;
  string s;
  cin>>s;
  for(i=0;i<4;i++){
    if(s[i]=='+')o++;
    else if(s[i]=='-') o--;
  }
  cout<<o<<endl;
  return 0;
}


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

int main(){

    char c[2][3];

    for (int i = 0; i < 2; i++){
        for (int j = 0; j < 3; j++){
            
            cin >> c[i][j];
        }    
    }

    if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
    {
        cout << "YES" << endl;
    }else
    {
        cout << "NO" << endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    cin >> A >> B >> K;
    
    vector<int> a;
    for(int i=0;i<K;i++){
        a.push_back(A+i);
    }
    for(int i=K-1;i>=0;i--){
        a.push_back(B-i);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<a.size()-1;i++){
        if(a.at(i) != a.at(i+1) && a.at(i) >= A && a.at(i) <= B){
            cout << a.at(i) << endl;
        }
    }
    if(a.at(a.size()-1)>=A && a.at(a.size()-1)<=B){
        cout << a.at(a.size()-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
struct UnionFind {
	int *par;
	int *rank;
	int size;
	UnionFind(int n) :size(n) {
		par = new int[size];
		rank = new int[size];
		for (int i = 0; i < size; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	void clear() {
		for (int i = 0; i < size; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
};
LL mod_pow(LL a, LL n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		LL x = mod_pow(a, n / 2);
		return (x*x) % MOD;
	}
	return (a*mod_pow(a, n - 1)) % MOD;
}
LL MST[2000];
int N, M;
LL F(LL X) {
	int c = 0;
	for (int i = 0; i < M; i++) {
		if (MST[i] <= X) c++;
	}
	if (c == 0) return mod_pow(2, M);
	return mod_pow(2, M - c + 1);
}
int main() {
	cin >> N >> M;
	LL X;
	cin >> X;
	vector<E> edge;
	for (int i = 0; i < M; i++) {
		int U, V, W;
		cin >> U >> V >> W;
		U--; V--;
		edge.push_back(E(W, P(U, V)));
	}
	sort(edge.begin(), edge.end());
	UnionFind U(N);
	for (int i = 0; i < edge.size(); i++) {
		LL sum = edge[i].first;
		U.unite(edge[i].second.first, edge[i].second.second);
		for (int j = 0; j < edge.size(); j++) {
			if (i == j) continue;
			if (!U.same(edge[j].second.first, edge[j].second.second)) {
				U.unite(edge[j].second.first, edge[j].second.second);
				sum += edge[j].first;
			}
		}
		MST[i] = sum;
		U.clear();
	}
	LL ans = F(X - 1);
	ans = (ans - F(X) + MOD) % MOD;
	cout << ans << endl;
}

Measured memory_bytes: 256
/**In the name of ALLAH*/

#include<bits/stdc++.h>

using namespace std;
#define pri(n)          printf("%d\n",n)
#define prll(n)         printf("%lld\n",n)
#define prd(n)          printf("%lf\n",n)
#define scll(n)         scanf("%lld",&n)
#define sci(n)          scanf("%d",&n)
#define scd(n)          scanf("%lf",&n)
#define pi              acos(-1)
#define ll              long long
#define pb              push_back
#define vsort(v)        sort(v.begin(),v.end())
#define asort(n)        sort(ar,ar+n)
#define for1(i,n)       for(i=1;i<=n;i++)
#define for0(i,n)       for(i=0;i<n;i++)
#define mod             1000000007
#define watch(x)        cout << (#x) << " is " << (x) <<"\n";
#define yes             cout<<"YES\n"
#define no              cout<<"NO\n"
#define LIMIT           100000 /**upto 10^8*/

ll xorr(ll n)
{
    if(n%4==0) return n;
    else if(n%4==1) return 1;
    else if(n%4==2) return n+1;
    else return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);/**Dont't use scanf of printf*/
    ll t,i,pro,x,k,j,a,b,cnt,q,sum,index,r,n;
    cin>>a>>b;
    if(a<=1) a==0;
    else a--;
    cout<<(xorr(b)^xorr(a))<<endl;



    return 0;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int N = sc.nextInt();
		
		int[] arr = new int[N];
		int sum = 0;
		
		for(int i = 0 ; i < N ; i++){
			arr[i] = sc.nextInt();
			sum += arr[i];
		}

		sc.close();
		
		int aver = sum / N;
		
		int value = calculateDiff(arr, aver);
	
		value = Math.min( calculateDiff(arr, aver + 1), value );
		
		System.out.println(value);
	}

	static int calculateDiff(int[] arr, int aver) {
		int diff = 0;
		
		for(int i = 0 ; i < arr.length ; i++){
			diff += ((arr[i] - aver) * (arr[i] - aver));
		}
		
		return diff;
	}
}


Measured memory_bytes: 9680
#include <bits/stdc++.h>
#define INF (1LL << 60)
#define int long long
#define mod 1000000007
using namespace std;

int A[100000];

int dp[101][100001];
int dp2[100001];
int32_t main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		dp2[0] = 1;
		for(int j = 1; j <= A[i-1]; j++){
			dp2[j] = dp2[j-1] + dp[i-1][j]; 
		}
		for(int j = A[i-1] + 1; j <= k; j++){
			dp2[j] = dp2[j-1] + dp[i-1][j] - dp[i-1][j - A[i-1] - 1]; 
		}
		for(int j = 0; j <= k; j++){
			dp[i][j] = dp2[j];
			dp[i][j] %= mod;
		}
	}
	cout << dp[n][k] << endl;
}

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

int main() {
  int a; 
  int b;
  int c;
  int d;
  
  cin >> a >> b >> c >> d ; 
  
  if ((a <= b) && (c <= d)){
    cout << a+c << endl;
  }
    else if ((a>b)&&(c<=d)){
      cout << b + c << endl;
    }
      else if ((a >b) && (c > d)) {
        cout << b+d << endl;
      }
        else {
          cout << a+d<< endl;
        }
}
  
   
 




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.s<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

void solve()
{
	int n;
	int d[MAXN];
	// cin>>a>>b;
	cin>>n;
	rep(i,n) cin>>d[i];
	ll ans = 0;
	for(int i = 0 ; i < n ; i ++){
		for(int j = i+1 ; j < n ; j++ )
			ans+=d[i]*d[j];
	}

	cout<<ans<<endl;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/

/*==================================================*/

long long N, A[10];

long long  ans = 1, odd = 1;

int main() {
    cin>>N;
    REP(i,0,N){
        cin>>A[i];
        if(A[i] % 2 != 0) odd *= 1;
        else odd *= 2;
        ans *= 3;
    }

    ans -= odd;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<=1500;i++){
            if (i*8/100==a&&i/10==b)ans=Math.min(ans,i);
        }
        if (ans==Integer.MAX_VALUE)System.out.println("-1");
        else System.out.println(ans);
    }
    static long factorial(long num){
        if (num<2)return 1;
        else return num*factorial(num-1);
    }
    static int arraySum(int[] array){
        int ans = 0;
        for (int value : array) ans += value;
        return ans;
    }
    static long combination(long a, long b){
        long data = 1;
        for (int i=0;i<b;i++){
            data*=a-i;
        }
        return data/factorial(b);
    }
    static double log(double base,double antilogarithm){
        return Math.log(antilogarithm)/Math.log(base);
    }

    static long gcd(long x,long y){
        if (y==0)return x;
        else return gcd(y,x%y);
    }
    static long lcm(long x,long y){
        return x/gcd(x,y)*y;
    }
    static HashMap<Long,Long> factorization(long num){
        HashMap<Long,Long> hash = new HashMap<>();
        long n = num;
        long count = 2;
        while (n>1){
            while (n%count==0){
                n/=count;
                if (hash.containsKey(count))hash.put(count,hash.get(count)+1);
                else hash.put(count,1L);
            }
            count++;
        }
        return hash;
    }

}


Measured memory_bytes: 35676
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}
// https://algo-logic.info/divisor/
/// 約数の配列を返す
func divisor(_ n:Int) -> [Int] {
    var ret = [Int]()
    var i = 1
    while i * i <= n {
        if n % i == 0 {
            ret.append(i)
            if i * i != n {
                ret.append(n / i)
            }
        }
        i += 1
    }
    return ret.sorted()
}

func main() {
    let S = readLines()
    let T = readLines()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿入力
    var ans = 1000
    
    let length = S.count == T.count ? 1: S.count - T.count
    for i in 0..<length {
        var cnt = 0
        for j in 0..<T.count {
            if S[i + j] != T[j] {
                cnt += 1
            }
        }
        ans = min(ans, cnt)
    }
    print(ans)
}
main()



Measured memory_bytes: 13228
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define prl pair<ll,ll>
#define pri pair<int,int>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define db double
#define N 100005
#define mod 1000000007
#define INF 2147483647
using namespace std;
mt19937 mrand(random_device{}());
uniform_int_distribution<ll> dist(0, 100000000);
ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }
ll qpow(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }

int main() {
	IOS;
	int n,ans=0;
	ll d;
	cin >> n>>d;
	d *= d;
	rep(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		if (a * a + b * b <= d)ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){ 
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N)scanf("%lld", &a[i]);

    ll count = 0;
    rep(i, N){
        while(a[i]%2 == 0){
            count++;
            a[i]/=2;
        } 
    }
    cout << count;

}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long

int main(){
  int card[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      scanf("%d",&card[i][j]);
    }
  }
  int n,i,j,k,w;
  scanf("%d",&n);
  int b[n];
  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  
  for(i = 0; i < 3; i++){
   for(j = 0; j < 3; j++){
     for(k=0;k<n;k++){
    if(card[i][j] == b[k]){
      card[i][j] = 0;
    }
    }
   }
  }
  
    for(i = 0; i < 3; i++){
w = 0;
for(j = 0; j < 3; j++){
w += card[i][j];
}
if(w == 0){
printf("Yes");
  return 0;
}
}

for(i = 0; i < 3; i++){
w = 0;
for(j = 0; j < 3; j++){
w += card[j][i];
}
if(w == 0){
printf("Yes");
  return 0;
}
}

w = 0;
for(i = 0; i < 3; i++){
w += card[i][i];
}
if(w == 0){
printf("Yes");
  return 0;
}

w = 0;
for(i = 0; i < 3; i++){
w += card[i][2 - i];
}
if(w == 0){
printf("Yes");
  return 0;
}

printf("No");
  return 0;
}

Measured memory_bytes: 128
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1e15+7;
const ll mod = 1e9 + 7;
const int MAX_N = 1e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<int>> kake(vector<vector<int>> &tim1,vector<vector<int>> &tim2) {
	vector<vector<int>> res = vector<vector<int>>(tim1.size(),vector<int>(tim1[0].size(),0));
	REP (i,tim1.size()) {
		REP (j,tim1[0].size()) {
			REP (k,tim2[0].size()) {
				res[i][k] += tim1[i][j] * tim2[j][k];
				res[i][k] %= mod;
			}
		}
	}
	return res;
}

class UnionFind {
private:
	vector<int> par;
public:
	vector<int> color;
	UnionFind(int N) { par = vector<int>(N, -1LL); color = vector<int>(N,-1);}
	int find(int x);
	ll size(int x);
	bool unite(int x, int y);
	bool same(int x, int y);
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

bool UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
	if (color[x] != -1 && color[y] != -1 && color[x] != color[y]) return false;
	else if (color[x] == -1 && color[y] != -1) color[x] = color[y];
	return true; 
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

signed main() {
	double n,k; cin >> n >> k;
	double ans = 0;
	FOR (i,1,n+1) {
		int cnt = 0;
		int p = i;
		while (p < k) {
			p *= 2;
			cnt++;
		}
		double tmp = 1/n;
		REP (i,cnt) {
			tmp *= 0.5;
		}
		ans += tmp;
	}
	cout << fixed;
	cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < n; i++) {
			int h = sc.nextInt();
			if(h >= k)
				ans++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 50916
#define _GLIBCXX_DEBUG //GCC環境での[]デバッグ
#include <bits/stdc++.h> //全ての標準ライブラリ
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
int sumVector (const std::vector<int>& v){ //int配列計算
    int sum = 0;
    rep(i, v.size()) sum += v.at(i);
    return sum; 
}
int main(void){
    int n; 
    cin >> n;
    std::vector<long long> l(n+1);
    l[0] = 2;
    l[1] = 1;
    for(int i = 2; i <= n; i++){
        l[i] = l[i-1] + l[i - 2];
    }
    cout << l[n];
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char a[100008];
int main()
{
	scanf("%s",a);
	int t=strlen(a);
	int sum=0;
	for(int i=0;i<t;i++)
	{
	if(a[i]=='p')
	sum++;	
	}
	printf("%d\n",t/2-sum);
	
	
	
}

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

char str[100009];

int main()
{
    scanf("%s",str);
    int n = strlen(str);
    int l = 0, r = n-1, ans = 0;
    while(l < r) {
        if(str[l] == str[r]) {
            ++l; --r;
            continue;
        }
        if(str[l] == 'x') {
            ++l; ++ans;
            continue;
        }
        if(str[r] == 'x') {
            --r; ++ans;
            continue;
        }
        return !printf("-1");
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define inf 111111111
using namespace std;

int main()
{
    vector <int> a(200001);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a.begin() + 1, a.begin() + n + 1);
    for (int i = 2; i <= n; ++i)
    {
        if (a[i] == a[i - 1])
        {
            cout << "NO"; return 0;
        }
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 1024
A, B, C = map(int, raw_input().split())
a = abs(A - B)
b = abs(B - C)
c = abs(C - A)
count = 0
if ((A | B | C) & 1 == 0):
    while((a | b | c) & 1 == 0):
        if(a + b + c) == 0:
            count = -1
            break
        a /= 2
        b /= 2
        c /= 2
        count = count + 1
print count



Measured memory_bytes: 2568
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 5 + 1)


class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))

    def is_same_set(self, x: int, y: int) -> bool:
        return self.find_root(x) == self.find_root(y)

    def union_set(self, x: int, y: int):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return

        self.parent[x] = y

    def find_root(self, x: int):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find_root(self.parent[x])
            return self.parent[x]


def main():
    N, K, L = map(int, input().split())
    uf1 = UnionFind(N)
    for _ in range(K):
        p, q = map(int, input().split())
        p -= 1
        q -= 1
        uf1.union_set(p, q)

    uf2 = UnionFind(N)
    for _ in range(L):
        r, s = map(int, input().split())
        r -= 1
        s -= 1
        uf2.union_set(r, s)

    groups = [(uf1.find_root(i), uf2.find_root(i)) for i in range(N)]
    c = Counter(groups)

    print(*(c[g] for g in groups))


if __name__ == '__main__':
    main()

Measured memory_bytes: 55908
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        long A = scan.nextLong();
        long B = scan.nextLong();
        long diff = B - A;
        long ans = Long.MAX_VALUE;
        if (diff % 2 == 0) {
            ans = Math.min(ans, diff / 2);
            ans = Math.min(N - A, ans);
            ans = Math.min(B - 1, ans);
        } else {
            ans = Math.min(N - A, ans);
            ans = Math.min(B - 1, ans);
            long x = Math.min(A - 1, N - B) + 1 + (B - A - 1) / 2;
            ans = Math.min(x, ans);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
n,m,x,y = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = max(a)
b = min(b)
if (a<b and a+1>x and a+1<=y):
  print("No War")
else:
  print("War")

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<math.h>
#define scani(x) scanf("%d",&x)
#define scanc(x) scanf("%s",x)
#define printi(x) printf("%d",x)
#define printin(x) printf("%d\n",x)
#define printc(x) printf("%s",x)
#define repd(i,n,m) for(int i = n; i > m; i--)
#define repu(i,n,m) for(int i = 0; i < m; i++)
#define allprintu(i,n,m,a) for(int i = 0; i < m; i++){if(i != m-1){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
#define allprintd(i,n,m,a) for(int i = n; i > m; i--){if(i != 0){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
#define cnt 2000000

struct node{
	unsigned int key;
	struct node *prev, *next;
};
typedef struct node* NodePointer;
NodePointer nil;

void InIt(){
	nil = (NodePointer)malloc(sizeof(NodePointer));
	nil->next = nil;
	nil->prev = nil;
}

NodePointer ListSearch(int key){
	NodePointer p = nil->next;
	while(1){
		if(p == nil) break;
		if(p->key == key){
			return p;
		}
		p = p->next;
	}
	return NULL;
}

void DeleteNode(NodePointer p){
	if(p == nil) return;
	p->prev->next = p->next;
	p->next->prev = p->prev;
	free(p);
}

void Insert(int key){
	NodePointer p;
	p = (NodePointer)malloc(sizeof(NodePointer));
	p->key = key;
	nil->next->prev = p;
	p->next =nil->next;
	p->prev = nil;
	nil->next = p;
}

void Delete(int key){
	NodePointer p = ListSearch(key);
	if(p != NULL){
		DeleteNode(p);
	}


}
void DeleteFirst(){
	NodePointer p = nil->next;
	if(p == nil) return;
	DeleteNode(p);
}

void DeleteLast(){
	NodePointer p = nil->prev;
	if(p == nil) return;
	DeleteNode(p);
}



void PrintList(){
	NodePointer cur = nil->next;
	int isf = 1;
	while(1){
		if(cur == nil) break;
		if(isf == 0) printf(" ");
		printf("%d",cur->key);
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}


int main(void){
	int n,key;
	int size = 0;
	char com[20];
	int np = 0; 
	int nd = 0;
	scani(n);
	InIt();
	repu(i,0,n){
		scanf("%s%d",com,&key);
		if(com[0] == 'i'){
			Insert(key);
			np++;
			size++;
		}else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F') DeleteFirst();
				else if(com[6] == 'L') DeleteLast();
			}else{
				Delete(key);
				nd++;
			}
			size--;
		}
	}
	PrintList();
	return 0;
}


Measured memory_bytes: 32936
import sys
a,b=map(int,input().split())
S=input()
for i in range(a):
  if(not S[i].isdigit()):
    print("No")
    sys.exit()
if(S[a]!="-"):
  print("No")
  sys.exit()
for i in range(b):
  if(not S[a+i+1].isdigit()):
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <limits>

using namespace std;

template<class T = int,T divided_by = 10>
constexpr T PINF(){ return std::numeric_limits<T>::max()/divided_by; }
template<class T = int,T divided_by = 10>
constexpr T MINF(){ return std::numeric_limits<T>::lowest()/divided_by; }

template<class T = int> T gcd(T a, T b){ return b ? gcd(b,a%b) : a; }
template<class T = int> T lcm(T a, T b){ return a / gcd(a,b) * b; }
template<class T = int> T lcm_safe(T a, T b){ T p = a/gcd(a,b); return (b <= PINF<T>()/p) ? p*b:PINF<T>(); }
//オーバーフローするとき+INFを返す
//
int main() {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;

	vector<set<int>> v(n);
	for(int i = 0; i < m; ++i){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		v[a].insert(b);
		v[b].insert(a);
	}

	vector<vector<int>> seqs(100000, vector<int>());

	vector<int> nodes(n-1);
	for(int i = 0; i < nodes.size(); ++i){
		nodes[i] = i+1;
	}
    int ans = 0;
    do {
    	// for(auto nextNode : nodes) cout << nextNode << " "; cout << "\n";    // v の要素を表示
    	int curNode = 0;
    	bool isOk = true;
        for(auto nextNode : nodes) {
        	bool hasNextNode = v[curNode].find(nextNode) != v[curNode].end();
        	isOk = isOk && hasNextNode;

        	curNode = nextNode;
        }
        if(isOk) ans++;
    } while( next_permutation(nodes.begin(), nodes.end()) );     // 次の順列を生成

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=1e5+5;
int n;
ll s[N],res;

void check(int skip){
	ll sum=0;
	set<int> vst;
	for(int k=0;k*skip<n;++k){
		vst.insert(k*skip);
		if(k==0){
			sum=s[0]+s[n-1];
			res=max(res,sum);
			continue;
		}
		sum+=s[n-1-k*skip]+s[k*skip];
		int a=n-1-k*skip;
		int b=a-skip;
		if(b<1||b>=a) continue;
		if(vst.find(a)!=vst.end()) continue;
		res=max(res,sum);
	}
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	REP(i,n) cin>>s[i];
	FOR(z,1,n-1) check(z);
	cout<<res<<'\n';
}



Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define A first
#define B second
 
const ll inf = (1LL<<60);
const ll p = 1e9+7;
 
ll f[205], q, x, y;
int m;
 
inline ll mult(ll a, ll b) {
    if (a == 0 || b == 0)
        return 0;
    if (a >= inf/b)
        return inf;
    return a*b;
}
 
//do k steps starting at a, b
inline pii val(ll a, ll b, ll k) {
    if (a == 0 && k > 0) {
        a = 2*b;
        swap(a, b);
        k--;
    }
    if (k == 0)
        return pii(a, b);

    return pii(mult(f[k-1], a)+mult(f[k], b), mult(f[k], a)+mult(f[k+1], b));
}

ll comp(ll a, ll b, ll n) {
    ll tot = 0;
 
    pii t = val(0, 1, n-1);
    if (t.B > a)
        return 0;
    tot = (tot + (b-t.A)/t.B)%p;
    for (int i = 1; i <= n-1; ++i) {
        t = val(0, 1, i-1);
        if (i == 1)
            t.A += 3*t.B;
        else
            t.A += 2*t.B;
        swap(t.A, t.B);
        if (t.A > inf || t.B > inf)
            continue;
        t = val(t.A, t.B, n-1-i);
        if (t.B > a)
            continue;
        tot = (tot + (b-t.A)/t.B)%p;
    }
 
    return tot;
}
 
void doit() {
    scanf("%lld%lld", &x, &y);
    if (x > y)
        swap(x, y);
    int n;
    if (x == y && x == 1)
        n = 1;
    else {
        for (int i = 2; i <= m; ++i) {
            if (f[i] > x || f[i+1] > y) {
                n = i-2;
                break;
            }
        }
    }
 
    ll ans = 0;
    for (int i = 1; i <= 2; ++i) {
        ans = (ans + comp(x/i, y/i, n) + comp(y/i, x/i, n))%p;
    }
 
    if (n == 1)
        ans = (ans + p - min(x, y))%p;
 
    printf("%d %d\n", n, ans);
}

int main() {
    f[0] = 0, f[1] = 1, f[2] = 1;
    for (int i = 3; i < 205; ++i) {
        f[i] = f[i-1] + f[i-2];
        if (f[i] > inf) {
            m = i;
            break;
        }
    }
 
    scanf("%lld", &q);
    for (int i = 0; i < q; ++i)
        doit();
}

Measured memory_bytes: 3968
M, D = map(int, input().split())
m_list = {m for m in range(1, M + 1)}
ans = 0
 
for d in range(11, D+1):
  d_10 = int(d/10)
  d_1 = d - (d_10 * 10)
  if (d_10 < 2) or (d_1 < 2):
    continue
  else:
    if (d_10 * d_1) in m_list:
      ans += 1
      
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int N;
	cin >> N;
	if (N % 2 == 0) {

		cout << N/2  << endl;
	}
	else {

		cout << 1+(N/2)  << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N;
		cin >> N;

		vector<int> X( N ), L( N );
		for( int i = 0; i < N; ++i ) { cin >> X[i] >> L[i]; }

		vector<pair<int, int>> rl( N );
		for( int i = 0; i < N; ++i ) {
			rl[i] = { X[i]+L[i], X[i]-L[i] };
		}
		sort( rl.begin(), rl.end() );

		int ans = 0;
		int x = -INT_MAX;
		for( int i = 0; i < N; ++i ) {
			if( x <= rl[i].second ) {
				ans += 1;
				x = rl[i].first;
			}
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 1792