akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e5 + 5;
int a[N][3];
int n, k;
int mem[N][5];
int oo = 0x3f3f3f3f;
int solve(int i = 0, int prev = 3){
    if(i == n)
        return 0;
    int &ret = mem[i][prev];
    if(~ret)
        return ret;
    ret = 0;
    for(int j=0; j<3; j++){
        if(prev == j) continue;
        ret = max(ret, solve(i+1, j) + a[i][j] );
    }
    return ret;
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    memset(mem, -1, sizeof(mem));
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    cout<<solve()<<'\n';
}

Measured memory_bytes: 14504
$cnt = 0

def insertion_sort(a, n, g)
    (g..n-1).each{|i|
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v
            a[j+g] = a[j]
            j = j - g
            $cnt += 1
        end
        a[j+g] = v
    }
end

class Array
    def sorted?
        (1...self.size).all?{|i| self[i-1]<=self[i]}
    end
end

def shell_sort(a, n)
    m = 0
    g = [1]
    loop do
        nxt = 3 * g[-1] + 1
        break if nxt >= n
        g << nxt
    end
    g.reverse!
    m = g.size
    g.each{|gi|
        insertion_sort(a, n, gi)
    }
    return g
end

n = gets.to_i
a = n.times.map{gets.to_i}

g = shell_sort(a, n)
puts g.size, g.join(' '), $cnt, a



Measured memory_bytes: 14820
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
  int n;
  std::cin >> n;
  std::vector<ll> a(3*n);
  rep(i,3*n)std::cin >> a[i];
  sort(all(a),greater<ll>());
  ll ans=0;
  rep(i,n)ans+=a[2*i+1];
  std::cout << ans << std::endl;
}

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(1000000)

n = int(input())
alst = list(map(int, input().split()))
edges = [[] for _ in range(n)]
rev_edges = [[] for _ in range(n)]
for i in range(n):
  edges[i].append((i + alst[i]) % n)
  rev_edges[(i + alst[i]) % n].append(i)

def dfs(x, ret, edges, visited):
  visited[x] = True
  for e in edges[x]:
    if not visited[e]:
      dfs(e, ret, edges, visited)
  ret.append(x)

def dfs_rev(x, cycles, rev_edges, visited):
  visited[x] = True
  flag = False
  for e in rev_edges[x]:
    if not visited[e]:
      cycles.add(e)
      dfs_rev(e, cycles, rev_edges, visited)
      flag = True
    elif x == e:
      flag = True
  if flag:
    cycles.add(x)

order = []
visited = [False] * n
for i in range(n):
  if not visited[i]:
    dfs(i, order, edges, visited)
order.reverse()

visited = [False] * n
cycles = set()
for i in order:
  if not visited[i]:
    dfs_rev(i, cycles, rev_edges, visited)
print(len(cycles))


Measured memory_bytes: 146776
N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]
count=[[0]*C for i in range(3)]
for i in range(1,N+1):
  for j in range(1,N+1):
    count[(i+j)%3][c[i-1][j-1]-1]+=1
ans=10**10
for i in range(C):
  for j in range(C):
    if i==j:
      continue
    for k in range(C):
      if i==k or j==k:
        continue
      tmp=0
      for x in range(C):
        tmp+=D[x][i]*count[0][x]+D[x][j]*count[1][x]+D[x][k]*count[2][x]
      if ans>tmp:
        ans=tmp
print(ans)

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ll cnt(vector<int> v){
	ll rtn=0, cnt=0;
	for(int i=0; i<v.size(); i++){
		if(v[i]==0) cnt++;
		else rtn+=cnt;
	}
	return rtn;
}

