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

int main() {

	int d; cin >> d;
	string  ans;
	if (d == 25) ans = "Christmas";
	if (d == 24) ans = "Christmas Eve";
	if (d == 23) ans = "Christmas Eve Eve";
	if (d == 22) ans = "Christmas Eve Eve Eve";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
fn read1<T: std::str::FromStr>() -> T {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        s.trim().parse().ok().unwrap()
    }
     
    pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
        let s = read1::<String>();
        s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
    }
     
    fn main() {
        let nk = readn::<usize>(" ");
        let mut n = nk[0];
        let mut k = nk[1];
     
        let mut x = readn::<isize>(" ");
        let zero = match x.binary_search(&0) {
            Ok(p) => {
                k -= 1;
                p
            },
            Err(p) => {
                x.insert(p, 0);
                n += 1;
                p
            }
        };
        let mut l = (0..zero).rev().map(|i| -x[i] as usize).collect::<Vec<usize>>();
        let mut r = (zero+1..n).map(|i| x[i] as usize).collect::<Vec<usize>>();
        l.insert(0, 0);
        r.insert(0, 0);
        
        let minr = if k < zero {
            0
        } else {
            k - zero
        };
        let maxr = if k < n - zero - 1 {
            k
        } else {
            n - zero - 1
        };
     
        let mut ans = 1_000_000_000;
        for i in minr..maxr+1 {
            ans = std::cmp::min(std::cmp::min(r[i] + 2 * l[k-i], 2 * r[i] + l[k-i]), ans);
        }
     
        println!("{}", ans);
    }

Measured memory_bytes: 9464
#入力
N = int(input())

t = []
x = []
y = []

i = 0
while i<N:
    
    a, b, c = map(int, input().split(" "))
    t.append(a)
    x.append(b)
    y.append(c)

    i += 1

    
#tの値と同数だけ判断基準2を通過すればよいので、それを判断するためのフラグを設定
flag_yes = 0
    
#判断基準1（t秒後の座標xとyを足した値が、そのtの値以下かどうか）
for (num_t, num_x, num_y) in zip(t, x, y):
    
    #フラグを設定
    flag = 0
    
    #座標xとyを足した値
    sum_xy = num_x + num_y
    
    #判定
    if num_t>=sum_xy:
        flag += 1
        
    #判断基準2（tが偶数(奇数)であれば、座標xとyを足した値も偶数(奇数)であるかどうか）
    if num_t%2==0 and sum_xy%2==0 and flag==1:
        flag_yes += 1
        
    elif num_t%2==1 and sum_xy%2==1 and flag==1:
        flag_yes += 1
        
#tの値とflag_yesの値が一致していれば"Yes"、それ以外は"No"
if len(t)==flag_yes:
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 11808
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long n;
  cin >> n;
  --n;
  vector<char> ans;
  while (true) {
    long long d = n % 26ll;
    ans.push_back('a' + d);
    n /= 26ll;
    if (n == 0) break;
    --n;
  };
  
  for (auto i = ans.rbegin(); i < ans.rend(); ++i) {
    cout << *i;
  }
  cout << endl;
  return 0;
}


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

const int INF = 1e+9;
const int MAX_V = 100;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int n, m;

