akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;
const int MOD=1e9+7;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(double x){
    return fabs(x) < EPS ? 0 : x>0 ? 1 : -1 ;
}
int main(void){
    ll n;
    sf(n);
    int odd=n/2;
    int even=n/2;
    if(n%2==1)  odd++;
    cout << odd*even << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	A := sc.nextIntSlice(N + 1)
	B := sc.nextIntSlice(N)
	count := 0
	for i := 0; i < N; i++ {
		if A[i] >= B[i] {
			count += B[i]
		} else {
			count += A[i]
			B[i] -= A[i]
			if A[i+1] >= B[i] {
				count += B[i]
				A[i+1] -= B[i]
			} else {
				count += A[i+1]
				A[i+1] = 0
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,ans;
string s[100009];
map < vector<ll> , ll > mp;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		vector < ll > num(30);
		for(int j=0;j<s[i].size();j++){
			num[s[i][j]-'a']++;
		}
		ans += mp[num]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 42496
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

int H1,M1,H2,M2,K;

int main(){
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int dealy = 0;
    dealy = (H2 - H1) * 60 + (M2 - M1);

    cout << dealy - K << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
struct edge{ ll to; ll cap; ll rev;};

const ll MAXN=203;
vector<edge> G[MAXN];

bool used[MAXN];
ll yaku(ll a, ll b){
    if(a>b) return yaku(b,a);
    else{
        if(b%a==0) return a;
        else return yaku(b%a,a);
    }
}

void addEdge0(ll from, ll to, ll cap){
    edge A={to,cap,(ll)G[to].size()};
    edge B={from,0,(ll)G[from].size()};
    G[from].push_back(A);
    G[to].push_back(B);
    return;
}//有向グラフを作る

void addEdge1(ll a, ll b, ll cap){
    edge A={b,cap,(ll)G[b].size()};
    edge B={a,cap,(ll)G[a].size()};
    G[a].push_back(A);
    G[b].push_back(B);
    return;
}//無向グラフを作る

ll dfs(ll v, ll t, ll f){
    if(v==t) return f;
    used[v]=true;
    rep(i,G[v].size()){
        edge &e=G[v][i];
        if(!used[e.to] && e.cap>0){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

ll MaxFlow(ll Start, ll Goal){
    ll ans=0;
    while(true){
        rep(i,MAXN) used[i]=false;
        ll P=dfs(Start, Goal, INF);
        if(P==0) break;
        ans+=P;
    }
    return ans;
}

ll a[100][2], b[100][2];


int main(){
    ll N; cin>>N;
    rep(i,N) cin>>a[i][0]>>a[i][1];
    rep(i,N) cin>>b[i][0]>>b[i][1];
    rep(i,N) addEdge0(201,i,1);
    rep(i,N) addEdge0(100+i,202,1);
    rep(i,N) rep(j,N){
        if(a[i][0]<b[j][0] && a[i][1]<b[j][1]) addEdge0(i,j+100,1);
    }
    cout<<MaxFlow(201,202)<<endl;
    
}

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


int main(){
	int n;
	cin >> n;
	vector<pair<int,int> > edges;
	int sum = n;
	if(n % 2 == 0) sum++;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < i; j++){
			if(i + j == sum) continue;
			edges.push_back({i, j});
		}
	}
	cout << int(edges.size()) << '\n';
	for(auto x : edges){
		cout << x.first << ' ' << x.second << '\n';
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
using ll = long long;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> pos, neg;
  ll zero = 0;
  for (int i = 0; i < N; i++) {
    ll x;
    cin >> x;
    if (x > 0) pos.push_back(x);
    if (x < 0) neg.push_back(-x);
    if (x == 0) zero++;
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end());
  ll l = -(ll)1e18 - 1;
  ll r = (ll)1e18 + 1;
  while (r - l > 1) {
    ll m = (l + r) / 2;
    ll cnt = 0;
    if (m >= 0) {
      cnt += zero * (zero - 1) / 2;
      cnt += zero * (pos.size() + neg.size());
      cnt += (ll)pos.size() * neg.size();
      for (int i = 0; i < pos.size(); i++) {
        // pos[i] <= floor(m / pos[j])
        cnt += upper_bound(pos.begin() + i + 1, pos.end(), m / pos[i]) - (pos.begin() + i + 1);
      }
      for (int i = 0; i < neg.size(); i++) {
        cnt += upper_bound(neg.begin() + i + 1, neg.end(), m / neg[i]) - (neg.begin() + i + 1);
      }
    } else {
      for (int i = 0; i < pos.size(); i++) {
        cnt += neg.end() - lower_bound(neg.begin(), neg.end(), (-m + pos[i] - 1) / pos[i]);
      }
    }
    if (cnt < K) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << r << endl;
}

Measured memory_bytes: 2420
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, x = na()
a = na()

ans = 0
for i in range(n):
    if a[i] > x:
        ans += a[i] - x
        a[i] = x

for i in range(n - 1):
    if a[i] + a[i + 1] > x:
        t = a[i] + a[i + 1] - x
        ans += t
        a[i + 1] -= t

print(ans)

Measured memory_bytes: 14752
from enum import Enum
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class Type(Enum):
    win_Taro = 0
    win_Hanako = 1
    EVEN = 2

def comp_str(A,B):
    if A > B:
        return Type.win_Taro
    elif A < B:
        return Type.win_Hanako
    else:
        return Type.EVEN

N = int(input())

point_Taro = 0
point_Hanako = 0

for loop in range(N):
    line = str(input()).split()
    ret_type = comp_str(line[0],line[1])
    if ret_type == Type.win_Taro:
        point_Taro += 3
    elif ret_type == Type.win_Hanako:
        point_Hanako += 3
    else:
        point_Taro += 1
        point_Hanako += 1

print("%d %d"%(point_Taro,point_Hanako))


Measured memory_bytes: 6340
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

def linear_nCk(n,k):
    a = [1]*(k+1)
    for i in range(1,k+1):
        a[i] = a[i-1]*(n-k+i)//i
    return a[-1]

N,P = LI()
A = LI()

odd = 0
even = 0
for i in range(N):
    if A[i]%2 == 0:
        even += 1
    else:
        odd += 1

if P == 0:
    ans = 0
    for i in range(0,odd+1,2):
        ans += linear_nCk(odd,i)
    ans = ans*(2**even)
    print(ans)
else:
    ans = 0
    for i in range(1,odd+1,2):
        ans += linear_nCk(odd,i)
    ans = ans*(2**even)
    print(ans)

Measured memory_bytes: 38256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

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

	for(int n; cin >> n, n;) {
		vector<int> x(n, 0), y(n, 0);

		for(int i = 1; i < n; ++i) {
			int idx, d;
			cin >> idx >> d;
			x[i] = x[idx] + dx[d];
			y[i] = y[idx] + dy[d];
		}

		const int width = *max_element(x.begin(), x.end()) - *min_element(x.begin(), x.end()) + 1;
		const int height = *max_element(y.begin(), y.end()) - *min_element(y.begin(), y.end()) + 1;
		cout << width << " " << height << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BinomialCoefficients solver = new BinomialCoefficients();
        solver.solve(1, in, out);
        out.close();
    }

    static class BinomialCoefficients {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }
            Arrays.sort(a);
            long ans = a[n - 1];

            double mid = (double) ans / 2;
            double min = Long.MAX_VALUE;
            long ans2 = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] == ans) {
                    continue;
                }
                double tmp = Math.abs(mid - a[i]);
                if (tmp < min) {
                    min = tmp;
                    ans2 = a[i];
                }
            }
            out.print(ans + " " + ans2);
        }

    }
}



Measured memory_bytes: 60760
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int A[100], n, i, j, cnt, tmp;

	while (scanf("%d", &n) && n != 0) {
		cnt = 0;
		for (i = 0; i < n; ++i) scanf("%d", &A[i]);
		for (i = 0; i < n; i++)
			for (j = n - 1; j > i; --j)
				if (A[j - 1] > A[j])
					tmp = A[j], A[j] = A[j - 1], A[j - 1] = tmp, cnt++;
		printf("%d\n", cnt);
	}
	return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


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


int main()
{
  ll n, ini, gcdv;
  cin >> n >> ini;
  vecll x(n+1);
  x[0] = ini;
  forll(i, 0, n)
	cin >> x[i + 1];

  sort(x.begin(), x.end());

  if (x.size() < 3){
	cout << x[1] - x[0] << endl;
	return 0;
  }
  gcdv = gcd(x[1] - x[0], x[2] - x[1]);
  forll(i, 2, n)
	gcdv = gcd(gcdv, x[i+1] - x[i]);
  cout << gcdv << endl;
}



Measured memory_bytes: 1024
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        int[] input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        if (input[0] != input[1] && input[1] != input[2] && input[2] != input[0])
        {
            Console.WriteLine("No");
        }
        else if (input[0] != input[1] || input[1] != input[2])
        {
            Console.WriteLine("Yes");
        } else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13268
/**
*    author:  souzai32
*    created: 15.08.2020 14:10:08
**/

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
typedef long long ll;
using namespace std;

int main() {

    ll n,k;
    cin >> n >> k;
    ll ans=0;
    ans+=(n/k)*(n/k)*(n/k);
    if(k%2==0){
        ans+=((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

int c1[21];
int c2[21];

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

    int w, d;
    while (cin >> w >> d && w) {
        rep(i, 21) {
            c1[i] = 0;
            c2[i] = 0;
        }

        int ans = 0;
        rep(i, w) {
            int h;
            cin >> h;
            c1[h]++;
            ans += h;
        }
        rep(i, d) {
            int h;
            cin >> h;
            c2[h]++;
        }

        rep(i, 21) {
            if (c2[i] > c1[i]) {
                ans += i * (c2[i] - c1[i]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3212
# coding: utf-8
N = int(input())
S = {}
for _ in range(N):
    s = input()
    if s not in S:
        S[s] = 0
    S[s] += 1
M = int(input())
for _ in range(M):
    s = input()
    if s not in S:
        S[s] = 0
    S[s] -= 1
T = list(S.values())
T.append(0)
print(max(T))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string s;
int dp[100005];
int main()
{
	cin>>s;
    dp[0]=1;
	for(int i=0;i<s.size();i++)
	{
		if(dp[i]==0)continue;
		if(i+5<=s.size()&&s.substr(i,5)=="dream") dp[i+5]=1;
		if(i+5<=s.size()&&s.substr(i,5)=="erase") dp[i+5]=1;
		if(i+6<=s.size()&&s.substr(i,6)=="eraser") dp[i+6]=1;
		if(i+7<=s.size()&&s.substr(i,7)=="dreamer") dp[i+7]=1;
		}	
	if(dp[s.size()]==1) cout<<"YES"<<endl;
	else 
	    cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (ll i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<ll, ll>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	ll n; cin>>n;
	ll ans=(n/500)*1000;
	n=n%500;
	ans+=(n/5)*5;
	cout<<ans;
}

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

int main() {
    map <string,int> memo;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        memo[s] += 1;
    }
    int maxv = 0;
    for (const auto& x : memo){
        int v = x.second;
        if (v > maxv) maxv = v;
    }
    for (const auto& x : memo){
        if (x.second == maxv){
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 25216
//सत्यान्न प्रमदितव्यम्  ||
//Still, Taking my time to perfect the beats
//And I still got love for the streets, it's the A-D-D-U

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define LINF  0x3f3f3f3f3f3f3f3fll
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 

const ll mod = 999983;
#define mx 1000005
const ll mxi = 35;

int main()
{
    fast_as_levi;
    ll n,m,x;
    cin>>n>>m>>x;
    vector<pair<ll,vector<ll>>> ar;
    for(int i=0;i<n;i++)
    {
        ll z;
        cin>>z;
        vector<ll> tmp(m);
        for(int j=0;j<m;j++)
        {
            cin>>tmp[j];
        }
        ar.pb({z,tmp});
    }
    ll ans = LINF;
    for(int i=1;i<(1<<n);i++)
    {
        ll chk[m] = {0};
        ll ans1 = 0;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                ans1 += ar[j].fir;
                for(int k=0;k<m;k++)
                {
                    // cout<<ar[j].sec[k]<<" ";
                    chk[k] += ar[j].sec[k];
                }
            }
        }
        ll fl = 0;
        for(int j=0;j<m;j++)
        {
            if(chk[j]<x)
            fl = 1;
        }
        if(fl==0 && ans1<ans)
        {
            ans = ans1;
        }
    }
    if(ans==LINF)
    cout<<-1;
    else
    cout<<ans;
}

Measured memory_bytes: 3656
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*三日目*/
//少数も使いたい割り算はしない方がいい(三日目）
// 数値の大きさ
	int a[3][3];
	bool pic[3][3];
	bool b=false;
	for (int i = 0;i < 3;i++) {
		for (int j = 0;j < 3;j++) {
			cin >> a[i][j];
			pic[i][j] = false;
		}
	}
	int n; cin >> n;
	vector<int> bingo(n);
	for (int i = 0;i < n;i++)
		cin >> bingo[i];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 3;j++) {
			for (int h = 0;h < 3;h++) {
				if (bingo[i] == a[j][h])
					pic[j][h] = true;
			}
		}
	}
	
	for (int i = 0;i < 3;i++) {
		if (pic[i][0] == true and pic[i][1] == true and pic[i][2] == true)
			b = true;
		if (pic[0][i] == true and pic[1][i] == true and pic[2][i] == true)
			b = true;
	}if (pic[1][1]) {
		if (pic[0][0]) 
			if (pic[2][2])
				b = true;
		
		if (pic[2][0]) 
			if (pic[0][2])
				b = true;
		
	}if (b)
		cout << "Yes";
	else
		cout << "No";

}

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

ll n, a, b, c;
vector<ll> l;

ll dfs(ll i, ll la, ll lb, ll lc){
    if(i == n){
        if(min(la, min(lb, lc)) == 0) return 1e18;
        else return abs(a-la) + abs(b-lb) + abs(c-lc) - 30; // 30 is come from first merge.
    }
    ll ret0 = dfs(i+1, la, lb, lc); // l_i is not used for any tree.
    ll ret1 = dfs(i+1, la+l[i], lb, lc) + 10; // l_i is merged to A.
    ll ret2 = dfs(i+1, la, lb+l[i], lc) + 10; 
    ll ret3 = dfs(i+1, la, lb, lc+l[i]) + 10;
    return min(min(ret0, ret1), min(ret2, ret3));
}

int main(){
    cin >> n >> a >> b >> c;
    l.resize(n);
    rep(i, 0, n) cin >> l[i];
    
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = s[0];
            int D = s[1];

            int[,] glid = new int[N, D];
            for (int i = 0; i < N; i++)
            {
                var input = ReadLine().Split(' ');
                for (int j = 0; j < D; j++)
                {
                    glid[i, j] = int.Parse(input[j]);
                }
            }
            //input end

            int ans = 0;
            for (int i = 0; i < N; i++)
            {
               
                for (int j = 0; j < N; j++)
                {
                    if (i != j&& i> j)
                    {
                        double sum = 0;
                        for (int k = 0; k < D; k++)
                        {
                            sum += Pow(Abs(glid[i, k] - glid[j, k]), 2);
                        }

                        sum = Sqrt(sum);
                        if (sum - Floor(sum) == 0) ans++;
                    }
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] c = { 500, 100, 50, 10, 5, 1 };
        while (true) {
            int n = 1000 - sc.nextInt();
            if (n == 1000) {
                break;
            }
            int count = 0;
            while (n > 0) {
                for (int i = 0; i < c.length; i++) {
                    if (n >= c[i]) {
                        n -= c[i];
                        count++;
                        i--;
                    }
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 25768
#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;
	string s;
	cin >> n >> s;
	int a = 0, b = 0;
	rep(i,n) if(s[i] == 'R') ++a;
	int ans = max(a,b);
	rep(i,n){
		if(s[i] == 'R') --a;
		else b++;
		int now = max(a,b);
		ans = min(ans,now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3716
// Code for B - Substring
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define MOD 1000000007
#define mod(x) ( (x) % MOD + MOD ) % MOD

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T, typename U> void view(const std::map<T, U>& m){ for(const auto& e : m){ std::cout << e.first << "=>" << e.second << " "; } std::cout << std::endl; }

int main() {
  string S, T;
  cin >> S >> T;

  int min = INT_MAX;

  REP(i, S.length() - T.length() + 1) {
    int t = 0;
    REP(j, T.length()) {
      if (S[i + j] != T[j]) {
        t++;
      }
    }

    if (t < min) {
      min = t;
    }
  }

  cout << min << endl;
  return 0;
}


Measured memory_bytes: 3612
import Data.List

modulus :: Int
modulus = 10^9 + 7

powMod :: Int -> Int -> Int
powMod n p
  | p == 0    = 1
  | odd p     = n * powMod n (p-1) `mod` modulus
  | otherwise = let t = powMod n (p `div` 2)
                 in (t^2) `mod` modulus

solve :: Int -> [Int] -> Int
solve n a
  | even n = if chk e then powMod 2 (n `div` 2) else 0
  | odd  n = if chk o then powMod 2 ((n-1) `div` 2) else 0
  where
    e = concat [ [i,i] | i <- [1,3..]]
    o = 0 : concat [ [i,i] | i <- [2,4..]]
    chk ex = all (uncurry (==)) . zip ex $ sort a

main :: IO ()
main = do
    n <- readLn :: IO Int
    a <- map read . words <$> getLine :: IO [Int]
    print $ solve n a

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

using namespace std;

const int maxn = 1111;
using ll = long long;
const ll mod = 1000000000 + 7;

char mm[maxn][maxn];
ll dp[maxn][maxn];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int h, w; cin >> h >> w;
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) cin >> mm[i];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i) dp[i][j] += dp[i-1][j];
            if (j) dp[i][j] += dp[i][j-1];
            if (mm[i][j]=='#') dp[i][j] = 0;
            dp[i][j] = dp[i][j] % mod;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}

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

#define MAXN 100010
#define ll long long
#define mod 1000000007

using namespace std;

int n, tot, ans;

int a[MAXN];

string s;

int main() {
	int t;
	int x, y;
	cin >> x >> y;
	cout << x * (x - 1) / 2 + y * (y - 1) / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque

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

positives = deque(sorted(a))
negatives = deque([positives.popleft()])
while len(positives) > 1:
    if positives[0] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M
print(sum(positives) - sum(negatives))

while len(positives) > 1:
    y = positives.popleft()
    x = negatives.pop()
    print(x, y)
    negatives.append(x - y)

x = positives.popleft()

while len(negatives) > 0:
    y = negatives.pop()
    print(x, y)
    x = x - y

Measured memory_bytes: 66012
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;

using namespace std;

const int C = 1000000007;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n), pref = {0};
    for (int q = 0; q < n; q++){
        cin >> a[q];
        pref.push_back((pref.back()+a[q]) % C);
    }
    int ans = 0;
    for (int q = 0; q < n; q++){
        ans += a[q]*pref[q] % C;
    }
    cout << ans % C << endl;
    return 0;
}


Measured memory_bytes: 6904
cook = []
amari = [0]
t = 0
for i in range(5):
    cook.append(int(input()))

for i in range(5):
    if cook[i] % 10 != 0:
        t += cook[i] + (10 - cook[i] % 10)
    else:
        t += cook[i]

for i in range(5):
    if cook[i] % 10 != 0:
        amari.append(10 - cook[i] % 10)

print(t - max(amari))


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int W=scanner.nextInt();
		int[] w=new int[n+1];
		int[] v=new int[n+1];
		int w0=0;
		for(int i=1;i<=n;i++) {
			w[i]=scanner.nextInt();
			v[i]=scanner.nextInt();
			if(i==1)w0=w[i]-1;
			w[i]-=w0;
		}
		long[][][] dp=new long[n+1][401][101];
		for(int i=0;i<=n;i++) {
			for(int j=0;j<=400;j++) {
				Arrays.fill(dp[i][j], Integer.MIN_VALUE);
			}
		}
		dp[0][0][0]=0;
		for(int i=1;i<=n;i++) {
			for(int j=0;j<=400;j++) {
				for(int k=0;k<=i;k++) {
					if (j - w[i] >= 0 && k - 1 >= 0 && j <=W-k*w0)
						dp[i][j][k] = Math.max(dp[i - 1][j][k], dp[i - 1][j - w[i]][k-1] + v[i]);
					else
						dp[i][j][k] = dp[i - 1][j][k];
				}
			}
		}
		long ans=Integer.MIN_VALUE;
		for(int i=0;i<=400;i++) {
			for(int j=0;j<=n;j++) {
				ans=Math.max(ans, dp[n][i][j]);
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 84940
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define INFLL 1000000000000000000LL
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>

using namespace std;

// clang-format on

main {
  string s;
  cin >> s;
  int c = 0;
  rep(i, 1 << s.size() - 1) {
    string t = s;
    rep(j, s.size() - 1) if (i >> j & 1) t.insert(s.size() - j - 1, "+");
    stringstream ss;
    ss << t;
    int n;
    while (ss >> n) {
      c += n;
    }
  }
  cout << c << endl;
  bye;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static int K;
    public static int X;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        K = sc.nextInt();
        X = sc.nextInt();

        int distance = K - 1;

        int from = X - distance;
        int to = X + distance;

        int output = from;
        while (output <= to) {
            System.out.println(output);
            output++;
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

#define N 110

int a[N];

int main() {
    while (scanf("%d%d%d", &a[0], &a[1], &a[2]) != EOF) {
        int cost = 0;
        sort(a, a + 3);
        cost = abs(a[1] - a[0]) + abs(a[2] - a[1]);
        printf("%d\n", cost);
    }
    return 0;
}


Measured memory_bytes: 128
def solve(n, h):
    dp = [10**10] * n
    dp[n-1] = 0
    for i in range(n-1, -1, -1):
        for k in [1,2]:
            if i+k < n:
                dp[i] = min(dp[i], dp[i+k] + abs(h[i+k] - h[i]))
    return dp[0]

n = input()
h = map(int, raw_input().split())
print(solve(n, h))

Measured memory_bytes: 12052
#include<iostream>
using namespace std;
class Dice{
    int x[7] = {};
    public:
    void input(int I, int num){
        x[I] = num;
    }
   
    void move(char order){
        int oldx[7];
        for(int i = 1; i <= 7; i ++){
            oldx[i] = x[i];
        }
        if(order == 'N'){
            x[1] = oldx[2];
            x[2] = oldx[6];
            x[6] = oldx[5];
            x[5] = oldx[1];
        } 
        else if(order == 'S'){
            x[1] = oldx[5];
            x[2] = oldx[1];
            x[6] = oldx[2];
            x[5] = oldx[6];
        }
        else if(order == 'W'){
            x[1] = oldx[3];
            x[4] = oldx[1];
            x[6] = oldx[4];
            x[3] = oldx[6];
        }
        else if(order == 'E'){
            x[1] = oldx[4];
            x[4] = oldx[6];
            x[6] = oldx[3];
            x[3] = oldx[1];
        }
    }
    void rotation(int top, int front){
       for(int i = 0; i < 4; i++){
           move('S');
           if(x[2] == top){
               for(int j = 0; j < 4; j++){
                   move('W');
                   if(x[6] == front){
                       move('N');
                       break;
                   }
               }
           }
           else if(x[2] == front){
               for(int j = 0; j < 4; j++){
                   move('E');
                   if(x[1] == top) break;
                   
               }
               
           }
           
       }
        
    }
    bool same(Dice a, Dice b){
        char ch[7] = "NNNWWW";
        for(int i = 0; i <= 6; i ++){
            b.rotation(a.print(1),a.print(2));
            if(a.print(1) == b.print(1) && a.print(2) == a.print(2) && a.print(3) == b.print(3) && a.print(4) == b.print(4) && a.print(5) == b.print(5) && a.print(6) == b.print(6)){
                return true;
                break;
            }
            else a.move(ch[i]);
        }
        if(a.print(1) != b.print(1) || a.print(2) != a.print(2) || a.print(3) != b.print(3) || a.print(4) != b.print(4) || a.print(5) != b.print(5) || a.print(6) != b.print(6)) return false;
    }
    
   
    int print(int num){
        return x[num];
        
    }
    
};

int main(){
    int val,n;
    cin >> n;
    Dice dice[n+1];
    for(int j = 1; j <= n; j++){
        for(int i = 1;i <= 6; i++){
            cin >> val;
            dice[j].input(i,val);
        }
    }
    for(int i = 2; i <= n; i++){
        if(dice[1].same(dice[1],dice[i])){
            cout << "No" << endl;
            break;
        }
        if(i == n) cout << "Yes" << endl;
        
    }
    return 0;
}




Measured memory_bytes: 3100
#include <stdio.h>

int main(){
  int n, m, l;
  scanf("%d%d%d", &n, &m, &l);
  int a[n][m];
  int b[m][l];
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  for(int i = 0; i < m; i++) for(int j = 0; j < l; j++) scanf("%d", &b[i][j]);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      long int sum = 0;
      for(int k = 0; k < m; k++){
        sum += a[i][k] * b[k][j];
      }
      printf("%ld", sum);
      if(j < l - 1) printf(" ");
      else printf("\n");
    }
  }
}



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

int p, q, r, cursor;
string s;

int NOT(int a) {
	return 2 - a;
}

int AND(int a, int b) {
	if(a == 0 || b == 0) return 0;
	if(a == 1 || b == 1) return 1;
	return 2;
}

int OR(int a, int b) {
	if(a == 2 || b == 2) return 2;
	if(a == 1 || b == 1) return 1;
	return 0;
}

int f() {
	char c = s[cursor];
	cursor++;
	if(c == '0') return 0;
	if(c == '1') return 1;
	if(c == '2') return 2;
	if(c == 'P') return p;
	if(c == 'Q') return q;
	if(c == 'R') return r;
	if(c == '-') return NOT(f());
	if(c == '(') {
		int a = f();
		char op = s[cursor];
		cursor++;
		int b = f();
		cursor++;
		if(op == '*') {
			return AND(a, b);
		}
		else {
			return OR(a, b);
		}
	}
	return -1;
}

int main() {
	while(cin >> s, s[0] != '.') {
		int ans = 0;
		for(p = 0; p <= 2; p++) {
			for(q = 0; q <= 2; q++) {
				for(r = 0; r <= 2; r++) {
					cursor = 0;
					if(f() == 2) ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188
#include <cstdio>
#include <vector>

#define MAX(a,b) ((a)>(b)?(a):(b))

using namespace std;


struct BINNODE {
	int parent;
	int depth;
	int degree;
	int sibling;
	int left;
	int right;
	int height;

	BINNODE () { // default constructor
		parent=-1;
		depth=0;
		degree=0;
		sibling=-1;
		left=-1;
		right=-1;
		height=-1;
	}
};

int heightSearch(vector<BINNODE>& node, int target) {
	if(target == -1) return -1;
	else if(node[target].height!=-1) return node[target].height;
	else return MAX(heightSearch(node,node[target].left),heightSearch(node,node[target].right))+1;
}

int main() {
	int n;
	int i,c;
	int id,left,right;
	vector<BINNODE> node;
	scanf("%d",&n);
	node.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d%d%d",&id,&left,&right);
		node[id].left=left;
		node[id].right=right;
		if(left==-1 && right==-1) {
			node[id].degree=0;
		} else if(left==-1) {
			node[id].degree=1;
			node[right].parent=id;
			node[right].sibling=-1;
		} else if(right==-1) {
			node[id].degree=1;
			node[left].parent=id;
			node[left].sibling=-1;
		} else {
			node[id].degree=2;
			node[left].parent=id;
			node[right].parent=id;
			node[left].sibling=right;
			node[right].sibling=left;
		}
	}
	for(i=0; i<n; ++i) {
		c=0;
		id=i;
		while(node[id].parent!=-1) {
			++c;
			id=node[id].parent;
		}
		node[i].depth=c;
		node[i].height=heightSearch(node,i);
	}
	for(i=0; i<n; ++i) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
				,i,node[i].parent,node[i].sibling,node[i].degree,node[i].depth,node[i].height);
		if(node[i].parent==-1) {
			printf("root\n");
		} else if (node[i].left==-1&&node[i].right==-1) {
			printf("leaf\n");
		} else {
			printf("internal node\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   char a,b; cin >> a >> b;
   bool c,d;
   c = (a=='H' ? true : false);
   d = (b=='H' ? true : false);
   cout <<  (((c&&d)||((!c)&&(!d))) ? "H" : "D") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  int h,m,s,ss;
  scanf("%d",&ss);
  s=ss%60;
  m=((ss-s)/60)%60;
  h=(ss-s-m*60)/3600;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
};

Measured memory_bytes: 592
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    int A,B;
  	char C;
  	cin >> A >> C >> B;
    if(C=='+')cout << A+B << endl; else cout << A-B << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,h,c;
struct p{
    int l;
    int r;
}a[1000005];
bool cmp(p xx,p yy){
    return xx.l>yy.l;
}
int main(void){
    cin>>n>>h;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[c++].l);
        a[c].r=1;
        scanf("%d",&a[c++].l);
    }
    sort(a,a+c,cmp);
    int sum=0;
    for(int i=0;i<c;i++)
    {
        if(a[i].r==1)
        {
            sum++;
            h-=a[i].l;
            if(h<=0)
            {
                printf("%d",sum);
                return 0;
            }
        }
        else if(a[i].r!=1)
        {
            if(h%a[i].l==0) sum+=h/a[i].l;
            else sum+=h/a[i].l+1;
            printf("%d",sum);
            exit(0);
        }
    }
}

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

int main()
{
    string ans = "NO";
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b)
        ans = "YES";
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
s=input()
l=len(s)
for i in range(l-2):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    exit()
  elif s[i]==s[i+2]:
    print(i+1,i+3)
    exit()
if s[l-2]==s[l-1]:
  print(l-1,l)
  exit()
print(-1,-1)

Measured memory_bytes: 3188
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
using namespace std;
vector<int>rotate(vector<int>v)
{
	vector<int>r;
	r.resize(4);
	r[0] = v[1], r[1] = v[2], r[2] = v[3], r[3] = v[0];
	return r;
}
vector<int>d[444];
typedef long long ll;
unordered_map<ll, ll>ma;
ll conv(vector<int>v)
{
	return (((ll)v[0]) << 30) + (((ll)v[1]) << 20) + (((ll)v[2]) << 10) + ((ll)v[3]);
}
void add(vector<int>v)
{
	ll t = conv(v);
	for (int i = 0; i < 4; i++)
	{
		ma[t]++;
		t = ((t&((1LL << 40) - (1LL << 30))) >> 30) + ((t&((1LL << 30) - 1)) << 10);
	}
}
void sub(vector<int>v)
{
	ll t = conv(v);
	for (int i = 0; i < 4; i++)
	{
		ma[t]--;
		t = ((t&((1LL << 40) - (1LL << 30))) >> 30) + ((t&((1LL << 30) - 1)) << 10);
	}
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		vector<int>v;
		for (int j = 0; j < 4; j++)
		{
			int z;
			scanf("%d", &z);
			v.push_back(z);
		}
		d[i] = v;
		add(v);
	}
	ll ans = 0;
	for (int i = 0; i < num; i++)
	{
		for (int j = i + 1; j < num; j++)
		{
			vector<int>s = d[i], t = d[j];
			sub(s), sub(t);
			swap(t[0], t[2]);
			for (int k = 0; k < 4; k++)
			{
				ll x = 1;
				vector<vector<int> >ddd;
				for (int l = 0; l < 4; l++)
				{
					vector<int>z;
					z.resize(4);
					z[0] = s[1], z[1] = s[0], z[2] = t[0], z[3] = t[1];
					x *= ma[conv(z)];
					sub(z);
					ddd.push_back(z);
					s = rotate(s), t = rotate(t);
				}
				for (int l = 0; l < 4; l++)add(ddd[l]);
				//if (x > 0)printf("%d %d %lld\n", i, j, x);
				ans += x;
				t = rotate(t);
			}
			swap(t[0], t[2]);
			add(s), add(t);
		}
	}
	printf("%lld\n", ans / 3);
}

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

using namespace std;

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

  int A[n];
  for(int i=0; i<n; ++i) cin >> A[i];

  int q;
  cin >> q;

  int order, b, e;

  for(int i=0; i<q; ++i){

    /* 0 : min, 1 : max */
    cin >> order >> b >> e;

    if(order == 0){
      int min = *min_element(A+b, A+e);
      cout << min << endl;
    }
    else if(order == 1){
      int max = *max_element(A+b, A+e);
      cout << max << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 3096
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

vector<int> dpr(4005,0), dpg(4005,0), dpb(4005,0);
ll ans = 0;
void solve()
{
    int n; cin>>n;
    string s; cin>>s;
    rep(i,1,n+1)
    {
        dpr[i] = dpr[i-1] + (s[i-1] == 'R');
        dpg[i] = dpg[i-1] + (s[i-1] == 'G');
        dpb[i] = dpb[i-1] + (s[i-1] == 'B');
    }

    rep(i,1,n-1)
    {
        rep(j,i+2,n+1)
        {
            char x = s[i-1], y = s[j-1];
            if(x<y) swap(x,y);
            if(x == 'R' and y == 'G')
            {
                ans+=(dpb[j-1]-dpb[i] - ((j-i)%2 == 0 and s[(i+j)/2 - 1] == 'B'));
            }
            if(x == 'R' and y == 'B')
            {
                ans+=(dpg[j-1]-dpg[i] - ((j-i)%2 == 0 and s[(i+j)/2 - 1] == 'G'));
            }
            if(x == 'G' and y == 'B')
            {
                ans+=(dpr[j-1]-dpr[i] - ((j-i)%2 == 0 and s[(i+j)/2 - 1] == 'R'));
            }
        }
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3676