int main(){
	string s;
	cin >> s;
	s+='X';
	int n=s.length();

	ll ans=0;
	vector<int> v;
	for(int i=0; i<n; i++){
		if(s[i]=='A'){
			v.push_back(0);
		}else if(i+1<n && s[i]=='B' && s[i+1]=='C'){
			v.push_back(1);
			i++;
		}else{
			ans+=cnt(v);
			v.resize(0);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2168
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "b.cpp"

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(m);
  cin >> a;
  cout << max(-1LL, n-accumulate(all(a), 0)) << el;
}


Measured memory_bytes: 3700
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct edge{
    int from, to, cost;
};

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

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

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

    int l;
    cin >> l;

    vector<edge> ans;
    int maxi = 0;
    rep(i, 19){
        ans.push_back({i, i + 1, 0});
        if((1 << (i + 1)) <= l){
            ans.push_back({i, i + 1, 1 << i});
            chmax(maxi, (1 << (i + 1)) - 1);
        }
    }

    rrep(i, 19){
        if((1 << i) < l - 1 && l - (1 << i) > maxi){
            ans.push_back({i, 19, l - (1 << i)});
            l -= (1 << i);
        }
    }

    cout << 20 << " " << ans.size() << endl;
    for(auto e : ans){
        cout << e.from + 1 << " " << e.to + 1 << " " << e.cost << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int[] d=new int[n];
		for(int i=0; i<n; i++){
			d[i]=sc.nextInt();
		}
		Arrays.sort(d);
		System.out.println(d[n/2]-d[n/2-1]);
	}
}




Measured memory_bytes: 50656
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input().strip())

    path = []

    def backtrack(seen):
        if len(path) == n:
            print("".join(path))
            return
        for i in range(seen + 1):
            path.append(chr(ord("a") + i))
            backtrack(max(seen, i + 1))
            path.pop()
    
    backtrack(0)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 59224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=Integer.valueOf(sc.next());
		int[] arr= new int[n];
		for(int i=0;i<n;i++){
			arr[i]=Integer.valueOf(sc.next());
		}
		sc.close();
		
		int count=0;
		for(int i=0;i<n-1;i++){
			int min=Integer.MAX_VALUE;
			int k=0;
			for(int j=i;j<n;j++){
				if(min>arr[j]){
					min=arr[j];
					k=j;
				}
			}
			if(i!=k){
				arr[k]=arr[i];
				arr[i]=min;
				count++;
			}
		}
		System.out.print(arr[0]);
		for(int i=1;i<n;i++){
			System.out.print(" "+arr[i]);
		}
		System.out.println();
		System.out.println(count);
	}

}

Measured memory_bytes: 26228
while True :
    H,W = map(int,input().split())
    if (H == 0 and W == 0) : break
    for j in range(0, H) :
        for i in range(0 ,W) : 
            if j == 0 or i == 0 or i == W - 1 or j == H - 1 :
                print("#", end = "")
            else :
                print(".", end = "")
        print()
    print()
    


Measured memory_bytes: 7004
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

const int MOD = 1000000007;

bool isPrime(unsigned long num)
{
	if (num == 2)
		return true;

	if (num <= 1 || num % 2 == 0)	// 0, 1, and all even numbers
		return false;

	for (unsigned long x = 3; x*x <= num; x += 2) {
		if (num % x == 0)
			return false;
	}

	return true;
}