int prim(){
	for(int i=0 ; i < n ; i++ ){
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	int res = 0;
	while( true ){
		int v = -1;
		for(int u = 0 ; u < n ; u++ ){
			if( !used[u] && (v == -1 || mincost[u] < mincost[v]) )
				v = u;
		}
		
		if( v == -1 ) break;
		used[v] = true;
		res += mincost[v];
		
		for(int u = 0 ; u < n ; u++ ){
			mincost[u] = min( mincost[u] , cost[v][u] );
		}
	}
	return res;
}

int main(){
	while( cin >> n >> m , n || m ){
		for(int u = 0 ; u < n ; u++ ){
			for(int v = 0 ; v < n ; v++ ){
				cost[u][v] = cost[v][u] = INF;
			}
		}
		
		for(int i=0 ; i < m ; i++ ){
			int a, b, c;
			cin >> a >> b >> c;
			cost[a][b] = cost[b][a] = c;
		}
		int ans = prim();
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
s=0
for i in range(n):
  if s+a[i]<=x:
    ans+=1
  s+=a[i]
if s<x:
  print(ans-1)
else:
  print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
const int nax=1e5+5;
ll mod=1e9+7;
ll n,k;
vector<vector<int>> v(nax);
int vis[nax]={0};
ll arr[nax];
ll ans=1;
void dfs(int ci, int level){
	vis[ci]=1;
	ll st;
	if(level==0) st=k-1;
	else st=k-2;
	for(auto x : v[ci]){
		if(vis[x]==1) continue;
		arr[x]=st--;
		dfs(x,level+1);
	}
}
int main(){
/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
    */
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n>>k;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	arr[0]=k;
	dfs(0,0);
	for(int i=0;i<n;i++){
		ans=(ans*arr[i])%mod;
	}
	cout<<ans;
}


Measured memory_bytes: 10368
//Somar dígitos do input e dividir pelo próprio input;
#include<bits/stdc++.h>
using namespace std;

int soma_digitos(int n){
    int sum,digit;
    while(n){
        digit = n%10;
        n/=10;

        sum += digit;
    }
    return sum;
}

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

    if(n % soma_digitos(n) == 0)
        cout<<"Yes";
    else
        cout<<"No";
    
    return 0;
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589,da,db;
    int a,b;
    scanf("%d %d",&a,&b);
    da=static_cast<double>(a);
    db=static_cast<double>(b);
    printf("%d %d %.8lf\n",a/b,a%b,da/db);
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const ld Pi=acos(-1);
int nature(ll a){
  if(a>=0){return a;}
  else{return 0;}
}
int main(){
  ll H,W,answer=0;
  cin>>H>>W;
  vector<ll> vec(H*W);
  vector<char> way(H*W);
  for(ll i=0;i<H*W;i++){
    char cha;
    cin>>cha;
    way.at(i)=cha;
    vec.at(i)=i;
  }
  using Graph=vector<vector<ll>>;
  Graph G(H*W);
  for (ll i=0;i<H*W;++i){
    if(i%W!=W-1){if(way.at(i+1)=='.')G[i].push_back(i+1);}
    if(i%W!=0){if(way.at(i-1)=='.')G[i].push_back(i-1);}
    if(i>=W){if(way.at(i-W)=='.')G[i].push_back(i-W);}
    if(i<W*(H-1)){if(way.at(i+W)=='.')G[i].push_back(i+W);}
  }
  for(ll k=0;k<H*W;++k){
  if(way.at(k)=='.'){
  ll ans=0;
  vector<ll> dist(H*W,-1);//全頂点を「未訪問」に初期化
  queue<ll> que;
  dist[k]=0;
  que.push(k);
  while(!que.empty()){
    ll v=que.front();//キューから先頭頂点を取り出す
    que.pop();
    //v から辿れる頂点をすべて調べる
    for(ll nv:G[v]){
      if(dist[nv]!=-1)continue;//すでに発見済みの頂点は探索しない
      //新たな白色頂点 nv について距離情報を更新してキューに追加する
      dist[nv]=dist[v]+1;
      ans=max(dist[nv],ans);
      que.push(nv);
    }
  }
  answer=max(answer,ans);
  //cout<<ans<<endl;
  }
  }
  cout<<answer<<endl;
}

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

int main(){

    int N, allsum = 0 , s = 0, s_2 = 0;
    cin >> N;
    vector <int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
        allsum += A[i];
    }
    int mins = allsum;
    for (int i = 0; i < N; i++){
        s += A[i];
        s_2 = abs(allsum - s * 2);
        mins = min(mins, s_2);
    }
    cout << mins << endl;
}

Measured memory_bytes: 256
k = 72
kk = k // 4
K = 1<<k
nu = lambda L: int("".join([hex(K+a)[3:] for a in L[::-1]]), 16)
st = lambda n: hex(n)[2:]
li = lambda s, l, r: [int(a, 16) % P if len(a) else 0 for a in [s[-(i+1)*kk:-i*kk] for i in range(l, r)]]

def grow(d, v, h):
    h += [0] * d
    f = [(-1 if (i+d) % 2 else 1) * fainv[i] * fainv[d-i] % P * h[i] % P for i in range(d+1)]
    nuf = nu(f)
    a = d * inv[v] % P
    t = [1] * (3*d+3)
    for i in range(1, 3*d+3): t[i] = t[i-1] * (a - d + i - 1) % P
    ti = [1] * (3*d+3)
    ti[-1] = pow(t[-1], P-2, P)
    for i in range(1, 3*d+3)[::-1]: ti[i-1] = ti[i] * (a - d + i - 1) % P
    iv = [1] * (3*d+3)
    for i in range(1, 3*d+3):
        iv[i] = ti[i] * t[i-1] % P

    ###
    g = [inv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = fg[i] * fa[d+i+1] % P * fainv[i] % P

    ###
    g = [iv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d+1):
        h[i] = h[i] * (fg[i] * t[d+i+1] % P * ti[i] % P) % P

    ###
    g = [iv[i] for i in range(d+2, 3*d+3)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = h[i+d+1] * (fg[i] * t[2*d+i+2] % P * ti[d+i+1] % P) % P

    return h

# Create a table of the factorial of the first v+2 multiples of v, i.e., [0!, v!, 2v!, ..., (v(v+1))!]
def create_table(v):
    s = 1
    X = [1, v+1]
    while s < v:
        X = grow(s, v, X)
        s *= 2

    table = [1]
    for x in X:
        table.append(table[-1] * x % P)
    return table

def fact(i, table):
    a = table[i//v]
    for j in range(i//v*v+1, i+1):
        a = a * j % P
    return a

N, A, B = map(int, input().split())
P = 10**9+7

v = 1 << (N.bit_length() + 1) // 2
fa = [1] * (2*v+2)
fainv = [1] * (2*v+2)
for i in range(2*v+1):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(2*v+1)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
inv = [0] * (2*v+2)
for i in range(1, 2*v+2):
    inv[i] = fainv[i] * fa[i-1] % P

T = create_table(v)
C = lambda n, k: fact(n, T) * pow(fact(k, T) * fact(n-k, T), P-2, P) % P
 
print((pow(2, N, P) - 1 - C(N, A) - C(N, B)) % P)


Measured memory_bytes: 24796
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    B = [int(x) for x in input().split()]

    ans = []
    while len(ans) < N:
        cnt = 0
        cnti = -1
        for i in range(N):
            if B[i] == 0:
                cnt += 1
            else:
                if B[i] == i - cnt + 1:
                    cnti = i
        if cnti == -1:
            print(-1)
            return
        else:
            ans.append(B[cnti])
            B[cnti] = 0

    for a in ans[::-1]:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
ans = 0
for i in range(N):
    l, r = ri_()
    ans += r - l + 1
print(ans)

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		int[] L = new int[N];
		int[][] a = new int[N][2];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
			L[i] = sc.nextInt();
			a[i][0] = X[i]- L[i];
			a[i][1] = X[i] + L[i];
		}
		Arrays.sort(a, (x,y) -> x[1]-y[1]);
		int ans = 1;
		int p = a[0][1];
		for(int i = 1;i < N;i++){
			if(a[i][0] >= p){
				ans++;
				p = a[i][1];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 94492
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    vector<ll> fib(50);
    rep(i, 50) {
        if(i == 0 || i == 1) {
            fib[i] = 1;
        } else {
            fib[i] = fib[i-1] + fib[i-2];
        }
    }
    int n; cin >> n;
    cout << fib[n] << endl;
}



Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    a, b = [int(x) for x in input().split()]
    if a <= 0 and b >= 0:
        print("Zero")
    elif a > 0 and b > 0 or (b - a) % 2:
        print("Positive")
    else:
        print("Negative")

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()



"""

1 4
7
RRRR
1 1 0 1
----
4

1 4
47
RCRR
1 1 0 1
----
-1

2 2
10
RR
RR
1 7
4 1
----
4

2 2
10
RR
RR
7 4
7 4
----
-1

3 3
8
RCR
RRC
RRR
1 1 1
1 1 1
1 3 1


3 3
1
RCR
RRC
RRR
1 1 1
1 1 1
1 3 1


"""





Measured memory_bytes: 3316
#include <iostream>
#include <stack>
#include <string>

#define INPUT_FROM_FILE (0)

#if INPUT_FROM_FILE
#include <fstream>
#endif

#if INPUT_FROM_FILE
#define IS ifs
#else
#define IS std::cin
#endif

int calc(int operand0, int operand1, std::string op){
	if(op == "+"){
		return operand0 + operand1;
	}
	else if(op == "-"){
		return operand0 - operand1;
	}
	else if(op == "*"){
		return operand0 * operand1;
	}
}

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs = std::ifstream("test.txt");
#endif
	std::stack<int> stack;
	std::string str;

	while(IS >> str){
		if(str == "+" || str == "-" || str == "*"){
			int operand0 = 0;
			int operand1 = 0;

			operand1 = stack.top();
			stack.pop();
			operand0 = stack.top();
			stack.pop();
			stack.push(calc(operand0, operand1, str));
		}
		else{
			stack.push(std::stoi(str));
		}
	}

	std::cout << stack.top() << std::endl;
	return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){

    int n;
    string s;
    cin>>n>>s;
    vector<int> S(n);
    for(int i=0;i<n;i++){
        S[i] = s[i] - '0';
        //cout<<S[i]<<" ";
    }

    ll ans = 0;

    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=9;k++){
               // cout<<i<<j<<k<<endl;
                int piv = i;
                int count = 1;
                for(int l=0;l<n;l++){
                    if(piv == S[l] && piv == i && count == 1) {piv = j; count++;}
                    else if(piv == S[l] && piv == j && count == 2) {piv = k; count++;}
                    else if(piv == S[l] && piv == k && count == 3 ) { ans++; break;}                     
                }

            }
        }
    }

    cout<<ans<<endl;
        return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
double PI=acos(-1);

int main(){
    cout << fixed << setprecision(5);
    while(1){
        ll n;
        cin >> n;
        if(n==0) break;
        double s[n];
        rep(i,n) cin >> s[i];
        double ave=0,var=0;
        rep(i,n) ave+=s[i];
        ave /= n;
        rep(i,n) var += pow((s[i]-ave),2);
        var /= n;
        cout << sqrt(var) << endl;
    }
}


Measured memory_bytes: 3248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            int r = ReadAndParseInt();
            int g = ReadAndParseInt();
            int ans = 2 * g - r;
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

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

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

int main(void){

    int n;
    cin >> n;
    printf("%.20lf", 2*n*acos(-1));

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
	x += y;
	if( x >= m )
		x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
	x -= y;
	if( x < 0 )
		x += m;
}

int main() 
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	fastio();

	ll n,q;
	cin>>n>>q;

	vector<int>horizontal, vertical;
	vector<array<int,2>>queries;
	for(int i=0;i<q;i++)
	{
		int t,x;
		cin>>t>>x;
		queries.pb({t,x});
		if( t == 1 )
			vertical.pb(x);
		else
			horizontal.pb(x);
	}
	sort(all(horizontal));
	sort(all(vertical));

	ll from_bottom = n-2, from_right = n-2;
	ll ans = 0;
	map<pair<int,int>,bool>vis;
	for(int i=0;i<q;i++)
	{
		int t, x;
		t = queries[i][0];
		x = queries[i][1];

		if( vis.find({t,x}) != vis.end() )
			continue;
		vis[{t,x}] = 1;

		if( t == 1 )
		{
			while( !vertical.empty() && vertical.back() >= x )
			{
				ans += from_bottom;
				// cout<<t<<" "<<vertical.back()<<" "<<ans,nl;
				vis[{t,vertical.back()}] = 1;
				vertical.pop_back();
			}
			from_right = x-2;
		}
		else
		{
			while( !horizontal.empty() && horizontal.back() >= x )
			{
				ans += from_right;
				// cout<<t<<" "<<horizontal.back()<<" "<<ans,nl;
				vis[{t,horizontal.back()}] = 1;
				horizontal.pop_back();
			}
			from_bottom = x-2;
		}
	}
	ll final = (n-2)*(n-2) - ans;
	cout<<final,nl;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 18212
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
vector<int> a;
ll cost(int i,int k){
    if(k == 0 or k== 4)return a[i];
    else if(k == 1 or k==3){
        if(a[i] == 0)return 2;
        if(a[i]%2)return 1;
    } else{
        if(a[i]%2 == 0)return 1;
    }
    return 0;
}
int main(){
    int l;
    cin>>l;
    a.resize(l);
    for(auto & b : a) cin>>b;
    vector<ll> from(5,inf);
    auto to = from;
    from[0] = 0;
    for(int i=0;i<l;++i){
        fill(to.begin(),to.end(),inf);
        for(int j=0;j<5;++j){
            for(int k=j;k<5;++k){
                to[k] = min(to[k],from[j] + cost(i,k));
            }
        }
        swap(to,from);
    }
    ll ret = inf;
    for(int i=0;i<5;++i){ret = min(ret,from[i]);}
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int dp[105][2][5];
//dp[place][tight][zeroes]
int32_t main()
{
	
	string s;cin>>s;
	int K=in();
	int n=s.size();
	dp[0][0][0]=1;
	
	for(int i=0;i<n;i++)
	{
		int D=s[i]-'0';
		for(int j=0;j<2;j++)
		{
			for(int k=0;k<=K;k++)
			{
				int target=(j==1?9:D);
				for(int d=0;d<=target;d++)
				{
					int ct=0;
					if(d!=0)ct++;
					dp[i+1][j or (d<D)][k+ct]+=dp[i][j][k];
				}
			}
			
		}
	}
	
	cout<<dp[n][0][K]+dp[n][1][K];
	
	
}

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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    for(auto& x:A) cin >> x;

    unsigned long long ans = 0;
    int l = 0, r = 0;
    int exor = 0;
    while(l < N){
        while(r < N){
            if((exor^A[r]) == exor+A[r]){
                exor ^= A[r];
                r++;
            } else break;
        }
        ans += r-l;
        exor ^= A[l];
        l++;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author Nikunj
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Together solver = new Together();
        solver.solve(1, in, out);
        out.close();
    }

    static class Together {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int N = in.scanInt();
            int array[] = new int[100001];
            for (int i = 0; i < N; i++) {
                array[in.scanInt()]++;
            }
            int ans = array[0] + array[1];
            for (int i = 1; i < 100000; i++) {
                if (array[i - 1] + array[i] + array[i + 1] > ans) ans = array[i - 1] + array[i] + array[i + 1];
            }
            ans = Math.max(ans, array[100000] + array[99999]);
            out.println(ans);

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 22100
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    string S;
    cin >> N >> S;
    int L=S.length();
    int alf[L];
    rep(i,L) alf[i]=S[i]-'A';
    rep(i,L) alf[i]=(alf[i]+N)%26;
    rep(i,L) cout << char('A'+alf[i]);
    cout << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<(a-b==b-c?"YES":"NO");
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p_list = [[0] * 2 for i in range(N)]
for i in range(N):
    x, y = map(int, input().split())
    p_list[i] = [x, y]

p_list.sort()
ans = float('inf')
for i in range(N - K + 1):
    for j in range(i + K - 1, N):
        x = abs(p_list[j][0] - p_list[i][0])
        y_list = []
        for k in range(i, j + 1):
            y_list.append((p_list[k][1]))
        y_list.sort()
        for k in range(len(y_list) - K + 1):
            ans = min(ans, x * abs(y_list[k + K - 1] - y_list[k]))

print(ans)


Measured memory_bytes: 3188
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_057_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(5).
    01 A      PIC 9(2).
    01 B      PIC 9(2).
    01 ans    PIC X(2).

    01 ZS     PIC Z(2)9.
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO A B.

    ADD B TO A.

    IF 24 <= A THEN
        SUBTRACT 24 FROM A
    END-IF.

    MOVE A TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 636
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 

int r, D,x2000;



int calc(int x){
    return r*x - D;
}



int main(){
    cin >> r >> D >> x2000;
    int ans = x2000;
    for(int i = 1; i<=10; i++){
        ans = calc(ans);
        cout << ans << endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll t1,t2; cin >> t1 >> t2;
    ll a1,a2; cin >> a1 >> a2;
    ll b1,b2; cin >> b1 >> b2;
    if(t1*a1 + t2*a2 == t1*b1 + t2*b2){
        cout << "infinity" << endl;
        return 0;
    }
    ll res = 0;
    ll s1 = t1*(a1-b1);
    ll s2 = t2*(a2-b2);
    if(s1 < 0){
        s1 = -s1;
        s2 = -s2;
    }
    ll s = s1 + s2;
    if(0 < s1 && 0 < s2){
        res = 0;
    }
    else{
        if(s1 < abs(s2)){
            ll num = s1 / abs(s);
            if(s1%abs(s) == 0)res = num*2;
            else res = num*2+1;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int MAX=510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        //???
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    COMinit();
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ll t=((n-i)*((m-j)*(i+j))%mod)%mod;
            if(i!=0&&j!=0) t*=2;//なんで?
            ans=(ans+t)%mod;
        }
    }

    ans=(ans*COM(n*m-2,k-2))%mod;

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


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vi c;

int f(vvi a,int t){
	if(n==1){
		if(t>=2) return m;
		for(int i=0;i<m;i++) if(a[0][0]==c[i]) return i;
		return m;
	}
	vi b(n),d(n);
	int t1=0,t2=0;
	vp ind(1000001,{-1,-1});
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) ind[a[i][j]]={i,j};
	for(int i=0;i<m;i++){
		P p=ind[c[i]];
		int x=p.first,y=p.second;
		if(x==-1) continue;
		b[x]++;
		d[y]++;
		if(b[x]==n) t--;
		if(d[y]==n) t--;
		if(x==y){
			t1++;
			if(t1==n) t--;
		}
		if(n-x-1==y){
			t2++;
			if(t2==n) t--;
		}
		if(t<=0) return i;
	}
	return m;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,y;
	cin>>n>>x>>y>>m;
	vvi a(n,vi(n)),b(n,vi(n));
	c=vi(m);
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>b[i][j];
	for(auto &i:c) cin>>i;
	int p=f(a,x),q=f(b,y);
	if(p==q) cout<<"DRAW"<<endl;
	else if(p<q) cout<<"USAGI"<<endl;
	else cout<<"NEKO"<<endl;
}


Measured memory_bytes: 12660
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
ll cx[4]={0,0,1,-1};
ll cy[4]={1,-1,0,0};
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n>>m;

	char ar[n][m+1];
	for(i=0;i<n;i++){
		cin>>ar[i];
	}
	ll dt[n][m];
	queue< pair<ll,ll> > qe;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			dt[i][j]=100000000000000;
			if(ar[i][j]=='#'){
				dt[i][j]=0;
				qe.push({i,j});
			}
		}
	}

	while(qe.size()>0){
		pair<ll,ll> p=qe.front();
		qe.pop();
		ll x,y;
		for(k=0;k<4;k++){
			x=p.fs+cx[k];
			y=p.sc+cy[k];
			if(x>=0&&y>=0&&x<n&&y<m&&dt[x][y]>dt[p.fs][p.sc]+1){
				dt[x][y]=dt[p.fs][p.sc]+1;
				qe.push({x,y});
			}
		}
	}
	ll mx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			mx=max(mx,dt[i][j]);
		}
	}
	cout<<mx;
	return 0;
}


Measured memory_bytes: 25396
#include <iostream>

using namespace std;

int main(){
    int a[100];
    int n;
    int max = 0;
    int min = 100000000000;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[n];
        if(max < a[n]){max = a[n];}
        if(min > a[n]){min = a[n];}

    }
    cout << max - min << endl;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const int MAXN=1000+20;
int dp[MAXN][MAXN];
int maze[MAXN][MAXN];
int h,w,n,sx[10],sy[10],temp;
void input(){
	memset(maze,-1,sizeof(maze));
	cin>>h>>w>>n;
	cin.get();
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			char x;
			x=cin.get();
			if(x=='.') maze[i][j]=0;
			if(x=='X') maze[i][j]=-1;
			if(x>='0' && x<='9'){
				maze[i][j]=x-'0';
				sx[x-'0']=i;
				sy[x-'0']=j;
			}
			if(x=='S'){
				maze[i][j]=0;
				sx[0]=i;
				sy[0]=j;
			}
		}
		cin.get();
	}
