akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_AtCoder
{
    class Program
    {
        static decimal distance_sum;
        static int N;
        static int N_b;
        static decimal[,] distance;

        
        static void Factorial(int n, int N)
        {
            if (n > N) return;
            N_b *= n;
            Factorial(n + 1, N);
        }

        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());
            decimal[] x = new decimal[N];
            decimal[] y = new decimal[N];
            for(int i = 0; i < N; i++)
            {
                decimal[] input = Console.ReadLine().Split(' ').Select(s => decimal.Parse(s)).ToArray();
                x[i] = input[0];
                y[i] = input[1];
            }

            distance = new decimal[N, N];
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < N; j++)
                {
                    if (i == j) continue;
                    decimal dx = x[i] - x[j];
                    decimal dy = y[i] - y[j];
                    decimal r = dx * dx + dy * dy;
                    distance[i, j] = (decimal)Math.Sqrt((double)r);
                }
            }

            distance_sum = 0;
            N_b = 1;
            int N_1 = 1;
            Factorial(1, N);
            N_1 = N_b;
            N_b = 1;
            int N_2 = 1;
            Factorial(1, N - 2);
            N_2 = N_b;

        
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < N; j++)
                {
                    if (i == j) continue;
                    distance_sum += distance[i, j] * (decimal)(N - 1) * N_2;
                }
            }
                       
            Console.WriteLine(distance_sum / (decimal)N_1);


        }
    }
}


Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N; cin >> N;
	long long x = 0, y = 0, T = 0;
	for (long long i = 0; i < N; i++) {
		long long t, X, Y;
		cin >> t >> X >> Y;
		if ((abs(X - x) + abs(Y - y) - (t - T)) > 0 || (abs(X - x) + abs(Y - y) - (t - T)) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
		x = X;
		y = Y;
		T = t;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    vector<string> words(3);
    rep(i, 3) cin >> words[i];

    rep(i, 3) cout << words[i][i];
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;

ll r[2001][2001];
void solve() {
	int n, m; cin >> n >> m;
	vector<int> a(n), b(m);
	rep(i, n)cin >> a[i];
	rep(i, m)cin >> b[i];
	rep(i, n + 1) {
		r[i][0] = 1;
	}
	rep(j, m + 1) {
		r[0][j] = 1;
	}
	rep1(i, n) {
		rep1(j, m) {
			ll add = 0;
			if (a[i-1] == b[j-1]) {
				add = r[i - 1][j - 1];
			}
			r[i][j] = add;
			r[i][j] += r[i-1][j];
			r[i][j] += r[i][j - 1];
			r[i][j] -= r[i - 1][j - 1];
			r[i][j] = (r[i][j] % mod + mod) % mod;
		}
	}
	ll ans = r[n][m];
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 31616
N, A, B, C, D = map(int, input().split())
S = input()

flag1 = 0

for i in range(C-A-2):
    if S[i+A] == S[i+A+1] == "#":
        flag1 = 1
for i in range(D-B-2):
    if S[i+B] == S[i+B+1] == "#":
        flag1 = 1    

flag2 = 0

if (B<D) & (D<C): #ABDC
    flag2 = 1
    for i in range(D-B+1):
        if S[B-2+i] == S[B-1+i] == S[B+i] == ".":
            flag2 = 0

if (flag1 == 0) & (flag2 == 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3640
import sys
import math 
import numpy as np
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N,K=na()
n=N
k=10**9
cnt=0
if(N==1):
    if(K==1):
        print(1)
        exit()
    else:
        ans=0
        while(N<K):
            ans+=1
            N*=2
            #print(N)
        print(0.5**ans)
        exit()
while(N<K):
    #print(N,K)
    K=math.ceil(K/2)
    cnt+=1
k=K

ans=0
first=True
while(True):
    if(first):
        ans+=(N-k+1)*(0.5**cnt)
        first=False
    else:
        ans+=(N-k)*(0.5**cnt)

    #print("ddd",(N-k+1)*(0.5**cnt),"N",N,"k",k,"n-k+1",N-k+1,"cnt",cnt)
    #print("ans",ans)
    cnt+=1
    N=k
    k=math.ceil(k/2)
    #print("k",k)
    if(k==1):
        ans+=1*(0.5**cnt)
        #print("ddd",1*(0.5**cnt))
        #print("cnt",cnt)
        break
#print(ans,n)
ans=ans/n
print(ans)

Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
char arr[10000][10000];
ll dp[10000][10000];
ll solve(int n,int m,int i,int j)
{
	if(i==n-1&&j==m-1)
		return 1;
	if(i>=n||j>=m||arr[i][j]=='#')
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	int a=0,b=0;
	a=solve(n,m,i+1,j);
	b=solve(n,m,i,j+1);
	return dp[i][j]=(a+b)%mod;

}

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>arr[i][j];
	memset(dp,-1,sizeof dp);
	cout<<solve(n,m,0,0);
}

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

int main() {
	int n;cin>>n;
	n--;
	vector<int>v(n+1);
	for(int i=0;i<n;i++) {
		cin>>v[i];
	}
	int a=v[0];
	int sum=a;
	for (int i=1;i<n;i++) {
		sum+=min(a,v[i]);
		a=v[i];
	}
	sum+=a;
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,l,r,num;
  num = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    if (r > l) {
      num += r - l + 1;
    }
    else{
      num += l - r + 1;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
        long current = a.Sum();
        long max = current;
        for (int i = 1; i < a.Length; i += 2)
        {
            a[i - 1] *= -1;
            a[i] *= -1;
            current += (a[i - 1] + a[i]) * 2;
            max = Max(max, current);
        }
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 33628
def prime_factorize(n):
    """Calculate prime factorization and return unique numbers and 1.
    """
    ans = set()
    ans_add = ans.add
    ans_add(1)
    while n % 2 == 0:
        ans_add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans_add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans_add(n)
    return ans


def main():
    x = int(input())
    # 素因数分解してユニークな因数を取る。
    insu = prime_factorize(x)
    # a^5 - b^5 も a - b も，ある因数の倍数となる。
    # ここは a >= b と仮定すると，a は正でなくては，xが負になっちゃう。

    b_min = -int(x ** (1 / 5))
    for n in insu:
        b = b_min
        while 1:
            a = b
            while 1:
                a += n
                if a < 0:
                    continue
                cand = a ** 5 - b ** 5
                if cand == x:
                    return f'{a} {b}'
                elif cand > x:
                    break
            b += 1
            if (b + n) ** 5 - b ** 5 > x:
                break


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9392
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  int s = 0;
  int sp = 0;
  int ans = 1;

  for (int i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) s = 1;
    if (a[i] > a[i + 1]) s = -1;

    if (s == 1 && sp == -1 || s == -1 && sp == 1) {
      ans++;
      s = 0;
      sp = 0;
      continue;
    }
    sp = s;
  }

  cout << ans << endl;
}


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

typedef long long ll;

ll t[202020];


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //Älä käytä, jos tehtävä on interaktiivinen!
    ll n, k;
    cin >> n >> k;
    for (int i=1; i<=n; ++i) cin >> t[i];
    ll b=1;
    bool yes=1;
    while (yes){
        ll a=0;
        for (int i=1; i<=n; ++i){
            ll c=t[i]/b;
            if ((t[i]%b)==0) a+=c-1;
            else a+=c;
        }
        if (a>k){
            b*=2;
        }
        else yes=0;
    }
    b/=2;
    ll d=b;
    while (b>0){
        ll a=0;
        for (int i=1; i<=n; ++i){
            ll c=t[i]/(b+d);
            if ((t[i]%(b+d))==0) a+=c-1;
            else a+=c;
        }
        if (a>k){
            d+=b;
        }
        if (b>2) b++;
        b/=2;
    }
    cout << d+1 << "\n";
}






Measured memory_bytes: 5208
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        x: usize, y: usize
    }

    let mut ans = "No";

    for t in 0..=x {
        let l = t * 4 + (x - t) * 2;
        if l == y {
            ans = "Yes"
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2092
(let ((s (read-line))
    (n 0))
    (if (not (zerop (rem (length s) 2)))
        (setq s (subseq s 0 (- (length s) 1)))
        (setq s (subseq s 0 (- (length s) 2)))
    )
    (setq n (length s))
    (loop for _ below (/ n 2) do
        (if (string= (subseq s 0 (/ (length s) 2)) (subseq s (/ (length s) 2) (length s)))
            (progn
            (format t "~D~%" (length s))
            (return)
            )
            (setq s (subseq s 0 (- (length s) 2)))
        )
    )
)

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

int main()
{
    int n, a, amin = 1000001, amax = -1000001;
    long sum = 0;
    cin >> n;

    while (n--) {
        cin >> a;
        amin = min(amin, a);
        amax = max(amax, a);
        sum += a;
    }

    cout << amin << " " << amax << " " << sum << endl;

    return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
typedef pair<int,char>pic;
pic d[37]={},e[37]={};

int main() {

	int n;
	cin>>n;
	rep(i,n*2){
		if(i%2==0){
			char c;
			cin>>c;
			d[i/2].second=c;
			e[i/2].second=c;
		}else{
			int a;
			cin>>a;
			d[i/2].first=a;
			e[i/2].first=a;
		}
	}
	rep(i,n-1){
		for(int j=n-1; j>i; j--){
			if(d[j].first<d[j-1].first){
				char x=d[j].second;
				int y=d[j].first;
				d[j].first=d[j-1].first;
				d[j].second=d[j-1].second;
				d[j-1].first=y;
				d[j-1].second=x;
			}
		}
	}
	rep(i,n-1){
		int mi=i;
		for(int j=i+1; j<n; j++){
			if(e[j].first<e[mi].first)mi=j;
		}
		char x=e[i].second;
		int y=e[i].first;
		e[i].first=e[mi].first;
		e[i].second=e[mi].second;
		e[mi].first=y;
		e[mi].second=x;
	}
	int f=0;
	rep(i,n){
		if(d[i].second!=e[i].second)f=1;
	}
	rep(j,n-1)cout<<d[j].second<<d[j].first<<" ";
	cout<<d[n-1].second<<d[n-1].first<<endl;
	cout<<"Stable"<<endl;
	rep(j,n-1)cout<<e[j].second<<e[j].first<<" ";
	cout<<e[n-1].second<<e[n-1].first<<endl;
	if(f==0)cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;

	return 0;
}



Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    static Node nodeRoot;
    static StringBuilder sb = new StringBuilder();

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            String s = br.readLine();
            if (s.charAt(0) == 'i') {
                int m = Integer.parseInt(s.substring(7));
                if (nodeRoot == null) {
                    nodeRoot = new Node(m);
                    continue;
                }
                insert(m, nodeRoot);
            } else if (s.charAt(0) == 'p') {
                sb.append(" ");
                inorder(nodeRoot);
                sb.deleteCharAt(sb.length() - 1).append("\n").append(" ");
                preorder(nodeRoot);
                sb.deleteCharAt(sb.length() - 1).append("\n");
            } else {
                int m = Integer.parseInt(s.substring(5));
                sb.append(find(m, nodeRoot) ? "yes\n" : "no\n");

            }
        }
        System.out.print(sb);
    }

    private static boolean find(int m, Node node) {
        if (node == null) return false;
        if (m > node.value) {
            return find(m, node.right);
        } else if (m < node.value) {
            return find(m, node.left);
        } else {
            return true;
        }
    }

    private static void preorder(Node node) {
        if (node == null) return;
        sb.append(node.value).append(" ");
        preorder(node.left);
        preorder(node.right);
    }

    private static void inorder(Node node) {
        if (node == null) return;
        inorder(node.left);
        sb.append(node.value).append(" ");
        inorder(node.right);
    }

    private static void insert(int m, Node node) {
        if (m > node.value) {
            if (node.right == null) node.right = new Node(m);
            else insert(m, node.right);
        } else {
            if (node.left == null) node.left = new Node(m);
            else insert(m, node.left);
        }
    }

    static class Node {
        int value;
        Node left;
        Node right;

        public Node(int value) {
            this.value = value;
        }
    }
}



Measured memory_bytes: 102788
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main()  {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i = 0; i < 1000; i++) {
        string T = "";
        T+=to_string(i/100);
        T+=to_string((i%100-i%10)/10);
        T+=to_string(i%10);
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if(S[j] == T[cnt]) {
                cnt++;
            }
            if(cnt == 3) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3780
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrep1(i,n) for(int i=n;i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
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 (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
	string s, t;
	cin >> s >> t;
	vector<char> to(26, '?');
	rep(i, s.size()) {
		if (to[s[i] - 'a'] == '?') {
			to[s[i] - 'a'] = t[i];
		}
		else {
			if (to[s[i] - 'a'] != t[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	vi used(26, 0);
	rep(i, 26) {
		if (to[i] == '?') {
			continue;
		}
		if (used[to[i] - 'a']) {
			cout << "No" << endl;
			return 0;
		}
		else {
			used[to[i] - 'a'] = 1;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
#include <stdio.h>
int main(){
  int n, i, ans=0, temp=0, j;
  scanf("%d", &n);
  for(j=1;j<=n;j++){
    for(i=1;i<=j;i+=2){
      if(j%i==0){
        temp++;
      }
    }
    if(temp==8){
      ans++;
    }
    temp=0;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)

using ll = int64_t;
using ld = long double;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr ll inf = 2e18;
constexpr int M = 1e9 + 7;

constexpr int N = 301;
ld E[N][N][N];

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

	int n, c[3] = {0, 0, 0}; cin >> n;
	rep(i, 0, n) { int a; cin >> a; ++c[--a]; }
	rep(k, 0, n + 1)
		rep(j, 0, n + 1)
			rep(i, 0, n + 1) {
				int s = i + j + k;
				if (n < s) break;
				if (s == 0) continue;
				auto &x = E[i][j][k];
				x = n;
				if (i) x += i * E[i - 1][j][k];
				if (j) x += j * E[i + 1][j - 1][k];
				if (k) x += k * E[i][j + 1][k - 1];
				x /= s;
			}
	cout << fixed << setprecision(10) << E[c[0]][c[1]][c[2]];
}

Measured memory_bytes: 426240
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private final static byte MASK_RIGHT = 0x0F; //右4bit数値化用マスク
	private final static int STRIP_LENGTH = 10; //短冊1行の長さ
	private static int[] punchTape = new int[100]; //10*10の方眼紙を短冊にしてくっつけた紙テープ

	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 256);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	/**
	 *都合の良い滴下
	 */
	private static void droppingInk(int x, int y, int size) {
		sinking(x, y - 1);
		sinking(x - 1, y);
		sinking(x, y);
		sinking(x + 1, y);
		sinking(x, y + 1);
		if (size == 1) {
			return;
		}

		sinking(x - 1, y - 1);
		sinking(x + 1, y - 1);
		sinking(x - 1, y + 1);
		sinking(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		sinking(x, y - 2);
		sinking(x - 2, y);
		sinking(x + 2, y);
		sinking(x, y + 2);
	}

	/**
	 * 床は汚さないようにする
	 */
	private static void sinking(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			punchTape[x * STRIP_LENGTH + y]++;
		}
	}

	/**
	 *紙の染みを数え、損害を報告する
	 */
	private static void calcResult() {
		int white = 0;//綺麗な部分
		int max = 0;//一番ひどい汚れ
		for (int i = 0; i < 100; i++) {
			if (punchTape[i] == 0) {
				white++;
			} else if (punchTape[i] > max) {
				max = punchTape[i];
			}
		}
		System.out.println(white);
		System.out.println(max);
	}
}

Measured memory_bytes: 16996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;

	ll X[100], Y[100];
	rep(i, N) cin >> X[i] >> Y[i];

	double kotae = 0;
	rep(i, N) {
		ll x = 0;
		ll y = 0;
		rep(j, N) {
			if (X[i] * Y[j] - X[j] * Y[i] > 0) {
				x += X[j];
				y += Y[j];
			}
			else if (X[i] * Y[j] - X[j] * Y[i] == 0 && X[i] * X[j] >= 0 && Y[i] * Y[j] >= 0) {
				x += X[j];
				y += Y[j];
			}
		}
		kotae = max(kotae, sqrt(x * x + y * y));
		x = 0;
		y = 0;
		rep(j, N) {
			if (X[i] * Y[j] - X[j] * Y[i] < 0) {
				x += X[j];
				y += Y[j];
			}
			else if (X[i] * Y[j] - X[j] * Y[i] == 0 && X[i] * X[j] >= 0 && Y[i] * Y[j] >= 0) {
				x += X[j];
				y += Y[j];
			}
		}
		kotae = max(kotae, sqrt(x * x + y * y));
		x = 0;
		y = 0;
		rep(j, N) {
			if (X[i] * Y[j] - X[j] * Y[i] > 0) {
				x += X[j];
				y += Y[j];
			}
		}
		kotae = max(kotae, sqrt(x * x + y * y));
		x = 0;
		y = 0;
		rep(j, N) {
			if (X[i] * Y[j] - X[j] * Y[i] < 0) {
				x += X[j];
				y += Y[j];
			}
		}
		kotae = max(kotae, sqrt(x * x + y * y));
	}

	cout << setprecision(12) << kotae << endl;


	Would you please return 0;
}


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

using namespace std;

using ll = long long;

// Runs range sum queries only.
// Sum : O(1)
template <class Abel>
class CumulativeSum
{
	std::vector<Abel> sums_;

  public:
	CumulativeSum(const std::vector<Abel> &data) : sums_(data)
	{
		sums_.insert(sums_.begin(), Abel(0));
		for (int i = 1; i < (int)sums_.size(); ++i)
		{
			sums_[i] += sums_[i - 1];
		}
	}

	// Gets the sum of data[0, right)
	Abel Sum(int right) { return sums_[right]; }

	// Gets the sum of data[left, right)
	Abel Sum(int left, int right) { return Sum(right) - Sum(left); }
};

int main()
{
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int> a(n);
	for (int i = 0; i < n - 1; ++i)
	{
		if (s[i] == 'A' && s[i + 1] == 'C')
		{
			a[i] = 1;
		}
	}
	CumulativeSum<int> cs(a);
	for (int i = 0; i < q; ++i)
	{
		int l, r;
		cin >> l >> r;
		cout << cs.Sum(l - 1, r - 1) << endl;
	}
}

Measured memory_bytes: 1784
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
int a[200010];
int main(){
    int n;
    while(~scanf("%d",&n)){
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        if(n==1) printf("%d\n",a[1]);
        else{
            if(n%2==0){
                for(int i=n;i>0;i-=2){
                    printf("%d ",a[i]);
                }
                for(int i=1;i<n-1;i+=2){
                    printf("%d ",a[i]);
                }
                printf("%d\n",a[n-1]);
            }
            else{
                for(int i=n;i>0;i-=2){
                    printf("%d ",a[i]);
                }
                for(int i=2;i<n-1;i+=2){
                    printf("%d ",a[i]);
                }
                printf("%d\n",a[n-1]);
            }
        }
    }
	return 0;
}


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


int main()
{
    int n;
    cin >> n;
    vector<int> b;
    rep(i, n - 1){ int tmp; cin >> tmp; b.push_back(tmp);}

    int ans = b[0];
    for (int i = 0; i < b.size() - 1; i++)
    {
       ans += min(b[i], b[i+1]); 
    }
    ans += b[b.size() - 1];

    cout << ans << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
//---------------------------------------
void tokuten(string t, string h, int &num_t, int &num_h);
//---------------------------------------

int main(void)
{
	int n;  //??????????????°
	int tokuten_taro = 0;
	int tokuten_hanako = 0;
	
	//???????????°?????\???
	cin >> n;
	
	//??????????????±
	for(int i = 0; i < n; i++){
		string card_taro, card_hanako;
		cin >> card_taro;  //1????????§????????????
		cin >> card_hanako; //1????????§????????????
		
		//???????????????
		tokuten(card_taro, card_hanako, tokuten_taro, tokuten_hanako);
	}
	
	//??¨???
	cout << tokuten_taro << ' ' << tokuten_hanako << endl;
	
	return 0;

}

//------------------------------------------------------------
void tokuten(string t, string h, int &num_t, int &num_h){

	int size_m, size_M;
	
	if(t.size() >=  h.size()){
		size_m = h.size();
	}
	else if(t.size() <= h.size()){
		size_m = t.size();
	}
	
	
	for(int i = 0; i < size_m; i++){
	
		if(t[i] > h[i]){
			num_t += 3;
			return;
		}
		else if(h[i] > t[i]){
			num_h += 3;
			return;
		}
	}
	//????????????????????§???????????£?????´???
	if(t.size() > h.size()){
		num_t += 3;
	}
	else if(h.size() > t.size()){
		num_h += 3;
	}
	else{
		num_t += 1;
		num_h += 1;
	}
	
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int dp[50][(1<<20)];

signed main(){
  int N,X,Y,Z;cin>>N>>X>>Y>>Z;

  int MAX=1LL<<(X+Y+Z-1);
  int ng=(1LL<<(X+Y+Z-1))|(1LL<<(Y+Z-1))|(1LL<<(Z-1));

  dp[0][0]=1;

  for(int i=0;i<N;i++){
    for(int j=1;j<=10;j++){
      for(int k=0;k<MAX;k++){
        int temp=(k<<j)|(1<<(j-1));

        if((temp&ng)!=ng){
          temp&=(MAX-1);

          dp[i+1][temp]+=dp[i][k];
          dp[i+1][temp]%=MOD;
        }
      }
    }
  }

  int ans=1;
  for(int i=0;i<N;i++){
    ans*=10;
    ans%=MOD;
  }

  for(int i=0;i<MAX;i++){
    ans=ans-dp[N][i]+MOD;
    ans%=MOD;
  }

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


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

using namespace std;

long long A[200005];
int n;

long long sum(long long mid) {
    long long ans = 0;
    for(int i=1;i<=n;i++) {
        ans += abs(A[i]-mid);
    }
    return ans;
}

int main() {
    scanf("%d",&n);
    long long l=1,r=0;
    for(int i=1;i<=n;i++) {
        scanf("%lld",&A[i]);
        A[i]=A[i]-i;
    }
    l=-1e9,r=1e9;
    while(l<r-1) {
        long long lmid = (l+r)>>1;
        long long rmid = (lmid+r)>>1;

        if(sum(lmid) > sum(rmid)) {
            l = lmid;
        }
        else {
            r = rmid;
        }
    }
//    cout<<l<<"   "<<r<<endl;
//    cout<<sum(l)<<"   "<<sum(r)<<endl;

    printf("%lld\n",min(sum(l),sum(r)));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
/***********************************************************************/

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int n, d;
  cin >> n >> d;
  d = 2 * d + 1;
  kek((n + d - 1) / d);
    
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll MOD=1000000007;
const ll E=1e18;

const ll MX=100000;

ll a[MX];

int main(){
  ll n,s,w,p;
  while(cin>>n>>s>>w>>p){
    if(n==0){break;}
  int g=s;
  for(int i=0;i<n;i++){
    a[i]=(g/7)%10;
    if(g%2==0){g/=2;}
    else{g=(g/2)^w;}
    //cout<<a[i]<<" ";
  }
  reverse(a,a+n);
  //for(int i=0;i<n;i++){cout<<a[i]<<" ";}
  //cout<<endl;
  if(p==2 || p==5){
    ll ans=0;
    ll w=0;
    for(int i=0;i<n;i++){
      if(a[i]%p==0){w++;}
      if(a[i]!=0){ans+=w;}
    }
    cout<<ans<<endl;
  }
  else{
    map<ll,ll> M;
    ll ans=0;
    ll sum=0;
    M[0]++;
    ll k=1;
    for(int i=0;i<n;i++){
      sum+=k*a[i];
      sum%=p;
      if(a[i]!=0){ans+=M[sum];}
      M[sum]++;
      (k*=10)%=p;
      //cout<<i<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
  }
  }

  return 0;
}



Measured memory_bytes: 9448
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
  double a, b, x; cin >> a >> b >> x; x/=a;
  double y, rad, deg;
  if(x >= a*b/2.0) {
    y = 2.*x/a-b;
    rad = atan((b-y)/a);
  } else {
    y = (2.*x) / b;
    rad = atan(b/y);
  }
  deg = rad * 180. / M_PI;
  cout << setprecision(12);
  cout << deg << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector<string> str(n);
		for (int i = 0; i < n; i++) {
			cin >> str[i];
			if (i == 0) {
				continue;
			}
			for (int j = 0; j < str[i].size(); j++) {
				if (str[i][j]  != '.') {
					str[i][j-1] = '+';
					break;
				} else {
					str[i][j] = ' ';
				}
			}
		}
		int a = -1;
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < str[i].size(); j++) {
				if (str[i][j] == '+') {
					if (j < a) {
						for (int k = i-1; k >= 0; k--) {
							if (str[k][j] == '+') {
								for (int p = k+1; p < i; p++) {
									str[p][j] = '|';
								}
								break;
							}
						}
					}
					a = j;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			cout << str[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15)<<
#define ld long double

signed main(){
    ld a,b,x; cin >> a >> b >> x;
    const ld PI = 3.141592653589793238;
   cout<<fixed<<setprecision(10);
   if(x<=a*a*b/2){
       cout<<atanl(a*b*b/2.0/x)*180.0/PI<<endl;
   }else{
       cout<<atanl(2.0*(a*a*b-x)/(a*a*a))*180.0/PI<<endl;
   }

}

Measured memory_bytes: 256
n=int(input())
lis=[]
for _  in range(n):
    x,l=map(int,input().split())
    lis.append([x-l,x+l])

lis.sort(key=lambda x:x[1])
count = 0
tmp = - 10 ** 18
for i in lis:
    if tmp <= i[0]:
        count += 1
        tmp = i[1]

print(count)





Measured memory_bytes: 21336
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n, m, k;
    cin >> n >> m >> k;

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i * j + (n - i) * (m - j) == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
n=int(input())

a=[int(i) for i in input().split()]
a.sort()

succession=0
pre=-10000
maxnum=0
check=[0,0,0]

for i in a:
#     print(i)
    if pre<i-2:
        succession=0
        pre=i
        maxnum=max(maxnum,sum(check))
        check=[1,0,0]
    elif pre==i:
        check[succession]+=1
    elif pre==i-1 and succession==0:
        succession+=1
        check[1]+=1
        pre=i
    elif pre==i-1 and succession==1:
        succession+=1
        check[2]+=1
        pre=i
    elif pre==i-1 and succession==2:
        maxnum=max(maxnum,sum(check))
        check=[check[1],check[2],1]
        pre=i
    elif pre==i-2:
        maxnum=max(maxnum,sum(check))
        check=[check[succession],0,1]
        succession=2
        pre=i
#     print(check)
maxnum=max(maxnum,sum(check))

print(maxnum)

Measured memory_bytes: 13964
{-# OPTIONS_GHC -O #-}

import Data.List
import Control.Monad

main=do
    [a,b,k]<-map read.words<$>getLine::IO[Int]
    forM_ [a..(min b (a+k-1))] print
    forM [(max (a+k) (b-k+1))..b] print

Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

using Item = tuple<ll,ll,ll>;
template<class Type>
Type solve(Type res = Type()){
    ll N,C; cin >> N >> C;
    vector<Item> Ts(N);
    for(int i = 0; i < N;i++){
        ll s,t,c; cin >> s >> t >> c;
        Ts[i] = Item(s,t,c);
    }
    sort(Ts.begin(),Ts.end());
    
    vector<int> checked(N);
    
    ll pret = -1,prec = -1;
    for(res = 1; res <= C;res++){
        pret = -1;prec = -1;
        auto ok = [&]{
            for(int i = 0; i < N;i++){
                if(checked[i]) continue;
                if(pret < get<0>(Ts[i])){
                    checked[i] = 1;
                    pret = get<1>(Ts[i]);
                    prec = get<2>(Ts[i]);
                }else if(pret == get<0>(Ts[i]) && prec == get<2>(Ts[i])){
                    checked[i] = 1;
                    pret = get<1>(Ts[i]);
                    prec = get<2>(Ts[i]);
                }
            }
            
            if(count(checked.begin(),checked.end(),0) == 0) return true;
            else return false;
        }();
        
        if(ok) break;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
struct node {
    int x,ind;
};
struct tpl {
    int cur,val,val2;
    bool operator < (const tpl &e1) const {
        return (val>e1.val);
    }
};
int n,a[200005],cnt;
node seg[2][530000];
vector<int> nex[1800005];
pair<int,int> ans[1800005];
void push_up(node a,node b,node &ret) {
    if (a.x<b.x) ret=a;
    else ret=b;
}
void fill(int l,int r,int cur,int t) {
    if (l==r) {
        if (l%2==t) seg[t][cur]={a[l],l};
        else seg[t][cur]={0x3f3f3f3f,0x3f3f3f3f};
        return;
    }
    fill(l,(l+r)/2,2*cur+1,t);
    fill((l+r)/2+1,r,2*cur+2,t);
    push_up(seg[t][2*cur+1],seg[t][2*cur+2],seg[t][cur]);
}
node que(int l,int r,int tl,int tr,int cur,int t) {
    if (r<tl or tr<l) return {0x3f3f3f3f,0x3f3f3f3f};
    if (tl<=l and r<=tr) return seg[t][cur];
    node a=que(l,(l+r)/2,tl,tr,2*cur+1,t);
    node b=que((l+r)/2+1,r,tl,tr,2*cur+2,t),ret;
    push_up(a,b,ret);
    return ret;
}
void func(int l,int r,int cur) {
    if (l>r) {ans[cur]={0x3f3f3f3f,0x3f3f3f3f}; return;}
    int ind=-1;
    if (l%2==0) ind=que(0,n-1,l,r,0,0).ind;
    else ind=que(0,n-1,l,r,0,1).ind;
    int ind2=que(0,n-1,ind+1,r,0,(l%2==0)).ind;
    ans[cur]={a[ind],a[ind2]};
    nex[cur].push_back(++cnt);
    func(l,ind-1,cnt);
    nex[cur].push_back(++cnt);
    func(ind+1,ind2-1,cnt);
    nex[cur].push_back(++cnt);
    func(ind2+1,r,cnt);
}
int main() {
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    fill(0,n-1,0,0);
    fill(0,n-1,0,1);
    func(0,n-1,0);
    priority_queue<tpl> q; q.push({0,ans[0].first,ans[0].second});
    while (!q.empty()) {
        int cur=q.top().cur,val=q.top().val,val2=q.top().val2;
        q.pop();
        cout<<val<<' '<<val2<<' ';
        for (int i=0; i<=2; i++) {
            int ne=nex[cur][i];
            if (ans[ne].first==0x3f3f3f3f) continue;
            q.push({ne,ans[ne].first,ans[ne].second});
        }
    }
    cout<<'\n';
}

Measured memory_bytes: 67980
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;


int main() {
int A,B,C,X,Y;
cin >> A >> B >> C >> X >> Y;
int64_t ans1,ans2,ans3;
ans1 = A*X + B*Y;
ans2 = C * max(X,Y) *2;
if (X > Y) {
    ans3 = Y*2 * C;
    ans3 += A * (X-Y);
} else {
    ans3 = X*2 * C;
    ans3 += B * (Y-X);
}
cout << min(ans1,min(ans2,ans3)) << endl;

return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(0);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;

const int MOD = inf + 7;

signed main(){
	fast;

	int n,m;
	cin >> n >> m;

	int a[m][2];
	f(i,0,m)	cin >> a[i][0] >> a[i][1];

	for(int i=0 ; i<=10001 ; i++)
	{
		string s = to_string(i);
		if(s.length() != n)	continue;
		int ok = 1;
		for(int j=0 ; j<m; j++)
		{
			if(s[a[j][0]-1] - '0' != a[j][1])
				ok = 0;
		}
		if(ok)
		{
			cout << i;
			return 0;
		}
	}
	cout << "-1";
}

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

using namespace std;

int n, h, ans;
int a, b[100005];

int main()
{
    scanf("%d%d", &n, &h);
    for(int i = 0; i < n; i++)
    {
        int t;
        scanf("%d%d", &t, &b[i]);
        a = max(a, t);
    }
    sort(b, b + n, greater<int>());
    for(int i = 0; i < n; i++)
    {
        if(b[i] <= a)
        {
            break;
        }
        if(h <= 0)
        {
            break;
        }
        h -= b[i];
        ans++;
    }
    h = max(h, 0);
    ans += (h + a - 1) / a;
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 640
let () =
  let slst = Scanf.scanf "%1s%1s%1s%1s\n" (fun a b c d -> [a; b; c; d]) in
  let countP = List.length (List.filter (fun x -> x = "+") slst) in
  let countM = List.length (List.filter (fun x -> x = "-") slst) in
  Printf.printf "%d\n" (0 + countP - countM)

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

def solve():
    N = int(input())
    S = input()
    K = int(input())

    t = S[K-1]
    ans = ""

    for moji in S:
        if moji == t:
            ans += moji
        else:
            ans += "*"
    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,s,k;
    cin>>N;
    s=N%1000;
    if(s!=0)
    {
       k=1000-s;
       cout<<k<<endl;
    }
    else
        cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

int main()
{
    ciosup;
    int n;
    cin >> n;
    int k = -1;
    FOR(i, 1, 2*n+1)
    {
        if (n == i*(i-1)/2){
            k = i;
        }
    }
    if (k == -1)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << k << endl;
    queue<int> al;
    REP(i,n){
        al.push(i+1);
    }
    vector<queue<int>> ans(k);
    REP(i,k){
        cout << k - 1 << " ";
        REP(j, i)
        {
            int val = ans[j].front();
            ans[j].pop();
            if (j != k - 2) cout << val << " ";
            else cout << val << endl;
        }
        REP(j,k-1-i){
            int val = al.front();
            al.pop();
            ans[i].push(val);
            if (j != k - 2 - i) cout << val << " ";
            else cout << val << endl;
        }
    }
}

Measured memory_bytes: 2176