int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N;
    cin >> N;

    vector <int> primeList;

    for(int i = 2; i <= 55555; ++i)
    {
        if(isPrime(i))
        {
            //5で割って1余るを 5つ集めれば、5で割れる合成数
            if(i % 5 == 1)primeList.push_back(i);
        }

    }

    REP(i,N)
    {
        cout << primeList[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 256
x, y, a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = list(map(int,input().split()))

pqr = sorted(p[:x]+q[:y]+r,reverse=True)
print(sum(pqr[:x+y]))

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    //vector<vector<int>> a(100, vector<int>(100));
    vector<int> a(100000);
    int cnt = 0;
    rep(i, k) {
        cin >> d[i];
        rep(j, d[i]) {
            cin >> a[cnt];
            cnt++;
        }
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    int ans = n - (a.size()-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>
int main(void) {
	char s1[300], s2[300];
	int i = 0, cnt, jud, j;
	while (1) {
		cnt = 0;
		jud = 0;
		i = 0;
		j = 0;
		fgets(s1, sizeof(s1), stdin);
		//scanf("%s",s1);
		if (s1[0] == '.') {
			break;
		}
		fgets(s2, sizeof(s2), stdin);
		//scanf("%s",s2);
		while ((s1[i] != '\n') || (s2[j] != '\n')) {
			//printf("%c %c\n", s1[i], s2[j]);
			if (s1[i] != s2[j]) {
				if (jud == 0) {
					cnt = 2;
					break;
				}
				else {
					cnt++;
					if (s2[j] != '"') {
						do {
							j++;
						} while (s2[j] != '"');
					}
					if (s1[i] != '"') {
						do {
							i++;
						} while (s1[i] != '"');
					}
					jud = 0;
				}
			}
			else if ((s1[i] == '"') || (s2[j] == '"')) {
				if (jud == 0) {
					jud = 1;
				}
				else {
					jud = 0;
				}
			}
			i++;
			j++;
		}
		if (cnt == 0) {
			printf("IDENTICAL\n");
		}
		else if (cnt == 1) {
			printf("CLOSE\n");
		}
		else {
			printf("DIFFERENT\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

struct Edge {
    int to;
    ll cost;
};

vector<int> Centroid(const vector<vector<Edge>> &edge) {
    int n = edge.size();
    vector<int> centroids;
    vector<int> sz(n);
    function<void(int, int)> dfs = [&](int cur, int par) {
        sz[cur] = 1;
        bool is_centroid = true;
        for (Edge ch : edge[cur]) {
            if (ch.to == par) continue;
            dfs(ch.to, cur);
            sz[cur] += sz[ch.to];
            if (sz[ch.to] > n / 2) is_centroid = false;
        }
        if (n - sz[cur] > n / 2) is_centroid = false;
        if (is_centroid) centroids.push_back(cur);
    };
    dfs(0, -1);
    return centroids;
}

ll total_cost[100005];

void dfs(vector<vector<Edge>> &edge, int cur, int par, ll sum) {
    total_cost[cur] = sum;
    for (Edge e : edge[cur]) {
        if (e.to == par) continue;
        dfs(edge, e.to, cur, sum + e.cost);
    }
}

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

    int n;
    cin >> n;

    vector<vector<Edge>> edge(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;

        edge[a].push_back(Edge{b, c});
        edge[b].push_back(Edge{a, c});
    }

    vector <int> centroids = Centroid(edge);

    ll ans = 0;
    if (centroids.size() == 2) {
        for (Edge e : edge[centroids[0]]) {
            if (e.to == centroids[1]) {
                ans -= e.cost;
            }
        }
    } else {
        ll mn = 1LL << 30;
        for (Edge e : edge[centroids[0]]) {
            mn = min(mn, e.cost);
        }
        ans -= mn;
    }

    int center = centroids[0];
    dfs(edge, center, -1, 0);

    for (int i = 0; i < n; i++) {
        ans += 2LL * total_cost[i];
    }

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

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

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

    long long int min_steps = LONG_LONG_MAX;
    for (long long int i = (int)(sqrt(n)) + 1; i >= 1; i--)
    {
        if (n % i == 0)
        {
            long long int steps = (long long int)(n / i) - 1 + i - 1;
            min_steps = min(min_steps, steps);
        }
    }
    cout << min_steps << endl;
}

Measured memory_bytes: 256
#import<cstdio>
int main(){for(int n,m,a,b,i;scanf("%d%d",&n,&m),n|m;printf("%d\n",a)){int f[510][510]={0};for(i=m;i--;f[a][b]=f[b][a]=1)scanf("%d%d",&a,&b);for(a=i=0;i<=n;i++)if(f[1][i])for(f[505][i]=b=1;b<=n;b++)f[i][b]?f[505][b]=1:0;for(;--i>1;)f[505][i]?a++:0;}}

Measured memory_bytes: 0
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def get_yakusu(n):
    ans = set()
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            if i != 1:
                ans.add(i)
            if n // i != i:
                ans.add(n // i)
    return ans

def main():
    N = I()
    cnt = 0
    yakusu = get_yakusu(N)
    n1yakusu = get_yakusu(N-1)
    if N == 2:
        print(1)
        return
    for n in yakusu:
        cpN = N
        while True:
            if n == 1:
                break
            if cpN % n == 0:
                cpN = cpN // n
            else:
                break
        if cpN % n == 1:
            cnt += 1
    cnt += len(n1yakusu)
    print(cnt)
main()



Measured memory_bytes: 65516
import bisect

N,C,K=map(int,input().split())
A=[int(input()) for i in range(N)]
A.sort()

def search_next_bus(Ti):
  nxt=bisect.bisect_right(A,A[Ti]+K)
  if nxt>Ti+C:
    nxt=Ti+C
  return nxt

cnt=0
ans=0
while True:
  cnt=search_next_bus(cnt)
  ans+=1
  if cnt==N:
    break
print(ans)

Measured memory_bytes: 7512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int c[15],t;
int main()
{
	for(int i=0;i<3;i++)
	{
		scanf("%d",&t);
		c[t]++;
	}
	puts(c[5]==2&&c[7]==1?"YES":"NO");
}




Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,b,c;
  cin>>a>>b>>c;
  if(c>a&&c>b||c<a&&c<b){
  	cout<<"No"<<endl;
  }

  else{
  	cout<<"Yes"<<endl;
  }
  
  return 0;
} 

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;

bool prime[1000000];
int dp[100010];

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

    //trueの配列を用意して、素数ではないものをfalseにしていく。
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1] = false;
    for(int i = 2; i <= 1000000; i++){
        if(prime[i]){
            for(int j = 2 * i; j <= 1000000; j += i){
                prime[j] = false;
            }
        }
    }

    //2017に似た数を調べて見つけたら1を代入する。
    for(int i = 1; i < 100010; i++){
        if(i%2 && prime[i] && prime[(i+1)/2]){
            dp[i] = 1;
        }
    }

    //累積和を作る。
    for(int i = 1; i < 100010; i++){
        dp[i] += dp[i-1];
    }

    //いつも通り累積和の答えの出し方をする。
    for(int i = 0; i < q; i++){
        int l,r;
        cin >> l >> r;
        //インデックスの関係
        cout << dp[r] - dp[l-1] << endl;
    }

    return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<cstdio>
using namespace std;

string ToUpperstr(string ss);

int main()
{
	int count=0;
	string ss1,ss2;
	
	cin >> ss1;

	ss1 = ToUpperstr( ss1 );

	while(1)
	{
		cin >> ss2;
		if((ss2=="END_OF_TEXT")) break;
		
		ss2 = ToUpperstr( ss2 );

		if(ss2 == ss1) count++;

	}

	cout << count << endl;


	return 0;
}

string ToUpperstr(string ss)
{
	for(int i=0;i<(int)ss.size();i++)
	{
		ss[i] = toupper((int)ss[i]);
	}
	return ss;
}

Measured memory_bytes: 1200
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    inf = float('inf')
    N = int(readline())
    A = list(map(lambda x: format(int(x), 'b')[::-1], readline().split()))
    cnt = inf
    for a in A:
        cnt = min(a.index('1'), cnt)
    print(cnt)

    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int n;
	cin>>n;
	int sum = 0;
	int temp = n;
	while(temp>0)
	{
		sum+= (temp%10);
		temp/=10;
	}
	if((n%sum)==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3572
n = int(input())
ans = []

if n % 2 == 0:
    m = n + 1
else:
    m = n

for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        if i + j != m:
            ans.append([i, j])

print(len(ans))
for i, j in ans:
    print(i, j)


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

const long long MOD = 1000000007;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

void solve(long long N, std::vector<long long> A)
{

    ll sum = 0;
    for (auto &&e : A)
    {
        sum += e;
        sum %= MOD;
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++)
    {
        ans += (A[i] * ((sum - A[i] + MOD) % MOD)) % MOD;
        ans %= MOD;
    }

    cout << ans * modinv(2, MOD) % MOD << endl;
}

signed main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4836
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;

int a[5];
int k[5];
int kotae;
int hiku;
int main(){
	hiku = 0;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  REP(i,5){
		k[i] = (a[i]+9)/10 *10;
		kotae += k[i];
		if(k[i]!=a[i]) hiku = max(hiku, k[i]-a[i]);
	}
	kotae -= hiku;
	cout << kotae << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	ll n, a[200010], sa = 0, sb = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a, a + n);
	for (int i = 0;i < n;i++) {
		sa += abs(a[i] - a[n / 2]);
	}
	for (int i = 0;i < n;i++) {
		sb += abs(a[i] - a[(n + 1) / 2]);
	}
	cout << min(sa, sb) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
int main()
{
int n,i;
  scanf("%d",&n);
 long int a[n],min,s,cc,ans,temp;
  temp=0;
  ans=0;
  s=0;
  cc=0;
  min=pow(10,9);
  for(i=0;i<n;++i)
  {
  scanf("%ld",&a[i]);
  if(a[i]<min) min=a[i];
  }

  cc=0;
  for(i=0; cc==0;++i)
  {
  for(int j=0;j<n;++j)
  {
  if(a[j]%2==0) {temp++;
                a[j]=a[j]/2;
                }
  else cc++;
  }
  if(temp==n) ans++;
  temp=0;
  }

  printf("%ld",ans);

return 0;}

Measured memory_bytes: 1736
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, m;
vector<int> g[1010], gr[1010];
bool used[1010];
int cmp[1010];
vector<int> vs;
void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
	vs.push_back(x);
}
void rdfs(int v, int k){
	used[v]=1;
	cmp[v]=k;
	for(auto y:gr[v]){
		if(!used[y]) rdfs(y, k);
	}
}
int scc(){
	fill(used, used+n, 0);
	vs.clear();
	for(int i=0; i<n; i++){
		if(!used[i]) dfs(i);
	}
	fill(used, used+n, 0);
	int k=0;
	for(int i=vs.size()-1; i>=0; i--){
		if(!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
vector<int> check(vector<int> vc){
	bool nuo[1010]={};
	for(auto x:vc){
		nuo[x]=1;
	}
	for(int i=0; i<vc.size(); i++){
		int x=vc[i];
		int y;
		if(i<vc.size()-1) y=vc[i+1];
		else y=vc[0];
		for(auto z:g[x]){
			if(!nuo[z]) continue;
			if(z!=y){
				vector<int> ret;
				ret.push_back(z);
				int j=0;
				for(; j<vc.size(); j++) if(z==vc[j]) break;
				for(; ; ){
					if(j<vc.size()-1) j++;
					else j=0;
					ret.push_back(vc[j]);
					if(vc[j]==x) break;
				}
				return ret;
			}
		}
	}
	return vc;
}
int main()
{
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int a, b; cin>>a>>b; a--; b--;
		g[a].push_back(b);
		gr[b].push_back(a);
	}
	int k=scc();
	if(k==n){
		cout<<-1<<endl;
		return 0;
	}
	vector<int> v[1010];
	for(int i=0; i<n; i++){
		v[cmp[i]].push_back(i);
	}
	int t;
	for(int i=0; i<k; i++){
		if(v[i].size()>=2){
			t=i;
			break;
		}
	}
	int a0, b0;
	for(auto x:v[t]){
		for(auto y:g[x]){
			if(cmp[y]==t){
				a0=x, b0=y;
			}
		}
	}
	int d[1010];
	fill(d, d+n, 1e9);
	queue<int> que;
	d[b0]=0;
	que.push(b0);
	while(!que.empty()){
		int x=que.front();
		que.pop();
		for(auto y:g[x]){
			if(cmp[y]!=t) continue;
			if(d[y]>d[x]+1){
				d[y]=d[x]+1;
				que.push(y);
			}
		}
	}
	vector<int> vc;
	int x0=a0;
	vc.push_back(a0);
	while(x0!=b0){
		for(auto y:gr[x0]){
			if(d[y]==d[x0]-1){
				vc.push_back(y);
				x0=y;
				break;
			}
		}
	}
	reverse(vc.begin(), vc.end());
	while(1){
		int s=vc.size();
		vc=check(vc);
		if(s==vc.size()){
			cout<<s<<endl;
			for(int i=0; i<s; i++) cout<<vc[i]+1<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void)
{
    int N, K;
    int A[200010];
    cin >> N >> K;
    for(int i=1; i<=N; i++) cin >> A[i];
    int sum[200010];
    sum[0]=0;
    for(int i=1; i<=N; i++)
    {
        sum[i]=(sum[i-1]+A[i])%K;
        sum[i]=(sum[i]+K-1)%K;
    }
    map<int, int> m;
    long long ans=0;
    for(int i=0; i<=N; i++)
    {
        if(i>=K) m[sum[i-K]]--;
        ans+=m[sum[i]];
        m[sum[i]]++;
    }
    /*for(int i=0; i<=N; i++)
    {
        cout << sum[i] << ' ' << m[sum[i]] << endl;
    }*/
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
//
//  abc152_compare_strings.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define PI 3.14159265


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

  if (a>b) {
    for (int i=0; i<a; i++) {
      std::cout << b;
    }
    std::cout << std::endl;
  }
  else {
    for (int i=0; i<b; i++) {
      std::cout << a;
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli l, r, minv = 2018;
    cin >> l >> r;
    if(r-l > 2020){
        cout << 0 << endl;
        return 0;
    }
    else{
        for(lli i=l; i<=r-1; i++){
            for(lli j=i+1; j<=r; j++){
                chmin(minv, (i%2019*j%2019)%2019);
            }
        }
    }
    cout << minv << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int solve(vector<int>&weight,vector<long long int>&value,int w){
    vector<vector< long long int>>dp(weight.size()+1,vector<long long int>(w+1,0));
    
    for(int i=1;i<=weight.size();i++){
        for(int j=1;j<=w;j++){
            if(j>=weight[i-1]) dp[i][j]=max(dp[i-1][j],value[i-1]+dp[i-1][j-weight[i-1]]);
            else dp[i][j]=dp[i-1][j];
            // cout<<dp[i][j]<<" ";
        
        }
        // cout<<endl;
    }
    return dp[weight.size()][w];
}





int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    int w;
    cin>>n>>w;
    vector<int>weight;
    vector<long long int>value;
    while(n-->0){
        int a,b;
        cin>>a>>b;
        
        weight.push_back(a);
        value.push_back(b);
    }
    cout<<solve(weight,value,w)<<endl;
}

Measured memory_bytes: 80256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M,Q;
int L[200010],R[200010];
int p[100010],q[100010];
int num[510][510];//y=l,x=r->r<p x<l
int B[510][510];

signed main(){
	cin>>N>>M>>Q;
	REP(i,M){
		cin>>L[i]>>R[i];
		L[i]--,R[i]--;
	}
	REP(i,Q){
		cin>>p[i]>>q[i];
	}
	REP(i,M){
		B[L[i]][R[i]]++;
	}
	REP(i,N){
		REP(j,N){
			num[i+1][j+1]=num[i][j+1]+num[i+1][j]-num[i][j]+B[i][j];
		}
	}
	REP(i,Q){
		int x1=p[i]-1;
		int y1=p[i]-1;
		int x2=q[i];
		int y2=q[i];
		cout<<num[x2][y2]-num[x1][y2]-num[x2][y1]+num[x1][y1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 9600
n = int(input())
h = list(map(int, input().split()))

for i in range(1, n):
  if h[i] <= h[i-1] - 2:
    print('No')
    exit()
  elif h[i] == h[i-1] - 1:
    h[i] += 1
  else:
    pass

print('Yes')


Measured memory_bytes: 63856
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int s = a*b;
    if(s&1) cout << "Odd" << endl;
    else cout << "Even" << endl;
}


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

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h+1);
  rep(i,h){
    cin>>s[i];
    s[i]=s[i]+'#';
  }
  rep(i,w+1) s[h][i] = '#';
  
  vector<vector<int>> a(h,vector<int>(w));
  vector<vector<int>> b(h,vector<int>(w));
  
  int res = 0;
  rep(i,h)rep(j,w+1){
    if(s[i][j]=='.'){
      res++;
    }else if(j){
      for(int k=1;k<=res;k++) a[i][j-k] = res;
      res = 0;
    }
  }
  res = 0;
  rep(j,w)rep(i,h+1){
    if(s[i][j]=='.'){
      res++;
    }else if(i){
      for(int k=1;k<=res;k++) b[i-k][j] = res;
      res = 0;
    }
  }
  int ans = 0;
  rep(i,h)rep(j,w){
    if(s[i][j]=='.'){
      ans = max(ans,a[i][j]+b[i][j]-1);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 35712
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const A = input[1].trim().split(' ').map(Number);

  let ret = [];
  for(let i=0; i<N; i++){
    let tmp = A[i] - 1;
    ret[tmp] = i + 1; 
  }

  console.log(ret.join(' '));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 43988
#include <iostream>
#include <queue>
#include <string.h>

using namespace std;


int main() {
    priority_queue<int> pq;
    string str;
    while(1){
        cin>>str;
        if (str=="end"){
            break;
        } else if(str=="insert"){
            int key;
            scanf("%d",&key);
            pq.push(key);
        } else if(str=="extract"){
            printf("%d\n",pq.top());
            pq.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 7132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  ll a[N];
  rep(i,N) cin>>a[i];
  
  vl judge(10,false);
  
  ll red=0;
  
  for(int i=0;i<N;i++){
    
    if(a[i]/400>=8) red++;
    else{
      judge[a[i]/400]=true;
    }
    
  }
  
  ll ma=0,mi=0;
  
  for(int i=0;i<10;i++){
    if(judge[i]) mi++;
  }
  ma=mi+red;
  if(mi==0) mi=1;
  
  cout<<mi<<" "<<ma<<endl;
}


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

using namespace std;

class DoublyLinkedList
{
private:
	struct node {
		unsigned int key;
		node* prev;
		node* next;
	};

	typedef node* NodePointer;

	NodePointer front;
	NodePointer back;

	void deleteNode(NodePointer t) {
		if(front == t || back == t) {
			if(front == back){
				front = nullptr;
				back = nullptr;
			}
			else{
				if(front == t) {
					front = (*t).next;
					(*front).prev = nullptr;
				}
				else if(back == t) {
					back = (*t).prev;
					(*back).next = nullptr;
				}
			}
		} else {
			(*(*t).prev).next = (*t).next;
			(*(*t).next).prev = (*t).prev;
		}
		delete t;
	}

public:
	DoublyLinkedList()
	: front(nullptr)
	, back(nullptr) {}

	~DoublyLinkedList(){
		NodePointer p = front;
		while(nullptr == p){
			NodePointer tmp = p;
			p = (*p).next;
			delete tmp;
		}
	}

	void insert(const unsigned int x) {
		node* newElment = new node{x, nullptr, front};
		if(nullptr == front) {
			back = newElment;
		}
		else{
			(*front).prev = newElment;
		}
		front = newElment;
	}

	void _delete(const unsigned int x) {
		NodePointer p = front;

		while(nullptr != p) {
			if(x == (*p).key) {
				deleteNode(p);
				break;
			}
			p = (*p).next;
		}
	}

	void deleteFirst() {
		if(nullptr != front) {
			deleteNode(front);
		}
	}

	void deleteLast() {
		if(nullptr != back) {
			deleteNode(back);
		}
	}

	void printList(){
		NodePointer cur = front;
		while(nullptr != cur){
			cout << (*cur).key;
			cur = (*cur).next;
			cout << (nullptr != cur ? " " : "\n");
		}
	}
};

int main() {
	int key, n, size, np, nd;
	size = 0;
	np = 0;
	nd = 0;
	string com;
	DoublyLinkedList list;

	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> com;
		if('i' == com[0]){
			cin >> key;
			list.insert(key);
			np++;
			size++;
		}
		else if('d' == com[0]){
			if(6 < com.length()){
				if('F' == com[6]) { list.deleteFirst(); }
				else if('L' == com[6]) { list.deleteLast(); }
			}
			else{
				cin >> key;
				list._delete(key);
				nd++;
			}
			size--;
		}
	}

	list.printList();

	return 0;
}


Measured memory_bytes: 34408
#include <iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
using namespace std;

int N, A[16], x[16][16], y[16][16];

int cnt(long long int k) {

	int ret = 0;
	while (k > 0) {
		if (k % 2 == 1) { ret++; }
		k /= 2;
	}
	return ret;
}

int IsPossible(int k) {

	int h[16];
	int tmp = k;
	for (int i = 1; i <= N; i++) {
		int y= tmp % 2;
		h[i] = y;
		tmp /= 2;
	}

	for (int i = 1; i <= N; i++) {
		if (h[i] == 0) {continue;}

		for (int j = 1; j <= A[i]; j++) {
			if (y[i][j] == 1 && h[x[i][j]] == 0) { return -1; }
			if (y[i][j] == 0 && h[x[i][j]] == 1) { return -1; }
		}

	}

	return 1;
}

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		for (int j = 1; j <= A[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	int ans = 0;

	for (int k = 0; k < pow(2, N); k++) {
	//	cout << bitset<8>(k) << "  "<<IsPossible(k)<<" " <<cnt(k)<<endl;
		if (IsPossible(k) == 1) { ans = max(ans, cnt(k)); }
	}

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

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int t[5]={0},i,R,P,S;

	while(0==0){
		
		R=P=S=0;

		scanf("%d",&t[0]);

		if(t[0]==0) break;
		else if(t[0]==1) R++;
		else if(t[0]==2) S++;
		else P++;
	    

		for(i=1;i<5;i++){
			scanf("%d",&t[i]);
			if(t[i]==1) R++;
		    else if(t[i]==2) S++;
	      	else P++;
		}

		if(R==0){
			if(P!=0 && S!=0)
				for(i=0;i<5;i++){
					if(t[i]==2) t[i]=1;
					else t[i]=2;
				}
		}
	    if(S==0){
			if(P!=0 && R!=0)
				for(i=0;i<5;i++){
					if(t[i]==3) t[i]=1;
					else t[i]=2;
				}
		}
		if(P==0){
			if(S!=0 && R!=0)
				for(i=0;i<5;i++){
					if(t[i]==1) t[i]=1;
					else t[i]=2;
				}
		}
		
		if(R==5 || S==5 || P==5 || (R!=0 && S!=0 && P!=0))
			for(i=0;i<5;i++)
				t[i]=3;

		for(i=0;i<5;i++)
			printf("%d\n",t[i]);
	}

	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    int n = s.size();

    if(s[0] != 'A' || s[1] == 'C' || s[n-1] == 'C'){
        cout << "WA" << endl;
        return 0;
    }

    int cnt = 0;
    rep(i,n) if(s[i] == 'C') cnt++;

    if(cnt != 1){
        cout << "WA" << endl;
        return 0;
    }

    int cnt2 = 0;

    rep(i,n){
        for(char c = 'a'; c<= 'z'; c++){
            if(c == s[i]) cnt2++;
        }
    }

    if(cnt2 + 2 == n){
        cout << "AC" << endl;
        return 0;
    }

    cout << "WA" << endl;
}

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

int main() {
	int r,g,b,k;
	int ans=0;
	cin>>r>>g>>b>>k;
	for(int i=0;i<3001;i++){
		for(int j=0;j<3001;j++){
			if((k-r*i-g*j)>=0 &&(k-r*i-g*j)%b==0)
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int n,a[20];
map<pair<int,int>,long long>Map[20][20];
long long solve(int l,int r,int tl,int tr){
	if(r-l==1)return 0;
	if(Map[l][r].count({tl,tr}))return Map[l][r][{tl,tr}];
	long long res=1ll<<60;
	for(int i=l+1;i<r;++i)
		res=min(res,1ll*a[i]*(tl+tr)+solve(l,i,tl,tl+tr)+solve(i,r,tl+tr,tr));
	return Map[l][r][{tl,tr}]=res;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	printf("%lld\n",a[1]+solve(1,n,1,1)+a[n]);
	return 0;
}


Measured memory_bytes: 18560
// compilation flags
// normal
//      g++ -std=c++17 -O2 -Wall a.cpp -o a
// fast running time
//      g++ -O2 -std=c++17 -Wno-unused-result -Wshadow -Wall -o a a.cpp
// check for mistakes
//      g++ -std=c++17 -Wshadow -Wall -o a a.cpp -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g
#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define E9 1000000007
#define E5 100007
#define INF 1e18+7
#define PI 3.1415926
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define all(a) a.begin(),a.end()
typedef long long int lli;  //  e-18 to e18
typedef vector<long long int> vll;
typedef vector<vector<long long int>> vvll;
void solve(){
    lli n;
    cin>>n;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) cout<<"hon"<<el;
    if(n%10==0 || n%10==1 || n%10==6 || n%10==8) cout<<"pon"<<el;
    if(n%10==3) cout<<"bon"<<el;
}
int main(){
    fastIO();
    lli t(1);
    // cin>>t;
    while(t--) solve();
    ret 0; 
}                                                             

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

ll N, M;
ll MAX_N=100010;
ll MAX_M=100010;
vector<vector<ll>> Way(MAX_N, vector<ll>(0));
vector<ll> Ans(MAX_N, -1);

ll solve2(ll x){
  if(Ans[x]!=-1)return Ans[x];
  ll res=0;
  for(auto nv: Way[x]){
    res=max(res, solve2(nv)+1);
  }
  return Ans[x]=res;
}

ll solve(){
  ll Ret=0;
  rep(i, N){
    Ret=max(Ret, solve2(i));
  }
  return Ret;
}


int main(){
  cin>>N>>M;
  vector<ll> X(M), Y(M);
  rep(i,M){
    cin>>X[i]>>Y[i];
    X[i]--;Y[i]--;
    Way[X[i]].push_back(Y[i]);
  }
  cout<<solve()<<endl;
  return 0;
} 

Measured memory_bytes: 12904
#include<stdio.h>

int ads(int n)
{
    return (n > 0) ? n : -n;
}

int main()
{
    int n;  scanf("%d", &n);
    int m;  scanf("%d", &m);

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

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

    int dir;
    int tmp;
    int j;
    for(i = 0; i < n; i++){
        int pnt = 0;
        dir = ads(a[i] - c[0]) + ads(b[i] - d[0]);

        for(j = 1; j < m; j++){
            tmp = ads(a[i] - c[j]) + ads(b[i] - d[j]);

            if(tmp < dir){
                dir = tmp;
                pnt = j;
            }
        }
        printf("%d\n", pnt + 1);
    }

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    double ans,count;
    for(int i=1;i<=N;i++){
        if(i%2==1||i==1)
            count++;
    }
    ans=count/N;
    printf("%lf\n",ans);
    return 0;
}


Measured memory_bytes: 128
import bisect

N = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
# print(al)
bl.sort()
# print(bl)
cl.sort()
# print(cl)

cnt = 0
for i in range(N):
    cnt_ab = bisect.bisect_left(al, bl[i])  # bl[b] = 6 idx= 3
    cnt_bc = len(cl) - bisect.bisect(cl, bl[i])  # bl[b] = 6 idx2= 1
    # print(cnt_ab,cnt_bc)
    cnt += cnt_ab * cnt_bc

print(cnt)


Measured memory_bytes: 23360
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  cin>>n;
  REP(i,n){
    printf("Case %d:\n",i+1);
    int s;
    cin>>s;
    REP(i,10){
      s *= s;
      s = (int)(s/1e5)%10*1e3 + (int)(s/1e4)%10*1e2 + (int)(s/1e3)%10*10 +(int)(s/1e2)%10;
      printf("%d\n",s);
    }
  }

  return 0;
}

Measured memory_bytes: 0