//	for(int i=0;i<10;++i) cout<<sx[i]<<' '<<sy[i]<<endl;
/*	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cout<<setw(4)<<maze[i][j];
		}
		cout<<endl;
	}*/
}
void bfs(int xx,int yy,int nn){
	queue <int> tx;
	queue <int> ty;
	tx.push(xx);
	ty.push(yy);
	while(tx.size() && ty.size()){
		int qx=tx.front(),qy=ty.front();
		tx.pop();
		ty.pop();
		for(int i=0;i<4;++i){
			int x=qx+dx[i],y=qy+dy[i];
			if(maze[x][y]==-1 || dp[x][y]>=0) continue;
			tx.push(x);
			ty.push(y);
			dp[x][y]=dp[qx][qy]+1;
			if(x==sx[nn] && y==sy[nn]){
				temp=dp[qx][qy];
//				cout<<temp<<endl;
				break;
			}
//			cout<<x<<' '<<y<<' '<<dp[x][y]<<endl;
		}
	}
//	cout<<endl;
}
void solve(){
	for(int i=0;i<n;++i){
//		cout<<temp<<endl;
		memset(dp,-1,sizeof(dp));
//		cout<<sx[i+1]<<' '<<sy[i+1]<<endl;
		dp[sx[i]][sy[i]]=temp;
		bfs(sx[i],sy[i],i+1);
	}
	cout<<dp[sx[n]][sy[n]]+n-1<<endl;
}
int main(){
	input();
	solve();
	return 0;
}


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

