akhauriyash/Code-Regression huggingface dataset:
import collections
n = int(input())
S = []
A = {}
for i in range(n):
    s = input()
    if i == 0:
        for j in s:
            if j in A: A[j] += 1
            else: A[j] = 1
    else:
        B = {}
        for j in s:
            if j in B: B[j] += 1
            else: B[j] = 1
        for j in A:
            if j in B:
                A[j] = min(A[j], B[j])
            else:
                A[j] = 0
ans = ""
for i in A:
    if A[i] > 0:
        ans += i*A[i]
ans = list(ans)
ans.sort()
print("".join(ans))

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <map>
#define ll long long
using namespace std;

#define MOD 1000000007

class Solve
{
private:
	int n, c, k;
	vector<int> t;
	int ans; 
public:
	Solve(){
		ans = 0;
		cin >> n >> c >> k;
		t.resize(n);
		for (int i = 0; i < n; ++i)
		{
			cin >> t[i];
		}
		sort(t.begin(), t.end());
	}

	void exec(){
		int itr = 0;
		while(itr < n){
			int new_itr = upper_bound(t.begin(), t.end(), t[itr] + k) - t.begin() - 1;
			// cout << *upper_bound(t.begin(), t.end(), t[itr] + k) << " ";
			int dif = new_itr - itr + 1;
			if(dif > c){
				// ans += dif/c;
				// dif = dif % c;
				ans++;
				itr = itr + c;
				continue;
			}
			if(dif != 0) ans++;
			itr = new_itr+1;
			// cout << itr << " test"<< endl;
		}
		cout << ans << endl;
	}
};

int main(){
	Solve solver = Solve();
	solver.exec();
}


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


int main(){
	LL A, B, C, K;
	cin >> A >> B >> C >> K;
	if(abs(A-B) > 1000000000000000000){
		cout << "Unfair" << endl;
		return 0;
	}
	LL ans;
	if(K%2==1) ans = (A-B) * (-1);
	else ans = A - B;
	cout << ans << endl;

}













Measured memory_bytes: 3612
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct howto {
	int wit;
	vector<int>needs;
	howto(const int g) :wit(g), needs() {}
};
struct aa {
	int wit;
	int need;
};
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.need> r.need;
	}
};
int main() {
	int N, E, T; cin >> N >> E >> T; T--;
	vector<int>costs(N);
	for (int i = 0; i < N; ++i) {
		int w; cin >> w;
		if (w)costs[i] = 1;
		else costs[i] = 1e8;
	}
	vector<howto>hows;
	vector<bool>howuses(E);
	for (int i = 0; i < E; ++i) {
		int g, c; cin >> g >> c;
		g--;
		hows.push_back(howto(g));
		for (int j = 0; j < c; ++j) {
			int s; cin >> s; s--;
			hows[i].needs.push_back(s);
		}
	}
	priority_queue<aa, vector<aa>, Compare>que;
	for (int h = 0; h<hows.size(); ++h) {
		vector<int>neednums;
		for (auto n : hows[h].needs) {
			neednums.push_back(costs[n]);
		}
		sort(neednums.begin(), neednums.end());
		int amax = 0;
		for (int i = 0; i < neednums.size(); ++i) {
			amax = max(int(neednums[i]+neednums.size() - i - 1), amax);
		}
		if (amax < costs[hows[h].wit])que.push(aa{ hows[h].wit,amax });
	}
	int ans = 1e8;
	while (!que.empty()) {
		aa atop(que.top());
		que.pop();
		if (atop.need < costs[atop.wit]) {
			costs[atop.wit] = atop.need;
			for (int h = 0; h<hows.size(); ++h) {
				vector<int>neednums;
				for (auto n : hows[h].needs) {
					neednums.push_back(costs[n]);
				}
				sort(neednums.begin(), neednums.end());
				int amax = 0;
				for (int i = 0; i < neednums.size(); ++i) {
					amax = max(int(neednums[i] + neednums.size() - i - 1), amax);
				}
				if (amax < costs[hows[h].wit])que.push(aa{ hows[h].wit,amax });
			}
		}
	}
	if (costs[T]>1e6)costs[T] = -1;
	cout << costs[T] << endl;
	return 0;
}

Measured memory_bytes: 3264
#include <cstdio>

unsigned int sw[10];
unsigned int p[10];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i)
  {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; ++j)
    {
      int a;
      scanf("%d", &a);
      sw[i] |= 1 << (a - 1);
    }
  }
  for (int i = 0; i < m; ++i)
  {
    scanf("%d", p + i);
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i)
  {
    int f = 0;
    for (int j = 0; j < m; ++j)
    {
      if ((__builtin_popcount(i & sw[j]) & 1) == p[j]) ++f;
    }
    if (f == m) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
    int n;
    int a, b;
    scanf("%d", &n);
    scanf("%d", &a);
    scanf("%d", &b);

    int num;

    for(int i=1;i<=n;i++){
        int num_kari=0;
        int j = i;
        while(j>0){
            num_kari += j%10;
            j = (j-j%10)/10;
        }
        if(a<=num_kari && num_kari<=b){
            num += i;
        }

    }

    printf("%d\n", num);
    return 0;



    




}



