akhauriyash/Code-Regression huggingface dataset:
use std::collections::HashSet;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace()
        .map(|x| x.parse().ok().unwrap()).collect()
}

fn main() {
    let kx = read_vec::<i64>();
    for p in (kx[1]-kx[0]+1)..(kx[1]+kx[0]) {
        print!("{} ", p);
    }
    println!("");
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val (W, H, x, y) = readLine()!!.split(' ').map { it.toDouble() }
    val ans = H * W / 2
    if ((W == x * 2) && (H == y * 2)) {
        println("$ans 1")
    } else {
        println("$ans 0")
    }
}

Measured memory_bytes: 38304
<?php
$ans = 0;
fscanf(STDIN, "%d", $N);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $x[$i], $y[$i]);
}
for ($i = 0; $i < $N - 1; $i++) {
    for ($j = $i + 1; $j < $N; $j++) {
        $ans += sqrt(pow($x[$i] - $x[$j], 2) + pow($y[$i] - $y[$j], 2));
    }
}
$toori = f($N);
$toori_path = $toori * ($N - 1);
$pattern = $N * ($N - 1) / 2;
$unit = $toori_path / $pattern;
$total = $unit * $ans;
echo $total / $toori;
// echo $unit;
//echo $ans;

function f($N) {
    $ret = 1;
    for ($i = 1; $i <= $N; $i++) {
        $ret *= $i;
    }
    return $ret;
}

Measured memory_bytes: 4856
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 18:29:53
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    LL n, k;
    cin >> n >> k;

    LL x, y;
    x = n - k*(n/k);
    y = k*(n/k + 1) - n;

    cout << min(x, y) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[100005];

int main()
{
	IO_OP;
	
	int n, k;
	cin >> n >> k;
	vi l, r;
	l.PB(0), r.PB(0);
	for(int i=0;i<n;i++) {
		cin >> a[i];
		if(a[i] == 0) k--;
	}
	for(int i=0;i<n;i++)
		if(a[i] > 0)
			r.PB(a[i]);
	for(int i=n-1;i>=0;i--)
		if(a[i] < 0)
			l.PB(a[i]);
	int ans = INF;
	for(int i=0;i<=k;i++) {
		int j = k - i;
		if(i >= r.size()) continue;
		if(j >= l.size()) continue;
		ans = min(ans, min(r[i]*2-l[j], -l[j]*2 + r[i]));
	}
	cout << ans << endl;
}



Measured memory_bytes: 1404
void main()
{
    long n = rdElem;
    calc(n).writeln;
}