using namespace std;

int main(){

  string red;
  string green;
  string down;
  string right;

  while(1){

	cin >> red;

	if(red == "-")
	  break;

	cin >> green;
	cin >> down;

	int ri = -1;
	int gi = 0;
	int di = 0;

	bool D = false;
	bool R = true;
	
	while(ri != red.size() || gi != green.size()){	  
	  if(R == true && green[gi] == down[di]){
		ri++;
		di++;
		D = true;
		R = false;
	  }
	  else if(D == true && red[ri] == down[di]){
		ri++;
		di++;
		D = true;
		R = false;
	  }	  
	  else if(R == true && green[gi] != down[di]){
		cout << green[gi];
		gi++;
		D = false;
		R = true;
	  }
	  else if(D == true && red[ri] != down[di]){
		cout << red[ri];
		gi++;
		D = false;
		R = true;
	  }	  	
	}
	cout << endl;
  }
	
}



Measured memory_bytes: 3148
#include <iostream>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        bool win = false;
        for(int i=0;i<N;i++){
            int t; cin >> t;
            if(t%2) win = true;        
        }
        cout << (win ? "first" : "second") << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur!=nil && cur->key != key){
    cur=cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

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

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

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char command[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", command, &key);
    if ( command[0] == 'i' ) {insert(key); np++; size++;}
    else if ( command[0] == 'd' ) {
      if (strlen(command) > 6){
	if ( command[6] == 'F' ) deleteFirst();
	else if ( command[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33052
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 2e9
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;

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

  ll *hs = new ll[n + 1];
  map<ll, vector<ll>> paths;
  FOR(i, 1, n)
  {
    cin >> hs[i];
    paths[i] = vector<ll>();
  }

  ll a, b;
  REP(i, m)
  {
    cin >> a >> b;
    paths[a].push_back(b);
    paths[b].push_back(a);
  }

  ll ans = 0;
  for (auto p : paths)
  {
    bool is_good = true;
    for (auto v : p.second)
    {
      if (hs[p.first] <= hs[v])
      {
        is_good = false;
        break;
      }
    }

    if (is_good)
    {
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15684
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Cake = Tuple!(long, "beauty", long, "tasty", long, "popular");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto r = lread();
    (3 * (r ^^ 2)).writeln();
}

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


int main() {
	int n;
	string str, forward, backward;
	cin >> n;
	cin >> str;

	if (n%2==0) {
		forward = str.substr(0, str.size() / 2);
		backward = str.substr(str.size() / 2, str.size() / 2);
		if (forward == backward) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
	else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;


int main(){
    //cin >> ;
    //cout << ans << endl;
    string s;

    //scanf("%lld", &N);
    cin >> K;
    cin >> s;
    if(s.length() <= K){
        cout << s;
    }
    else{
        cout << s.substr(0, K) + "...";
    }


    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  [n, m, p] <- f
  unless (n == 0 && m == 0 && p == 0) $ do
    solve m p <$> replicateM n readLn >>= print
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> [Int] -> Int
solve m p xs
  | nw == 0 = 0
  | otherwise = sum xs * (100 - p) `div` nw
  where
    nw = xs !! (m - 1)



Measured memory_bytes: 4176
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

ll mod;

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

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

ll calc1(ll n, ll p){
    ll ten = powll(10, p);
    ll ret = 0, x = 1, c = 1;
    while (n){
        if (n & 1){
            ret = (ret * powll(ten, c)) % mod;
            ret = (ret + x) % mod;
        }
        x = (x + x * powll(ten, c)) % mod;
        c *= 2;
        n /= 2;
    }
    return ret;
}

ll calc2(ll n, ll p){
    ll ten = powll(10, p);
    ll ret = 0, x = 0, c = 1, d = 0;
    while (n){
        if (n & 1){
            ll tmp = (x + calc1(c, p) * (d % mod)) % mod;
            ret = (ret + tmp * powll(ten, d)) % mod;
            d += c;
        }
        ll tmp = (x + calc1(c, p) * (c % mod)) % mod;
        x = (x + tmp * powll(ten, c)) % mod;
        c *= 2;
        n /= 2;
    }
    return ret;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b >> mod;

    ll base = 1, t = 1e17, ans = 0;
    FORR(d,18,1){
        ll m = (t - a + b - 1) / b;
        if (t < a) m = 0;
        if (m < n){
            ll s = ((a % mod) + ((n - 1 + mod) % mod) * (b % mod)) % mod;
            ll x = n - m;

            ll tmp = (s * calc1(x, d)) % mod;
            tmp = (tmp + (mod - (b % mod)) * calc2(x, d)) % mod;
            ans = (ans + tmp * base) % mod;

            base = (base * powll(powll(10, d), x)) % mod;
            n = m;
        }
        t /= 10;
    }    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());

  ll ans = 0;
  rep(i, n-k) ans += h[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
program golf

 implicit none
 integer :: k,a,b,i,j

 read*,k,a,b

 j=0
 do i=1,1000
   if(k*i>=a .and. k*i<=b) j=j+1
 end do

 if(j>=1) print*,'OK'
 if(j==0) print*,'NG'

end program golf

 

Measured memory_bytes: 2856
#include<iostream>
using namespace std;
int main(){
	int n,c,total=0;
	cin>>n;
	int v[n];
	for(int i=0;i<n;i++)cin>>v[i];
	for(int i=0;i<n;i++){
		cin>>c;
		v[i]-=c;
	}
	for(int i=0;i<n;i++)total+=(v[i]>0?v[i]:0);
	cout<<total<<endl;
}

Measured memory_bytes: 256
MOD = 1000000007
N, K = map(int,input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

C = [False for _ in range(N)]
F = [0]
C[0] = True
r = K
while F:
    n = F.pop()
    if n == 0:
        c = K-1
    else:
        c = K-2
    for e in G[n]:
        if C[e]:
            continue
        C[e] = True
        r = (r * c) % MOD
        c -= 1
        F.append(e)

print(r)

Measured memory_bytes: 23660