Measured memory_bytes: 128
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>	// wrap,pair
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
int GCD(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
int LCM(int x, int y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}

// 素数判定(素数ならtrue,合成数ならfalse)
bool IsPrime(int num) {
	if (num < 2) return false; // 0,1
	else if (num == 2) return true;	// 2
	else if (num % 2 == 0) return false; // 偶数

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false; // 割り切れたら素数ではない
	}
	return true; // 全部通ったら素数
}

// pairをsecond基準で昇順sort
// sort(vector_name.begin(),vector_name.end(),compare_by_b);
bool compare_by_b(pair<int, int>a, pair<int, int>b) {
	if (a.second != b.second) return a.second < b.second;
	else return a.first < b.first;
}

// ----------------------------------------------------------------

int main(void) {

	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> c(n);
	REP(i, n) cin >> c[i].first >> c[i].second;

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

	int cnt = m, i = 0;
	ll ans = 0;
	while (cnt > 0) {
		ans += (ll)min(cnt, c[i].second) * (ll)c[i].first;
		cnt -= c[i].second;
		i++;
	}
	cout << (ll)ans << endl;

	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        //var mod = 998244353;
        var num = Input.num;
        var str = ReadLine();
        var bl = str.Count(c => c == '#');
        var wh = str.Count(c => c == '.');

        /*var index = 0;
        while (index!=num-1&&str[index] == '.')
        {
            index++;
        }
        var ind = num - 1;
        while (ind != 0 && str[ind] == '#')
        {
            ind--;
        }*/
        var cb = 0;
        var cw = 0;
        var res = wh;
        for(var i = 0; i < num; i++)
        {
            if (str[i] == '#') cb++;
            else cw++;
            res = Min(res, wh - cw + cb);
        }
        WriteLine(res);
        /*for(var i = index; i <= ind; i++)
        {
            if (str[i] == '#') cb++;
            else cw++;
        }
        WriteLine(Min(cb, cw));*/
        /*var b = new List<int>();b.Add(0);
        for (var j = index; j < num; j++)
            if (b.Count % 2 == 1 && str[j] == '#')
                b[b.Count - 1]++;
            else if (b.Count % 2 == 0 && str[j] == '.')
                b[b.Count - 1]++;
            else b.Add(0);

        var res = 0;
        for(var i = 0; i < num-1; i++)
        {
            if (str[i] == '#' && str[i + 1] == '.' )
            {
                res++;
                while (i != num - 2 && str[i + 2] == '.')
                {
                    res++;
                    i++;
                }
            }
        }
        WriteLine(res);*/
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13368
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    sc=[]
    for i in range(M):
        sc.append([s[i],c[i]])
    sc=list(map(list,set(map(tuple,sc))))
    sc.sort()
    for i in range(len(sc)):
        if sc[i][0]==1 and sc[i][1]==0 and not N==1:
            print(-1)
            exit()
    if M==0 and N==1:
        print(0)
        exit()
    if M==0 or len(sc)==1 and c[0]==0 and not s[0]==1:
        q=[1]
        for i in range(N-1):
            q.append(0)
        print("".join(map(str,q)))
        exit()
    for i in range(len(sc)-1):
        if sc[i][0]==sc[i+1][0]:
            print(-1)
            exit()
    #if N>max(set(s)):
    #    print(-1)
    #    exit()
    a=[0]*N
    for i in range(len(s)):
        a[s[i]-1]=c[i]
    if a[0]==0 and not N==1:
        a[0]=1
    print("".join(map(str,a)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <stdio.h>
int main(void){
	int count;
	count = 1;
	while(1){
		int a;
		scanf("%d\n",&a);
		if(a!=0){
			printf("Case %d: %d\n",count,a);
			count = count+1;
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    int n = 0;
    cin >> a >> b >> c;
    for (int i = a; i < b+1; ++i) {
        if (c % i == 0) {
            n += 1;
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3092
package main

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

type Edge struct {
	source, target, cost int
}

const Inf = 1 << 60 / 10

func main() {
	N, M := ReadInt(), ReadInt()
	edges := make([]Edge, M)
	for i := 0; i < M; i++ {
		edges[i].source = ReadInt() - 1
		edges[i].target = ReadInt() - 1
		edges[i].cost = -ReadInt()
	}
	d := make([]int, N)
	for i := 0; i < N; i++ {
		d[i] = Inf
	}
	d[0] = 0
	for i := 0; i < N-1; i++ {
		for _, e := range edges {
			if d[e.source] == Inf {
				continue
			}
			newD := d[e.source] + e.cost
			if newD < d[e.target] {
				d[e.target] = newD
			}
		}
	}

	negative := make([]bool, N)
	for i := 0; i < N; i++ {
		for _, e := range edges {
			if d[e.source] == Inf {
				continue
			}
			newD := d[e.source] + e.cost
			if newD < d[e.target] {
				d[e.target] = newD
				negative[e.target] = true
			}
			if negative[e.source] {
				negative[e.target] = true
			}
		}
	}

	if negative[N-1] {
		fmt.Println("inf")
	} else {
		fmt.Println(-d[N-1])
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 2024
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define deb(...) cout << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define SINT int32_t
#define UMO unordered_map
#define USO unordered_set
#define UB(v, n) upper_bound(ALL(v), n)
#define LB(v, n) lower_bound(ALL(v), n)
#define to_bin(b, n) bitset<b>(n) // Provide binary representation of a Number
#define setBits(n) popcount(n) // count Set Bits in a Number
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + ((n >> 4) & 0xF0F0F0F)) * 0x1010101) >> 24;
}

void Panda() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    else if((a - b) >= c) cout << 0 << endl;
    else cout << c - (a - b) << endl;
}
  
int32_t main() 
{ 
    FAST;

    
    Panda();

    return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#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)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
    lint n, k;
    cin >> n >> k;
    if(k >= n-1) k = n-1;
    vector<lint> frac(500000);
    frac[0] = 1;
    FOR(i, 1, 500000) frac[i] = i * frac[i-1] % MOD;
    lint ans = 1;
    REP(i, k) {
        ans = (ans + frac[n-1] * power(frac[n-2-i], MOD-2, MOD) % MOD * power(frac[i+1], MOD-2, MOD) % MOD * frac[n] % MOD * power(frac[n-1-i], MOD-2, MOD) % MOD * power(frac[i+1], MOD-2, MOD) % MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <functional>
#include <limits>

template <class Data, class Operator>
class CoSegmentTree {
    using OperatorMerger = std::function<Operator(Operator, Operator)>;
    using Applier = std::function<Data(Data, Operator)>;

public:
    int length;
    std::vector<Operator> ope;
    Data dat_id;
    Operator ope_id;
    OperatorMerger opem;
    Applier app;

    explicit CoSegmentTree(int N, Data dat_id, Operator ope_id, OperatorMerger opem, Applier app)
        : length(1), dat_id(dat_id), ope_id(ope_id), opem(opem), app(app) {
        while (length < N) length *= 2;
        ope.assign(length * 2, ope_id);
    }

    // half-open interval [ql, qr)
    void update(int ql, int qr, Operator e) { return update(ql, qr, e, 1, 0, length); }

    void update(int ql, int qr, Operator e, int nidx, int nl, int nr) {
        if (nr <= ql || qr <= nl) return;
        if (ql <= nl && nr <= qr) {
            ope[nidx] = opem(ope[nidx], e);
            return;
        }
        // 子に作用素を伝播
        ope[nidx * 2] = opem(ope[nidx * 2], ope[nidx]);
        ope[nidx * 2 + 1] = opem(ope[nidx * 2 + 1], ope[nidx]);
        ope[nidx] = ope_id;
        // 子を再帰的に更新
        update(ql, qr, e, nidx * 2, nl, (nl + nr) / 2);
        update(ql, qr, e, nidx * 2 + 1, (nl + nr) / 2, nr);
    }

    Data query(int idx) {
        int nidx = idx + length;
        Data ret = app(dat_id, ope[nidx]);
        while (nidx > 0) {
            nidx /= 2;
            ret = app(ret, ope[nidx]);
        }
        return ret;
    }
};

const int INF = std::numeric_limits<int>::max();

int main() {
    int N, Q;
    std::cin >> N >> Q;

    CoSegmentTree<int, int> seg(N, INF, INF,
                                [](int a, int b) { return (b == INF ? a : b); },
                                [](int a, int e) { return (e == INF ? a : e); });

    for (int q = 0; q < Q; ++q) {
        int k;
        std::cin >> k;
        if (k == 0) {
            int l, r, x;
            std::cin >> l >> r >> x;
            seg.update(l, r + 1, x);
        } else {
            int i;
            std::cin >> i;
            std::cout << seg.query(i) << std::endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		long M=sc.nextLong();
		long price=0;
		long[][] kan=new long[N][2];
		for(int i=0; i<N; i++) {
			kan[i][0]=sc.nextLong();
			kan[i][1]=sc.nextLong();
		}
		quick_sort(kan,0,N-1);
		long sum=0;
		for(int i=0; i<N; i++) {
			if(sum+kan[i][1]<=M) {
				price+=kan[i][0]*kan[i][1];
				sum+=kan[i][1];
			}
			else if(sum+kan[i][1]>M) {
				price+=kan[i][0]*(M-sum);
				break;
			}
		}
		pl(price);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static void quick_sort(long[][] d, int left, int right) {
		if (left>=right) {
			return;
		}
		long p = d[(left+right)/2][0];
		int l = left, r = right;
		long tmp,tmp1,tmp2;
		while(l<=r) {
			while(d[l][0] < p) { l++; }
			while(d[r][0] > p) { r--; }
			if (l<=r) {
				tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
				tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
				l++; r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
}

Measured memory_bytes: 44780
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define dd(a) cout<<#a<<" = "<<a<<' '
#define de(a) cout<<#a<<" = "<<a<<endl
typedef long long ll;
typedef pair<int, int> pii;
//---
const int N=6333;
int a, b, c, d, e, f, ans1, ans2;
bool dp[N][N];
int main(){
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
	dp[0][0]=1;
	ans1=ans2=-1;
	rep(i, 0, f+1){
		rep(j, 0, i+1){
			if(dp[i][j]){
				int w=i-j, s=j;
				if(i!=0&&j!=0&&1ll*s*100<=1ll*w*e){
	//				if(i==200&&j==100)de((1ll*100*s*(ans1+ans2)>1ll*ans2*100*i));
					if(ans1==-1||1ll*100*s*(ans1+ans2)>1ll*ans2*100*i)
						ans1=w, ans2=s;
				}
				dp[i+a*100][j]=1;
				dp[i+b*100][j]=1;
				dp[i+c][j+c]=1;
				dp[i+d][j+d]=1;
			}
		}
	}
	if(ans1==-1)ans1=100*a, ans2=0;
	printf("%d %d\n", ans1+ans2, ans2);
	return 0;
}


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

const int Nmax=200010;
 
int main() {
	int N;
	cin >> N;
	int a[Nmax]={};
	for (int i = 0; i < N; i++) cin >> a[i];
 
	map<int, int> mp;
	for (int i = 0; i < N; i++) mp[a[i]]++;
 
	int ans = 0;
	for (auto p: mp) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}
 
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5504
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int cases=sc.nextInt();
		int[][] zahyo=new int[cases][3];

		for(int i=0; i<cases; i++) {
			zahyo[i][0]=sc.nextInt();		//x
			zahyo[i][1]=sc.nextInt();		//y
			zahyo[i][2]=sc.nextInt();		//h
		}

		int sum_height=0;
		boolean onaji=true;
		for(int i=0; i<=100; i++) {
			for(int j=0; j<=100; j++) {
				sum_height=-1;
				for(int k=0; k<cases; k++) {
					if(zahyo[k][2]>0) {
						int tmp=zahyo[k][2]+Math.abs(j-zahyo[k][1])+Math.abs(i-zahyo[k][0]);
						if(sum_height==-1) {
							sum_height=tmp;
						}
						else {
							if(sum_height!=tmp) {
								sum_height=-2;
								break;
							}
						}
					}
				}

				if(sum_height==-2) {
					continue;
				}
				for(int k=0; k<cases; k++) {
					if(zahyo[k][2]==0) {
						int dist=Math.abs(j-zahyo[k][1])+Math.abs(i-zahyo[k][0]);
						if(sum_height>dist) {
							sum_height=-2;
							break;
						}
					}
				}
				if(sum_height==-2) {
					continue;
				}
				else {
					System.out.println(i+" "+j+" "+sum_height);
					System.exit(0);
				}
			}
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string dig(string n){
	ll ans=0;
	for(int i=0;i<n.size();i++){
		ans+=(n[i]-'0');
		ans%=9;
	}
	if(ans==0){
		return "Yes";
	}
	else{
		return "No";
	}
}
int main() {
	string n;
	cin>>n;
	cout<<dig(n);
	return 0;
	
}

Measured memory_bytes: 3920
#include<stdio.h>
int main(){
  int n,i;
  char s[100010]={};
  scanf("%d %s",&n,s);
  if(s[n]){
    for(i=0;i<n;i++)printf("%c",s[i]);
    printf("...\n");
  }
  else printf("%s\n",s);
  return 0;
}


Measured memory_bytes: 1744
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int n;
    cin>>n;
    string s[n];
    rep(i,n)cin>>s[i];

    int alp[n][26] = {0};
    rep(i,n){
        rep(j,s[i].size()){
            rep(k,26){
                if(s[i][j] == 'a'+k){
                    ++alp[i][k];
                }
            }
        }
    }

    int ans_alp[26];
    rep(i,26) ans_alp[i] = 100;
    rep(i,26){
        rep(j,n){
            ans_alp[i] = min(ans_alp[i],alp[j][i]);
        }
    }

    rep(i,26){
        rep(j,ans_alp[i]){
            printf("%c",'a'+i);
        }
    }
    /*rep(i,26){
        printf("%d ",ans_alp[i]);
    }printf("\n");
    rep(i,n){
        rep(j,26){
            printf("%d ",alp[i][j]);
        }
        printf("\n");
    }*/
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int n, i, tmp;
	vector<int> a;
	int prev_size, erase_size;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	prev_size = a.size();
	cout << endl;
	auto itr = unique(a.begin(), a.end());
	a.erase(itr, a.end());
	cout << endl;
						 
	erase_size = a.size();

	if (prev_size == erase_size)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<vector>
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
  int n;
  string in;
  cin >> n;
  getline(cin, in);
  getline(cin, in);
  string answer;
  for(int i = 0; i < in.size(); ++i) {
    char c = 'A' + ((in[i] - 'A' + n) % 26);
    answer.push_back(c);
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
day = input()

if day == 'SUN':
    print('7')
elif day == 'MON':
    print('6')
elif day == 'TUE':
    print('5')
elif day == 'WED':
    print('4')
elif day == 'THU':
    print('3')
elif day == 'FRI':
    print('2')
else:
    print('1')

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

template<typename T> struct BinaryIndexedTree {
  vector<T> data;
  BinaryIndexedTree(int sz) { data.assign(++sz, 0); }
  T sum(int k) {
    T ret = 0;
    for (++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(int k, T x) { for (++k; k < data.size(); k += k & -k) data[k] += x; }
};

template<typename T> ll InversionNumber(vector<T> &v) {
  ll sz = v.size(), ret = 0;
  vector<T> rev, v_cp = v; sort(v_cp.begin(), v_cp.end());
  for (auto e : v) rev.emplace_back(lower_bound(v_cp.begin(), v_cp.end(), e) - v_cp.begin());
  BinaryIndexedTree<T> bit(sz);
  for (int i = 0; i < sz; ++i) {
    ret += i - bit.sum(rev[i]);
    bit.add(rev[i], 1);
  }
  return ret;
}

int N;
ll M;
vector<int> A;

bool check(int k) {
  vector<int> B(N), B_sum(N + 1, 0);
  for (int i = 0; i < N; ++i) B[i] = (A[i] >= k) ? 1 : -1;
  for (int i = 0; i < N; ++i) B_sum[i + 1] = B_sum[i] + B[i];
  return (M - InversionNumber(B_sum) >= (M + 1) / 2);
}

signed main() {

  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  if (N == 1) {
    cout << A[0] << endl;
    return 0;
  }

  M = N * (N + 1) / 2;

  ll ok = 0, ng = 1e9 + 1;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;

}


Measured memory_bytes: 5224
let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let f () = List.map int_of_string (split (read_line ()) ' ')

let dfs g n =
  let v = Array.make n (-1) in
  let rec dudu j = function
    | [] -> ()
    | hd :: tl when v.(hd) = (-1) -> (wa hd j; dudu j tl)
    | _ :: tl -> dudu j tl
  and wa i j = v.(i) <- j; dudu j g.(i)
  and doit i =
    if i < n then (if v.(i) = (-1) then wa i i; doit (i + 1))
  in
  doit 0;
  v

let () =
  match f () with
  | [n;m] -> begin
      let g = Array.make n [] in
      let rec read i =
        if i < m then
          match f () with
          | [s;t] -> begin
              g.(s) <- t :: g.(s);
              g.(t) <- s :: g.(t);
              read (i + 1)
            end
          | _ -> exit 1
      in
      read 0;
      let v = dfs g n in
      let q = read_int () in
      let rec read_q i =
        if i < q then begin
          match f () with
          | [s;t] -> begin
              print_endline (if v.(s) = v.(t) then "yes" else "no");
              read_q (i + 1)
            end
          | _ -> exit 1
        end
      in
      read_q 0
    end
  | _ -> exit 1

Measured memory_bytes: 14004
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}

ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))
;

ll arr[403];
ll dp[405][405];
int main() 
{
   // #ifndef ONLINE_JUDGE
   //  freopen("input.txt","r",stdin);
   //  freopen("output.txt","w",stdout);
   // #endif 
        ll n;
    in(n)
    for(ll i=1;i<=n;i++){
        in(arr[i])
    }
    arr[0]=0;
    for(ll i=1;i<=n;i++){
        arr[i]+=arr[i-1];
    }
 
    for(ll i=0;i<=400;i++){
        for(ll j=0;j<=400;j++){
            dp[i][j]=1e18;
        }
    }
    for(ll i=1;i<=n;i++){
        dp[i][i]=0;
    }
    for(ll len=2;len<=n;len++){
        for(ll i=1;i<=n;i++){
            ll end=i+len-1;
            if(end>n)break;
            for(ll k=i;k<end;k++){
                dp[i][end]=min(dp[i][k]+dp[k+1][end]+arr[end]-arr[i-1],dp[i][end]);
            }
        }
    }
    // for(ll i=0;i<=n;i++){
    //  for(ll j=0;j<=n;j++){
    //      cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    //  }
    // }
    cout<<dp[1][n]<<endl;
    

   
}



/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/






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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,r,x,y,m,n;
        string s,t;
        cin>>s>>t;
        ll ns,nt;
        ns=s.size();
        nt=t.size();
        ll ans=hell;
        for(i=0;i<ns+1-nt;i++)
        {
            ll ansi=0;
            for(j=0;j<nt;j++)
            {
                if(s[i+j]!=t[j])ansi++;
            }
            ans=min(ans,ansi);
        }
        cout<<ans;
    }
    return 0;
}

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

using namespace std;

const int MOD=1e9+7;
//const int MOD=998244353;

const double PI=3.14159265359;




int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    vector<int> v(n);
    
    int ans=0;
    for(int&i:v)cin>>i, ans+=i;
    //sort(v.begin(),v.end());
    int x=*max_element(v.begin(),v.end());
    ans-=x/2;
    cout<<ans;
    
    
    
    return 0;
}

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

using namespace std;

int main(){

    string ring, tmp_str, word;
    char tmp_ch;

    unsigned int i, j;

    cin >> ring;
    cin >> word;

    for(i=0;i<ring.length();i++){

        int counter = 0;

        if(ring[i] == word[0]){
            tmp_str = ring;
            for(j=0;j<i;j++){
                tmp_ch = tmp_str[0];
                tmp_str.erase(tmp_str.begin());
                tmp_str.insert(tmp_str.end(), tmp_ch);
            }
            for(j=0;j<word.length();j++){
                if(word[j] == tmp_str[j]){
                    counter++;
                }
            }
            if(counter == word.length()){
                cout << "Yes" << endl;
                return 0;
            }
        }

    }

    cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int count = 0;

    while (true) {
        // cout << count << ": " << A << " " << B << " " << C << " " << D << "\n";
        if (count % 2 == 0) {
            C -= B;
        } else {
            A -= D;
        }
        if (A <= 0) {
            cout << "No";
            return 0;
        } else if (C <= 0) {
            cout << "Yes";
            return 0;
        }
        count++;
    }

    return 0;
}


Measured memory_bytes: 3636
program abc
	implicit none
	integer :: n,m,x
	integer :: an(10000)=0 
	character(len=3) :: fname,XXX,YYY
    
    XXX = "AAA"
    YYY = "BBB"

	read(*,*) fname
	if(fname == XXX) then
    	write(*,*) "No"
	else if(fname == YYY) then
    	write(*,*) "No"
    else
    	write(*,*) "Yes"
    endif
    
end program abc

Measured memory_bytes: 256
N, K = map(int, input().split())
l = []
for i in range(N):
    a, b = map(int, input().split())
    l.append([a, b])
l.sort()

num = 0
for i in range(N):
    num += l[i][1]
    if num >= K:
        print(l[i][0])
        break


Measured memory_bytes: 20104
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int cnt=0;
  string s;
  cin >> s;
  for(int i=0; i<3; i++) {
    if(s[i]=='o') {
      cnt++;
    }
  }
  cout << 700+cnt*100 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }   
    ll ans = 0;
    Rep(i,0,N){
        Rep(j,i+1,N){
            ans += d[i]*d[j];
        }
    }
    pr(ans);
}

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

using namespace std;

int n,m,x,an;

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

    for (x=m/n ;; x--) {
        if(m%x == 0) {
            an = x;
            break;
        }
    }


    cout << an << "\n";

}

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

l = []
for i in range(N):
    l.append(input())

print("AC x " + str(l.count("AC")))
print("WA x " + str(l.count("WA")))
print("TLE x " + str(l.count("TLE")))
print("RE x " + str(l.count("RE")))

Measured memory_bytes: 16208
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
using namespace std;

int main() {
	const int LARGE = 100010;
    int N; cin >> N;
	vector<int> v(N);
	for(int i = 0; i < N; i++) cin >> v[i];

	int ans = 0;

	vector<int> even(LARGE, 0);
	vector<int> odd(LARGE, 0);

	for(int i = 0; i < N; i++){
		if(i%2==0) even[v[i]]++;
		else odd[v[i]]++;
	}
	
	int even_max = 0, odd_max = 0, even_max2 = 0, odd_max2 = 0;
	for(int i = 0; i < LARGE; i++){
		if(even[even_max] < even[i]){
			even_max2 = even_max;
			even_max = i;
		}else if(even[even_max2] < even[i]){
			even_max2 = i;
		}
		if(odd[odd_max] < odd[i]){
			odd_max2 = odd_max;
			odd_max = i;
		}else if(odd[odd_max2] < odd[i]){
			odd_max2 = i;
		}
	}

	if(even_max == odd_max){
		cout << N - max(even[even_max] + odd[odd_max2], even[even_max2] + odd[odd_max]) << endl;
	}else{
		cout << N - even[even_max] - odd[odd_max] << endl;
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
template<class T> void chmax(T &a, const T &b){if(a<b) a=b;}
template<class T> void chmin(T &a, const T &b){if(b<a) a=b;}
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n; cin >> n;
    vi dp(n + 1, INT_MAX);
    int a, length = 1;
    rep(i, 0, n) {
        cin >> a;
        if(dp[length - 1] < a) dp[length++] = a;
        else *lower_bound(dp.begin(), dp.begin() + length, a) = a;
    }
    P(length);
	return 0;
}

Measured memory_bytes: 3344
object Main extends App {
  val Array(n,m) = readLine.split(" ").map{_.toInt}
  val (a,b) = (1 to m).map{_ =>
    val Array(x,y) = readLine.split(" ").map{_.toInt}
  	(x,y)}.unzip
  
  (1 to n).foreach{i => println(a.count{_ == i} + b.count{_ == i})}
}

Measured memory_bytes: 25492
S=input()
N=len(S)
ls=[0]*N
rs=[0]*N

nl=0
nr=0
for i in range(N-1,-1,-1):
    if S[i]=='L':
        nl=i
    ls[i]=nl
for i in range(N):
    if S[i]=='R':
        nr=i
    rs[i]=nr

res=[0]*N
for i in range(N):
    if S[i]=='L':
        tgt = rs[i]
        diff = i-tgt
        res[tgt+diff%2]+=1
    else:
        tgt = ls[i]
        diff = tgt-i
        res[tgt-diff%2]+=1
for v in res:
    print(v,end=" ")
print()


Measured memory_bytes: 11484
def main():
    N, M = map(int, input().split())
    d = [None for _ in range(N)]
    for _ in range(M):
        s, c = map(int, input().split())
        if d[s-1] is not None and d[s-1] != c:
            print("-1")
            exit()
        elif N > 1 and s == 1 and c == 0:
            print("-1")
            exit()
        else:
            d[s-1] = c

    if d == [None]:
        print(0)
        exit()

    ans = ""
    for idx, v in enumerate(d):
        if v is not None:
            ans += str(v)
        elif idx == 0:
            ans += "1"
        else:
            ans += "0"
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61816
s = input()
n = len(s)
ans = [0]*(n+1)
count = 0
for i in range(n):
    if s[i] == "<":
        ans[i+1] = ans[i]+1
        if count > 0:
            for j in range(count):
                ans[i-j-1] = max(ans[i-j-1],ans[i-j]+1)
        count = 0
    else:
        count += 1
for j in range(count):
    ans[n-j-1] = ans[n-j]+1
print(sum(ans))

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

int main(){
    int n, k; cin >> n >> k;
    int sunuke[n];
    int count =0;
    for (int i = 0; i < n; i++)
    {
        sunuke[i] = 0;
    }
    
    int d[k];
    int a;
    for (int i = 0; i < k; i++)
    {
        cin >> d[i];
        for (int j = 0; j < d[i]; j++)
        {
            cin >> a;
            sunuke[a-1] = 1;
        }
        
    }

    for (int i = 0; i < n; i++)
    {
        if(sunuke[i] == 0)count++;
    }

    cout << count<<endl;
    
    
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  ll a,b,c,x,y; cin >> a >> b >> c >> x >> y;

  //c*2*max(x,y)
  //c*2*min(x,y)+(a or b)*((x-min(x,y)) or (y-min(x,y)))
  //2a+2b

  // 2c min(x,y)>2a+2b?
  
  ll ans;
  if(2*c*min(x,y)+(x-min(x,y))*a+(y-min(x,y))*b>x*a+y*b){
    ans = x*a+y*b;
  }
  else{
    ans = 2*c*min(x,y)+(x-min(x,y))*a+(y-min(x,y))*b;
  }
  ans = min(ans,2*c*max(x,y));
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3568
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>


using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N){
  for(ll i=1; i<=3500; i++) {
    for(ll j=1; j<=3500; j++) {
      if(4*i*j-N*i-N*j > 0 and (N*i*j)%(4*i*j-N*i-N*j) == 0 and (N*i*j)/(4*i*j-N*i-N*j) > 0) {
	std::cout << i << " " << j << " " << (N*i*j)/(4*i*j-N*i-N*j) << std::endl;
	return;
      }
    }
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}



Measured memory_bytes: 256
main = do
  a <- getLine
  b <- getLine
  c <- getLine
  putStrLn $ game 'a' a b c

game :: Char -> String -> String -> String -> String
game 'a' [] _ _ = "A"
game 'b' _ [] _ = "B"
game 'c' _ _ [] = "C"
game 'a' (a:as) b c = game a as b c
game 'b' a (b:bs) c = game b a bs c
game 'c' a b (c:cs) = game c a b cs


Measured memory_bytes: 508
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
#include<valarray>
typedef unsigned long long ull;
typedef  long long ll;


int main() {
	ll  h,w,hb,wb;

	std::cin >> h >> w >> hb>> wb;

	std::cout << h * w - (hb *w) - (wb * h) + hb * wb << std::endl;
	return 0;
}

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

void dfs(vector<ll> A,vector<ll> a,vector<ll> b,vector<ll> c,vector<ll> d,ll i,ll n,ll m,ll q,ll *mx){
    if(i==n){
        ll tmp=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i]) tmp+=d[i];
        }
        *mx=max(*mx,tmp);
    }else{
        ll j;
        if(i==0) j=1;
        else j=A[i-1];
        for(;j<=m;j++){
            A[i]=j;
            dfs(A,a,b,c,d,i+1,n,m,q,mx);
        }
    }

}

int main(){
    ll n,m,q,mx=0;
    cin>>n>>m>>q;
    vector<ll> a(q),b(q),c(q),d(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--; b[i]--;
    }
    vector<ll> A(n);
    dfs(A,a,b,c,d,0,n,m,q,&mx);
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int x = stoi(s+t);
    for (int i = 1; i <= 1000; i++)
        if(i*i == x){
            cout << "Yes" << endl;
            return 0;
        }
    cout << "No" << endl;
}

Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var d = getDic(a, n, 1);
        var d2 = getDic(a, n, 0);
        var dr = d.OrderByDescending(x => x.Value).ToArray();
        var d2r = d2.OrderByDescending(x => x.Value).ToArray();
        if (dr.Length == 1 | d2r.Length == 1) { Console.WriteLine( getAns1(dr, d2r, n)); goto end; }
        var ans = new List<int>();
        if (dr[0].Key != d2r[0].Key) ans.Add(n - dr[0].Value - d2r[0].Value);
        if (dr[0].Key != d2r[1].Key) ans.Add(n - dr[0].Value - d2r[1].Value);
        if (dr[1].Key != d2r[0].Key) ans.Add(n - dr[1].Value - d2r[0].Value);
        if (dr[1].Key != d2r[1].Key) ans.Add(n - dr[1].Value - d2r[1].Value);
        Console.WriteLine(ans.Min());
        end:;
    }
    public static int getAns1(KeyValuePair<int, int>[] dr, KeyValuePair<int, int>[] d2r, int n)
    {
        if (dr.Length == 1 && d2r.Length == 1 && dr[0].Key != d2r[0].Key) return 0;
        if (dr.Length == 1 && d2r.Length == 1 && dr[0].Key == d2r[0].Key) return n / 2;
        if (dr.Length > 1) return getAns1(d2r, dr, n);
        if (dr[0].Key != d2r[0].Key) return n / 2 - d2r[0].Value;
        else if (dr[0].Key != d2r[1].Key) return n / 2 - d2r[1].Value;
        return 0;
    }
    public static Dictionary<int, int> getDic(int[] a, int n, int s)
    {
        var d = new Dictionary<int, int>();
        for (int i = s; i < n; i += 2)
            if (d.ContainsKey(a[i])) d[a[i]]++;
            else d[a[i]] = 1;
        return d;
    }
}


Measured memory_bytes: 26592
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  map<int,int> C;
  for(int i = 0; i < N; ++i) cin >> A[i], ++C[A[i]];
  sort(A.begin(), A.end());
  if(A[0] == A.back() and A[0] == 0){
    puts("Yes");
    return 0;
  }
  if(N%3 or C.size() > 3){
    puts("No");
    return 0;
  }
  int x = 0;
  for(auto e : C){
    if(e.second%(N/3)){
      puts("No");
      return 0;
    }
    for(int i = 0; i < e.second/(N/3); ++i)
      x ^= e.first;
  }
  if(x) puts("No");
  else puts("Yes");
}


Measured memory_bytes: 4224
#include<stdio.h>

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


Measured memory_bytes: 128