long calc(long x)
{
    long result = inf;
    for (long i = 1; i * i <= x; ++i)
    {
        if (x % i == 0)
        {
            result = min(result, i+x/i-2);
        }
    }
    return result;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

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

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
using System;

class Program {
    static void Main() {
        string[] stdin = Console.ReadLine().Split();
        int[] a = new int[3];
        for(int i = 0; i < 3; i++) a[i] = int.Parse(stdin[i]);
        bool flag = true;
        for(int i = 0; i < 2; i++) flag &= a[i] < a[i + 1];
        Console.WriteLine(flag? "Yes" : "No");
    }
}


Measured memory_bytes: 17940
#include <stdio.h>
int main(void){
        char s[10000];
        int  ans;
        int i;

        while(1){
                scanf("%s",s);
                if(s[0]=='0')
                        break;
                i=0;
                ans=0;
                while(s[i]!='\0'){
                        ans+=s[i]-'0';
                        i++;
                }
                printf("%d\n",ans);
        }
        return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int b[9] = {};
  int id;
  for(int i=0;i<n;i++){
    id = min(a[i] / 400, 8);
    b[id] += 1;
  }
  int ans = 0;
  for(int i=0;i<9;i++){
    if(b[i] > 0){
      ans += 1;
    }
  }
  if(b[8] == 0){
    cout << ans << " " << ans << endl;
    return 0;
  }
  bool flag=true;
  for(int i=0;i<8;i++){
    if(b[i]>0){
      flag = false;
    }
  }
  if(flag){
    cout << 1 << " " << b[8] << endl;
  }else{
    cout << ans - 1 << " " << ans-1+b[8] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

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

	int K;
	string s;
	cin >> s >> K;

	set<string> sSet;
	REP(i, s.length()) {
		REP(j, K) {
			if ((i + j + 1) <= s.length()) {
				sSet.insert(s.substr(i, j+1));
			}
		}
	}
	vector<string> vec(sSet.begin(), sSet.end());
	cout << vec[K-1] << endl;
	return 0;
}


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

int main() {
  int n;
  cin >>n;
  if(n==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  if(n==23){
    cout<<"Christmas Eve Eve"<<endl;
  }
  if(n==24){
    cout<<"Christmas Eve"<<endl;
  }
  if(n==25){
    cout<<"Christmas"<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

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

	cout << n*n - a << endl;
	return	0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char s[105];
int n;
void dfs(int pos,int x,int up) {
	s[pos]=x+'a';
	if(pos==n-1) {
		printf("%s\n",s);
		return;
	}
	for(int i=0;i<=up+1;i++) {
		dfs(pos+1,i,max(up,i));
	}
}
int main() {
    //freopen("in.txt","r",stdin);
    scanf("%d",&n),s[n]='\0';
    dfs(0,0,0);
    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (double i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  double a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  double x, y, ansSum = -1, ansPer = -1, ansY = -1;

  REP(i, 11) {
    REP(j, 11) {
      REP(m, 101) {
        REP(n, 101) {
          x = 100 * (a * i + b * j);
          y = c * m + d * n;

          if (x + y > f) continue;
          if (x / 100 * e < y) continue;

          if (ansPer < 100 * y / (x + y)) {
            ansSum = x + y;
            ansY = y;
            ansPer = 100 * y / (x + y);
          }
        }
      }
    }
  }
  cout << ansSum << " " << ansY << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;
 
#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;
 
int main() {
  string S;
  vector<long long> v;
  cin >> S;
  long long N = S.length();
  long long key = 0;
  char k[2] = {'R', 'L'};
  rep(i, N) {
    if(S[i] == k[key]) continue;
    else {
      v.push_back(i-1);
      key = key ^ 1;
    }
  }
  v.push_back(N-1);
  long long ans[100000] = {0};
  rep(i, v.size()) {
    if(i % 2 == 1) continue;
    if(i == 0) {
      ans[v[i]] = (v[i] + 2) / 2 + (v[i+1]-v[i]) / 2;
      ans[v[i]+1] = (v[i] + 1) / 2 + (v[i+1]-v[i]+1) / 2;
    } else {
      ans[v[i]] = (v[i]-v[i-1]+1) / 2 + (v[i+1]-v[i]) / 2;
      ans[v[i]+1] = (v[i]-v[i-1]) / 2 + (v[i+1]-v[i]+1) / 2;
    }
  }
  // cout << v.size() << endl;
  // rep(i, N) {
  //   cout << ans[i];
  //   if(i != N-1) cout << " ";
  //   else cout << endl;
  // }
  rep(i, N) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4800
class PriorityQueue

  def initialize(heap=[])
    @size = heap.size
    @heap = heap.sort
  end

  # log( log n )
  def push x
    i = @size
    @size += 1
    while i > 0
      par = ( i - 1 ) / 2
      break if @heap[par] <= x
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  # log( log n )
  # return nil if @size == 0
  def pop

    ret = @heap[0]
    x = @heap[@size-=1]
    # @heap.delete_at(-1)

    i = 0
    while (child = i * 2 + 1) < @size
      child_1 = i * 2 + 2
      child = child_1 if child_1 < @size && @heap[child_1] < @heap[child]
      break if @heap[child] >= x
      @heap[i] = @heap[child]
      i = child
    end

    @heap[i] = x
    @heap.delete_at(-1)
    ret
  end

  def size
    @heap.size
  end

  def top
    @heap[0]
  end

  def any?
    @size > 0
  end

  def empty?
    @size == 0
  end

  def all
    @heap
  end

  def first
    @heap[0]
  end

  def second
    @size < 3 ? @heap[1] : [@heap[1], @heap[2]].min
  end

  def third
    @size < 3 ? nil : [@heap[1], @heap[2]].max
  end

  def sum
    @heap.reduce(0){|s,t| s+t }
  end
end

class Array

  include Comparable

  def to_pq
    PriorityQueue.new(self)
  end

  def -@
    map{|e| -e.to_i }
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
nks = m.times.map{ gets.split.map(&:to_i) }
 
pq = PriorityQueue.new(a)
nks.sort_by!{|nk| -nk[1]}
nks.each do |nk|
  q = false
  nk[0].times do
    t = pq.pop
    if t < nk[1]
      pq.push(nk[1])
    else
      pq.push(t)
      q = true
      break
    end
  end
  break if q
end
 
p pq.sum

Measured memory_bytes: 21536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    for(int i=0;i<b;i++){
      printf("%d",a);
    }
  }
  else{
    for(int i=0;i<a;i++){
      printf("%d",b);
    }
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define endl "\n"

int main()
{
    ll n;
    cin >> n;
    ll a[n], b[n];
    for (ll i = 0; i < n; ++i)
        cin >> a[i], b[i] = a[i];
    sort(b, b + n);
    ll ans = 0;
    for (ll i = 0; i < n; ++i)
    {
        if (a[i] != b[i])
            ++ans;
    }
    if (ans > 2)
    {
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	void main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		System.out.print(a[n-1]);
		for(int i=n-2;i>=0;i--) {
			System.out.print(" " + a[i]);
		}
		System.out.println();
		
	}
	
	public static void main(String[] args) {
		new Main().main();
	}

}





Measured memory_bytes: 26436
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

struct Edge {
    tt: Vec<usize>,
    tf: Vec<usize>,
    ff: Vec<usize>,
}

impl Clone for Edge {
    fn clone(&self) -> Self {
        Edge {
            tt: self.tt.clone(),
            tf: self.tf.clone(),
            ff: self.ff.clone(),
        }
    }
}

fn f(u: usize, edges: &Vec<Edge>, b: bool, check: &mut Vec<Option<bool>>) -> bool {
    if let Some(t) = check[u] {
        if t != b {
            return false;
        } else {
            return true;
        }
    }

    check[u] = Some(b);
    let mut ret = true;
    if b {
        for v in &edges[u].tt {
            ret = ret && f(*v, edges, true, check);
        }
        for v in &edges[u].tf {
            ret = ret && f(*v, edges, false, check);
        }
    } else {
        for v in &edges[u].ff {
            ret = ret && f(*v, edges, false, check);
        }
    }

    ret
}

use std::cmp::max;

fn g(u: usize, n: usize, edges: &Vec<Edge>, check: &mut Vec<Option<bool>>) -> u32 {
    if u == n {
        return 0;
    }

    let mut check_tmp1 = check.clone();
    let mut check_tmp2 = check.clone();

    let ans1;
    if f(u, edges, true, &mut check_tmp1) {
        ans1 = g(u + 1, n, edges, &mut check_tmp1) + 1;
    } else {
        ans1 = 0;
    }

    let ans2;
    if f(u, edges, false, &mut check_tmp2) {
        ans2 = g(u + 1, n, edges, &mut check_tmp2);
    } else {
        ans2 = 0;
    }

    max(ans1, ans2)
}

fn main() {
    let n: usize = read();

    let mut edges: Vec<Edge> = vec![
        Edge {
            tt: vec![],
            tf: vec![],
            ff: vec![],
        };
        n
    ];

    for i in 0..n {
        let a: usize = read();
        for _ in 0..a {
            let xy: Vec<usize> = read_vec();
            let j = xy[0] - 1;
            if xy[1] == 1 {
                edges[i].tt.push(j);
                edges[j].ff.push(i);
            } else {
                edges[i].tf.push(j);
                edges[j].tf.push(i);
            }
        }
    }

    let mut check: Vec<Option<bool>> = vec![None; n];
    println!("{}", g(0, n, &edges, &mut check));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 200050;
int N;
long long A[MAX_N];

long long calc_seg(const std::vector<long long>& tmp_vec) {
    long long ret = 0;
    for (int i = tmp_vec.size() - 1; 0 <= i; i--) {
        if (tmp_vec[i] > i) {
            return -1;
        } else if (i < tmp_vec.size() - 1 && tmp_vec[i] == tmp_vec[i+1] - 1) {
            continue;
        } else if (i < tmp_vec.size() - 1 && tmp_vec[i] < tmp_vec[i+1] - 1) {
            return -1;
        } else {
            ret += tmp_vec[i];
        }
    }
    return ret;
}

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    A[N+1] = 0;

    long long ret = 0;
    std::vector<long long> tmp_vec;
    for (int i = 1; i <= N; i++) {
        tmp_vec.push_back(A[i]);
        if (A[i+1] == 0) {
            long long tmp = calc_seg(tmp_vec);
            if (tmp == -1) {
                std::cout << -1 << std::endl;
                return 0;
            } else {
                ret += tmp;
                tmp_vec.clear();
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3956
#include<cstdio>
const int MaxN=200010,MaxA=2010,MaxB=2010,mod=1000000007;
int N,A[MaxN],B[MaxN],mA,mB,G[MaxA][MaxB],
	f[MaxA*2][MaxB*2],g[MaxA*2][MaxB*2];
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d%d",A+i,B+i);
		if(A[i]>mA)mA=A[i];
		if(B[i]>mB)mB=B[i];
		G[A[i]][B[i]]++; 
	}
	int ans=0;
	for(int i=0;i<=mA*2;i++){
		for(int j=0;j<=mB*2;j++){
			if(i<=mA&&j<=mB)f[i][j]=G[mA-i][mB-j];
			if(i)(f[i][j]+=f[i-1][j])%=mod;
			if(j)(f[i][j]+=f[i][j-1])%=mod;
			if(i>=mA&&j>=mB)ans=(ans+1ll*f[i][j]*G[i-mA][j-mB])%mod;
			g[i][j]=!i&&!j;
			if(i)(g[i][j]+=g[i-1][j])%=mod;
			if(j)(g[i][j]+=g[i][j-1])%=mod;
		}
	}
	for(int i=0;i<N;i++)ans=(ans+mod-g[A[i]*2][B[i]*2])%mod;
	ans=ans*(mod+1ll)/2%mod;
	printf("%d\n",ans);
}

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

NA,NB,M = map(int,readline().split())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
m = map(int,read().split())
XYC = list(zip(m,m,m))

def gen_cand():
    yield min(A) + min(B)
    for x,y,c in XYC:
        yield A[x-1] + B[y-1] - c

answer = min(gen_cand())
print(answer)

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "

int main() {
  int n; cin >> n;
  vector<int> S(n);
  rep0(i, n) cin >> S[i];

  int q; cin >> q;
  vector<int> T(q);
  rep0(i, q) cin >> T[i];
  sort(T.begin(), T.end());

  ll ans = 0;
  rep0(i, q) {
    rep0(j, n) {
      if (T[i] == S[j]) {
        ans++;
        break;
      }
    }
  }

  cout << ans << BR;
  return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
void recur(ll n){
  if(n<0)return;
  recur(n/26-1);
  printf("%c", (int)(n%26)+'a');
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll n, i, j, k;
  cin>>n;
  recur(n-1);
  return 0;
}


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

int main(){
    int n, d;
    cin >> n >> d;
    int watching = 2 * d + 1;
    int ans;

    if (n % watching == 0)
        ans = n / watching;
    else
        ans = n / watching + 1;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> pii;
const ll maxn = 1e6+10;
const ll inf = 1e14;

vector<pii> ve[maxn];
ll dis[maxn];
priority_queue<pii,vector<pii>,greater<pii> > heap;
int N,M;

void init(){
    for(int i = 1;i<=N;i++) dis[i] = inf;
    for(int i = 1;i<=N;i++) ve[i].push_back({i-1,0});
}

ll Dji(){
    heap.push({0,1});
    dis[1] = 0;
    
    while(heap.size()){
        auto cur = heap.top();heap.pop();
        ll d = cur.first,id = cur.second;
        for(auto v: ve[id]){
            ll id2 = v.first,w = v.second;
            if(d+w < dis[id2]){
                dis[id2] = d+w;
                heap.push({dis[id2],id2});
            }
        }
    }
    if(dis[N] == inf) return -1;
    else return dis[N];
}

int main(){
    cin>>N>>M;
    init();
    int a,b,c;
    for(int i = 0;i<M;i++){
        scanf("%d%d%d",&a,&b,&c);
        ve[a].push_back({b,c});
    }
    cout<<Dji()<<endl;
    
    return 0;
}


Measured memory_bytes: 31608
from collections import defaultdict as dd
import heapq

n,k=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
l.sort(key=lambda x:-x[1])

sushi_types = set()
sushies = []
v=0

for i in range(k):
    t,d=l[i]
    v+=d
    if t in sushi_types:
        heapq.heappush(sushies,d)
    else:
        sushi_types.add(t)

remaining_sushi=dd(list)
for i in range(k,n):
    t,d=l[i]
    if not t in sushi_types:
        heapq.heappush(remaining_sushi[t],-d)

eat_candidate_sushi = []
for i in remaining_sushi.keys():
    if not i in sushi_types:
        heapq.heappush(eat_candidate_sushi,remaining_sushi[i][0])

sushi_kinds=len(sushi_types)
val=v
ans=v+sushi_kinds**2

for i in range(sushi_kinds+1,k+1):
    if sushies and eat_candidate_sushi:
        v-=heapq.heappop(sushies)
        v-=heapq.heappop(eat_candidate_sushi)
        ans=max(ans,v+i**2)
    else:
        break

print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 100000;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

int main() {
    string s;
    cin >> s;
    rep(i, s.length()) {
        if(i % 2 == 0 && s[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
        if(i % 2 == 1 && s[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include"bits/stdc++.h"
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N;i++){
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());

    int cnt = 1;
    int lastD = d.at(0);

    for (int i = 1; i < N;i++){
        if (d.at(i) < lastD) {
            cnt++;
            lastD = d.at(i);
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <deque>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    string ans;
    ans = "IMPOSSIBLE";
    int N, M;
    int a, b;
    map<int, bool>m;

    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        if (a == 1) {
            if (m[b]) {
                ans = "POSSIBLE";
            }
            m[b] = true;
        } else if (b == 1) {
            if (m[a]) {
                ans = "POSSIBLE";
            }
            m[a] = true;
        } else if (a == N) {
            if (m[b]) {
                ans = "POSSIBLE";
            }
            m[b] = true;
        } else if (b == N) {
            if (m[a]) {
                ans = "POSSIBLE";
            }
            m[a] = true;
        }
    }

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


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int n,k,a[200000],c[200000],cnt=0,ans=0;
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
        c[a[i]-1]++;
    }
    sort(c,c+n);
    for(int i=0;i<n;i++)if(c[i]!=0)cnt++;
    cnt-=k;
    if(cnt<=0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<200000;i++){
        if(c[i]==0)goto loop;
        cnt--;
        ans+=c[i];
        if(cnt<=0){
            cout<<ans<<endl;
            return 0;
        }
        loop:;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(){
 
  int W,H,i,j;
 
  while(1){
  scanf("%d %d",&W,&H);
if(W==0 && H==0)break;
 
  for(i=0;i<W;i++){

    for(j=0;j<H;j++)
{
    printf("#");
  } 
  printf("\n");
 
  
  }
  printf("\n");
  }
  
 
  return 0;
  }


Measured memory_bytes: 2028
function main(input){
  const args=input.split(' ');
  const A=parseInt(args[0], 10);
  const B=parseInt(args[1], 10);
  if(A>=13){
    console.log(B);
  }else if(A>=6){
    console.log(B/2);
  }else{
    console.log(0);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N,T;
  get(N,T);
  map<ll,int> diff;
  ll mn=1LL<<40;
  FOR(i,N){
    ll A;
    get(A);
    if(mn<A){
      diff[A-mn]++;
    }else{
      mn=A;
    }
  }
  ll ans,mx=0;
  for(pair<ll,int> p:diff){
    if(mx<p.first){
      mx=p.first;
      ans=p.second;
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//const ll INF = (ll)1e18 + 1;

struct edge{
  ll from;
  ll to;
  ll cost;
  edge(ll f, ll t, ll c): from(f), to(t), cost(c){};
};

int main(){
  int N, M; cin >> N >> M;
  vector<ll> d(N, INF);
  d[0] = 0;
  vector<edge> edges;
  rep(i, M){
    ll a, b, c; cin >> a >> b >> c;
    --a, --b;
    edges.push_back(edge(a, b, -c));
  }

  //Bellman-Ford
  bool negative = false;
  rep(i, 2 * N){
    rep(j, M){
      edge e = edges[j];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        if (i >= N - 1 && e.to == N - 1) negative = true;
      }
    }
  }
  if (negative) cout << "inf" << endl;
  else cout << -d[N - 1] << endl;
}


Measured memory_bytes: 384
"use strict";
function main(input) {
    const args = input.split(' ');

    let A = parseInt(args[0]);
    let B = parseInt(args[1]);

    let ans = 0;

    for(let i = 0; i < 2; i++) {
        if (B < A) {
            ans += A;
            A--;
        } else {
            ans += B;
            B--;
        }
    }

    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
import sys
import math

N, X = map(int, input().split())
x = list(input().split())
city = [abs(int(x[i]) - X) for i in range(N)]
MAX = min(city)
candidate = []
for i in range(int(math.sqrt(MAX)+1)):
    if MAX % (i+1) == 0:
        candidate.append(i+1)
        candidate.append(MAX // (i+1))

candidate = list(sorted(candidate, reverse=True))

for j in range(len(candidate)):
    ans = candidate[j]
    tmp = [city[i] % ans for i in range(N)]
    if max(tmp) == 0:
        print(ans)
        sys.exit()

Measured memory_bytes: 21764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		var S = GetString();
		WriteLine(S.Last() == 's' ? S + "es" : S + "s");
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 26180
#include <stdio.h>
int main(void){
    int n,i,c[4],tmp,f=0;
    const int v[]={10,50,100,500};
    while(1){
        scanf("%d",&n);
        if(n==0)
            break;
        if(f)
            puts("");
        tmp=0;
        for(i=0;i<4;i++){
            scanf("%d",&c[i]);
            tmp+=v[i]*c[i];
        }
        tmp-=n;
        for(i=3;i>=0;i--){
            c[i]-=tmp/v[i];
            if(c[i]<0)
                c[i]=0;
            tmp%=v[i];
        }
        for(i=0;i<4;i++){
            if(c[i])
                printf("%d %d\n",v[i],c[i]);
        }
        f=1;
    }
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        if(mp.count(tmp-1)){
            mp[tmp-1]++;
        }else{
            mp[tmp-1]=1;
        }
        if(mp.count(tmp)){
            mp[tmp]++;
        }else{
            mp[tmp]=1;
        }
        if(mp.count(tmp+1)){
            mp[tmp+1]++;
        }else{
            mp[tmp+1]=1;
        }
    }
    
    int ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        ans=max(ans,itr->second);
    }
    cout<<ans<<endl;
    return 0;
}

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

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
    
print(num2alpha(n).lower())

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

int main(){
  long long int a,b,c,d;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  long long int ans=max({max(a,b)*max(d,c),min(a,b)*min(c,d), min(a,b)*max(c,d), max(a,b)*min(c,d)});
  printf("%lld", ans);
}
             


Measured memory_bytes: 3828
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;
typedef pair<double,double> P;


int main(){
	
	P p[50];
	char c;
	double ans=0;
	int n=1;
	while(cin>>p[n].first>>c>>p[n].second)
		n++;
	p[n+1].first=p[1].first;
	p[n+1].second=p[1].second;
	n--;
	for(int i=1;i<=n;i++){
		double s=0;
		s=(p[i].first-p[i+1].first)*(p[i].second+p[i+1].second);
		ans+=s;
	}
	
	printf("%.6f\n",abs(ans)/2);
	
	
	
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}







int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);

ll arr[3][3];

for(int i=0;i<3;i++)
for(int j=0;j<3;j++)cin>>arr[i][j];

ll n;cin>>n;

for(int i=0;i<n;i++)
{
  ll temp;cin>>temp;
  for(int j=0;j<3;j++)
  {
    for(int k=0;k<3;k++)
    {
      if(arr[j][k]==temp)arr[j][k]=0;
    }
  }
}



for(int i=0;i<3;i++)
{
  ll cnt=0;
  for(int j=0;j<3;j++)
  {
    if(arr[i][j]==0)cnt++;
  }
  if(cnt==3)
  {
    cout<<"Yes"<<"\n";
    return 0;
  }
}


for(int i=0;i<3;i++)
{
  ll cnt=0;
  for(int j=0;j<3;j++)
  {
    if(arr[j][i]==0)cnt++;
  }
  if(cnt==3)
  {
    cout<<"Yes"<<"\n";
    return 0;
  }
}


ll x=0;
for(int i=0;i<3;i++)
{
if(arr[i][i]==0)x++;
}
if(x==3)

  {
    cout<<"Yes"<<"\n";
    return 0;
}


 x=0;
for(int i=0;i<3;i++)
{
if(arr[i][2-i]==0)x++;
}
if(x==3)
  {
    cout<<"Yes"<<"\n";
    return 0;
  }

cout<<"No"<<"\n";


  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;
ll mod = 1e9 + 7;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; i++)
    {
        ll aa = i * (2 * n - i + 1) / 2;
        ll bb = i * (i - 1) / 2;
        ans += (aa) % mod;
        ans -= (bb) % mod - 1;
        if (ans < 0)
        {
            ans += mod;
        }
    }
    cout << ans % mod << endl;
    return 0;
}


Measured memory_bytes: 3632
l = [list(map(int, input().split())) for i in range(3)]
b = l[0]
a2 = l[1][0] - b[0]
a3 = l[2][0] - b[0]
if l[1] == [a2 + b[0], a2 + b[1], a2 + b[2]] and l[2] == [a3 + b[0], a3 + b[1], a3 + b[2]]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[20];
int b[1100];
int c[1100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)b[i]=c[i]=0;
		for(int i=0;i<a;i++){
			scanf("%s",str);
			if(str[0]=='x'){
				c[i]=1;
			}else sscanf(str,"%d",b+i);
		}
		int L=-1111111111;
		int R=1111111111;
		for(int i=0;i<a;i++){
			if(c[i]==1){
				if(i%2==0){
					if(i){
						if(c[i-1]==1){L=1111111111;R=-1111111111;}
						else R=min(R,b[i-1]-1);
					}
					if(i<a-1){
						if(c[i+1]==1){L=1111111111;R=-1111111111;}
						else R=min(R,b[i+1]-1);
					}
				}else{
					if(i){
						if(c[i-1]==1){L=1111111111;R=-1111111111;}
						else L=max(L,b[i-1]+1);
					}
					if(i<a-1){
						if(c[i+1]==1){L=1111111111;R=-1111111111;}
						else L=max(L,b[i+1]+1);
					}
				}
			}else{
				if(i%2==0){
					if(i&&!c[i-1]&&b[i]>=b[i-1]){L=1111111111;R=-1111111111;}
					if(i<a-1&&!c[i+1]&&b[i]>=b[i+1]){L=1111111111;R=-1111111111;}
				}else{
					if(i&&!c[i-1]&&b[i]<=b[i-1]){L=1111111111;R=-1111111111;}
					if(i<a-1&&!c[i+1]&&b[i]<=b[i+1]){L=1111111111;R=-1111111111;}
				}
			}
		}
		if(L>R)printf("none\n");
		else if(L<R)printf("ambiguous\n");
		else printf("%d\n",L);
	}
}

Measured memory_bytes: 1056
N=int(input())
Ball=[]
for i in range(2*N):
  c,a=input().split()
  Ball.append((c,int(a)))
B=[0]*N
W=[0]*N
B_table=[[0]*(N+1) for i in range(N)]
W_table=[[0]*(N+1) for i in range(N)]
for i in range(2*N):
  c=Ball[i][1]-1
  if Ball[i][0]=="B":
    B[c]=i+1
    for j in range(i+1,2*N):
      if Ball[j][0]=="B":
        if Ball[j][1]<Ball[i][1]:
          B_table[Ball[i][1]-1][0]+=1
      elif Ball[j][0]=="W":
        B_table[c][Ball[j][1]]+=1
    for k in range(N):
      B_table[c][k+1]+=B_table[c][k]
  elif Ball[i][0]=="W":
    W[c]=i+1
    for j in range(i+1,2*N):
      if Ball[j][0]=="W":
        if Ball[j][1]<Ball[i][1]:
          W_table[c][0]+=1
      elif Ball[j][0]=="B":
        W_table[c][Ball[j][1]]+=1
    for k in range(N):
      W_table[c][k+1]+=W_table[c][k]
dp=[[0]*(N+1) for i in range(N+1)]
for s in range(1,2*N+1):
  for b in range(max(0,s-N),min(s,N)+1):
    if b==0:
      dp[0][s]=dp[0][s-1]+(W[s-1]+W_table[s-1][0]-s)
    elif b==s:
      dp[s][0]=dp[s-1][0]+(B[s-1]+B_table[s-1][0]-s)
    else:
      dp[b][s-b]=min(dp[b-1][s-b]+(B[b-1]+B_table[b-1][s-b]-s),dp[b][s-b-1]+(W[s-b-1]+W_table[s-b-1][b]-s))
print(dp[N][N])

      
      

   
  
      
      

   
  

Measured memory_bytes: 146008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");
		String str2[] = br.readLine().split("");

		for (int i = 0; i < str.length; i++) {
			if (!str[i].equals(str2[i])) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 32928
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	
	while (k--){
		int x, y, temp;
		scanf("%d%d", &x, &y);
		if (x > n/2)
			x = n-x+1;
		if (y > n/2)
			y = n-y+1;
		if (x == y){
			temp = x%3;
		}else if (x > y){
			temp = y%3;
		}else {
			temp = x%3;
		}
		if (temp == 0) temp = 3;
		printf("%d\n", temp);
	}
	return 0;
}

Measured memory_bytes: 3180
#include<stdio.h>


int main(void){
	int n;
	int a[200000]={};
	int i;
	int b;

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

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

	return 0;

}



Measured memory_bytes: 2508
n = int(input())
x = list(input().split() for i in range(n))
c = 0

for i in range(n):
    if x[i][1] == 'JPY':
        c += int(x[i][0])
    else:
        y = float(x[i][0]) * 380000.0
        c += y

print(c)

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

int main() {
    int x;
    cin >> x;
    for(int i=x; i<1e5+4;++i){
        int ans=i;
        bool a=true;
        for(int j=2; j<sqrt(ans); ++j){
            if(ans%j==0){
               a=false;
               break;
            }
        }
        if(a){
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1ll<<i)<=x;i++);
    return i;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    int n;
    cin >> n;
    
    int c=1,p=1;
    if(n==1){
        cout << 1;
        return 0;
    }
    
    while(n>1) {
        p*=2;
        c+=p;
        n/=2;
    }
    
    
    cout << c;
        
    
    
	return 0;
    
}

Measured memory_bytes: 8832
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var two = nextIntArray();
  var R = two[0];
  var S = two[1];
  var P = two[2];
  var map = {
    "r" : R,
    "s" : S,
    "p" : P
  };
  var t = next();
  var s = new Array(N);
  var output = 0;
  for(var i = 0; i < N; i++){
    if(i < K){
      switch(t[i]){
        case "r":
          output += map["p"];
          s[i] = "p";
          break;
        case "s":
          output += map["r"];
          s[i] = "r";
          break;
        case "p":
          output += map["s"];
          s[i] = "s";
          break;
      }
    }else{
      switch(t[i]){
        case "r":
          if(s[i - K] != "p"){
            output += map["p"];
            s[i] = "p";
          }else{
            s[i] = "-";
          }
          break;
        case "s":
          if(s[i - K] != "r"){
            output += map["r"];
            s[i] = "r";
          }else{
            s[i] = "-";
          }
          break;
        case "p":
          if(s[i - K] != "s"){
            output += map["s"];
            s[i] = "s";
          }else{
            s[i] = "-";
          }
          break;
      }
    }
  }
  
  myout(output);
}


Measured memory_bytes: 34660