akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <stdlib.h>

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	long a[50][2],c[50][2];
	int i,j;
	for(i=0;i<n;i++)scanf("%ld%ld",&a[i][0],&a[i][1]);
	for(i=0;i<m;i++)scanf("%ld%ld",&c[i][0],&c[i][1]);
	for(i=0;i<n;i++){
		long min=200000001;
		int ans;
		for(j=0;j<m;j++){
			if(abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])<min){
				min=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]);
				ans=j;
			}
		}
		printf("%d\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int A[105];
int main() {
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	int col = N + 1;
	int ans = 0;
	for (int i = 0; i + 1 < N; ++i) {
		if (A[i] == A[i + 1]) {
			++ans;
			A[i + 1] = col;
			++col;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
import math
MOD = 1000000000+7
X, Y = map(int, input().split())

if ((2*Y-X)%3 != 0) or ((2*X-Y)%3 != 0) or (2*Y-X) < 0 or (2*X-Y) < 0:
    print(0)
else:
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    fac_list = [None for _ in range(x+y+2)]
    inv_fac_list = [None for _ in range(x+y+2)]

    fac_list[0] = 1
    for i in range(1, x+y+2):
        fac_list[i] = i * fac_list[i-1] % MOD

    inv_fac_list[x+y+1] = pow(fac_list[x+y+1],(MOD - 2), MOD)
    for i in range(x+y, -1, -1):
        inv_fac_list[i] = inv_fac_list[i+1] * (i+1) % MOD

    print((fac_list[x+y] * inv_fac_list[x] * inv_fac_list[y]) % MOD)

Measured memory_bytes: 92040
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: str):
    # 下の桁から貪欲？
    N = "0" + N
    ans = 0
    kuriagari = 0
    for i in reversed(range(len(N))):
        n = int(N[i])
        if kuriagari == 1:
            kuriagari = 0
            n += 1
        if 0 <= n <= 4:
            ans += n
        elif n == 5:
            # print("上の桁を見て決める")
            k = i-1
            if 0 <= int(N[k]) <= 4:
                # print("桁上がらない")
                ans += 5
            else:
                # print("桁上がる")
                ans += 5
                kuriagari = 1
        else:
            ans += 10 - n
            kuriagari = 1
        # print("現状", ans, kuriagari)
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = next(tokens)
    N = str(a)  # type: str
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 57580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc176_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = CIn.ReadLong();
            var A = CIn.ReadLongArray(N);
            var max = new long[N];
            var sum = 0l;
            var ans = 0l;
            for(var i = 1; i < N; i++)
            {
                max[0] = A[0];
                max[i] = Math.Max(max[i - 1],A[i]);
                if(max[i - 1] > A[i])
                {
                    sum = max[i - 1] - A[i];
                    ans = ans + sum;
                }
            }
            Console.WriteLine(ans);
        
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


Measured memory_bytes: 52228
h, w = map(int, input().split())
n = int(input())
d = list(map(int, input().split()))

c = []
for i in range(len(d)):
	for _ in range(d[i]):
		c.append(i+1)

for i in range(h):
	res = ""
	for j in range(w):
		if i % 2 == 0:
			res = res + str(c.pop()) + ' '
		else:
			res = str(c.pop()) + ' ' + res

	print(res)

Measured memory_bytes: 3444
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)

	sp := strings.Fields(next())
	sum := 0
	for i := 0; i < b; i++ {
		t, _ := strconv.Atoi(sp[i])
		sum = sum + t
	}

	if a < sum {
		fmt.Println(-1)
	} else {
		fmt.Println(a - sum)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
    int r;
    double ans;
    cin >> r;
    ans = 2 * r * PI;
    cout << ans << endl;
}


Measured memory_bytes: 3784
data = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
# print(data)
n = int(input())
for i in range(n):
    b,f,r,v = list(map(int,input().split()))
    data[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(" " + " ".join(map(str,data[i][j])))
    if i < 3:
        print("#"*20)



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

using namespace std;
char a[4];
int main()
{
    int A=0,B=0;
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
        if(a[i]=='A')
            A++;
        if(a[i]=='B')
            B++;
    }
    if( A>0 && B>0)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FU(i, a, b) for (int i = a; i < b; ++i)
#define fu(i, b) FU(i, 0, b)
#define FA(i, x) for (auto i : x)
#define all(V) (V).begin(), (V).end()
#define sz(V) ((int)V.size())
#define FD(i, a, b) for (int i = b - 1; i >= a; --i)
#define fd(i, b) FD(i, 0, b)

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string al, bo, ch;
  map<char, string> m;
  while (getline(cin, al) && al.length()){
    cin >> bo;
    cin >> ch;
    reverse(all(al)); reverse(all(bo)); reverse(all(ch));
    m['a'] = al; m['b'] = bo; m['c'] = ch;
    char curr = 'a';
    while (1){
      if (!m[curr].length()) {
        cout << (char)(curr - 32) << '\n';
        break;
      }
      else {
        char temp = m[curr].back();
        m[curr].pop_back();
        curr = temp;
      }
    
    }
  }
  
  return 0;

}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto H = RD;
	auto W = RD;
	auto S = new string[](H);
	foreach (y; 0..H)
	{
		S[y] = RD!string;
	}

	auto ans = new long[][](H, W);
	void visit(long y, long x)
	{
		if (inside(y, 0, H) && inside(x, 0,W))
		{
			++ans[y][x];
		}
	}

	foreach (y; 0..H)
	{
		foreach (x; 0..W)
		{
			if (S[y][x] != '#')
				continue;
			foreach (i; -1..2)
			{
				foreach (j; -1..2)
				{
					if (i == 0 && j == 0)
						continue;
					visit(y+i, x+j);
				}
			}
		}
	}

	foreach (y; 0..H)
	{
		foreach (x; 0..W)
		{
			if (S[y][x] == '.')
				write(ans[y][x]);
			else
				write("#");
		}
		writeln();
	}

	stdout.flush();
	debug readln();
}

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

const int MOD = 1000000007;


int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    //double r = d/s;
    if((double)d/s <= t)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}





Measured memory_bytes: 3620
// 右からi左からj取ったら捨てるのはK-i-j個でこれは価値の小さいものから選べばよさそう
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	V := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&V[i])
	}
	ans := -1 * int(1e18)
	for i := 0; i <= min(N, K); i++ {
		left := V[:i]
		for j := 0; j <= min(N, K)-i; j++ {
			right := V[N-j:]
			cur := append([]int{}, left...)
			cur = append(cur, right...)
			sort.Ints(cur)
			if len(cur) == 0 {
				continue
			}
			// 負だけとれるだけとればいいんだけどめんどくさいのでループ
			for k := 0; k <= K-i-j; k++ {
				tmp := 0
				for _, c := range cur[min(k, len(cur)):] {
					tmp += c
				}
				ans = max(ans, tmp)
			}
		}
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 1280
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(str.lower(num2alpha(n)))

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
int main()
{
	double a, b;
	cin >> a >> b;
	b -= a;
	int ans = ceil(b / (a - 1.));
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll n;
		cin >> n;
		ll p = 0;
		while (p + 1000 < n)
			p = p + 1000;
		p = p + 1000;
		cout << p - n << endl;
	}
	return 0;
}


Measured memory_bytes: 3684
n = gets.chomp.to_i
h = gets.chomp.split(' ').map(&:to_i)

ans = 0
max = 0
pre = -1
h.each do |x|
  if pre > -1
    if pre >= x
      ans += 1
    else
      max = ans > max ? ans : max
      ans = 0
    end
  end
  pre = x
end
max = ans > max ? ans : max
puts "#{max}"


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define vi vector< int > 
#define pii pair< int, int >
#define mii map< int , int > 
#define F(start,stop) for(int i=start; i<stop; i++)
#define FRev(start,stop) for(int i=start; i>=stop; i--)
#define MOD1 1000000007
#define MOD2 998244353

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	IOS

	ll n;
	cin >> n;
	vector< ll > primes;

	ll temp = n;
	ll cnt  = 0;
	while(temp % 2 == 0){
		temp /= 2;
		cnt++;
	}

	if(cnt > 0)
		primes.push_back(cnt);

	for(ll i=3; i <= sqrt(temp); i += 2){
		cnt  = 0;
		while(temp % i == 0){
			temp /= i;
			cnt++;
		}
		if(cnt > 0)
			primes.push_back(cnt);
	}

	if(temp > 2)
		primes.push_back(1);

	ll ans = 0;

	for(ll i = 0; i < primes.size(); i++){
		ans += ((sqrt(8*primes[i] + 1) - 1)/2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
  int n, x, y = -1;
  int i;
  int sum = 0;
  scanf("%d",&n);

  int a[20], b[20], c[20];
  for(i = 0; i < n; i++){
    scanf("%d",&a[i]);
  }
  for(i = 0; i < n; i++){
    scanf("%d",&b[i]);
  }
  for(i = 0; i < n - 1; i++){
    scanf("%d",&c[i]);
  }
  for(i = 0; i < n; i++){
    x = a[i];
    sum = sum + b[x - 1];
    if(x == y + 1){
      sum = sum + c[x - 2];
    }
    y = x;
  }
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout(v) if(false);
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;



void Main()	
{
	string S;
	cin>>S;
	if(S == "ABC"){
		cout<<"ARC"<<endl;
	}
	else{
		cout<<"ABC"<<endl;
	}
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3640
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val ss = next()

    var max = 0
    for (i in 1 until ss.length) {
        val left = ss.take(i).toSet()
        val right = ss.takeLast(ss.length-i).toSet()
        val merged = mutableSetOf<Char>()
        merged.addAll(left)
        merged.addAll(right)

        val cnt = left.size + right.size - merged.size
        if (cnt > max) max = cnt
    }

    println(max)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 38332
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

const int N = 5002;

int n, m, p_cnt[N][N], X[N], Y[N];
vector<int> vx, vy;

int conv(vector<int>& vec, int x){
  return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

void print(int n){
  for(int i=n+1;i>=0;i--){
    for(int j=0;j<n+2;j++){
      cout << p_cnt[i][j];
    }
    cout << endl;
  }
  cout << endl;
}

main(){
  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> X[i] >> Y[i];
    vx.push_back(X[i]);
    vy.push_back(Y[i]);
  }
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());

  fill(p_cnt[0], p_cnt[N], 0);
  for(int i=0;i<n;i++){
    int x = conv(vx, X[i]);
    int y = conv(vy, Y[i]);
    p_cnt[y+1][x+1]++;
    //printf("X[i] = %d, Y[i] = %d, x = %d, y = %d\n", X[i], Y[i], x, y);
  }
  //print(n);
  for(int i=0;i<vy.size()+2;i++){
    for(int j=0;j<vx.size()+2;j++){
      if(i == 0 && j == 0) continue;
      else if(i == 0) p_cnt[i][j] += p_cnt[i][j-1];
      else if(j == 0) p_cnt[i][j] += p_cnt[i-1][j];
      else p_cnt[i][j] += p_cnt[i][j-1] + p_cnt[i-1][j] - p_cnt[i-1][j-1];
    }
  }
  //print(n);
  for(int i=0;i<m;i++){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1 = conv(vx, x1);
    y1 = conv(vy, y1);
    x2 = conv(vx, x2+1);
    y2 = conv(vy, y2+1);
    //printf("%d %d %d %d\n", x1, y1, x2, y2);
    cout << p_cnt[y2][x2] - p_cnt[y2][x1] - p_cnt[y1][x2] + p_cnt[y1][x1] << endl;
  }
}

Measured memory_bytes: 99068
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> cs(10, vector<int>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> cs[i][j];
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                cs[j][k] = min(cs[j][k], cs[j][i] + cs[i][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int a; cin >> a;
            if(a != -1){
                ans += cs[a][1];
            }
        }
    }
    cout << ans << '\n';
}


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

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  vector<int> T(S.size());
  fill(T.begin(), T.end(), 1);

  for(int i=0; i<S.size(); i++)
    {
      if(S[i]==S[i+1])
	{
	  if(S[i]=='R')
	    {
	      T[i+1] += T[i];
	      T[i] = 0;
	    }
	}
    }

  for(int i=S.size()-1; i>0; i--)
    {
      if(S[i]==S[i-1])
	{
	  if(S[i]=='L')
	    {
	      T[i-1] += T[i];
	      T[i] = 0;
	    }
	}
    }
  int border = 0;
  int rc = 0;
  int lc = 0;
  for(int i=0; i<S.size(); i++)
    {
      if(S[i]==S[i+1])
	{
	  if(S[i]=='R')
	    rc += 1;
	  else
	    lc += 1;
	}
      else if(S[i]=='R')
	{
	  border = i;
	}
      else if(S[i]=='L')
	{
	  rc++;lc++;

	  int common=0;

	  if(rc>lc)
	    common = lc;
	  else
	    common = rc;

	  int sum = T[border]+T[border+1];

	  T[border]=sum*0.5;
	  T[border+1]=sum*0.5;


	  if(abs(rc-lc)%2==0)
	    {
	      rc=0;lc=0;
	    }
	  else if(common%2==0)
	    {
	      if(rc > lc)
		{
		  T[border]++;
		}
	      else
		{
		
		  T[border+1]++;
		}
	     
	       rc=0;
	       lc=0;
	    }
	  else
	    {
	      if(rc > lc)
		{
		
		  T[border+1]++;
		}
	      else
		{
		  T[border]++;
		
		}
	       rc=0;
	       lc=0;
	    }
	  
	  

	  
	}
    }


  for(int i=0; i<S.size(); i++)
    cout << T[i] << " ";
  cout << endl;
  


  return 0;
}


//cout << setprecision(13);
//next_permutation(v.begin(), v.end());



Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
bool visited[1000001]; 
int arr[1000001];
int arr2[1000001];
vector <int> prime;
const long long int MOD = 1e9 + 7;
 
long long int mypow(long long int a,long long int n)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((res%MOD) * (a%MOD)%MOD);
			res%=MOD;
		}
		a = ((a%MOD)*(a%MOD))%MOD;
		a%=MOD;
		n/=2;
	}
	return res;
}
 
void eratos()
{
	memset(visited,true,sizeof(visited));
	for(int i=2;i<=1000000;i++)
	{
		if(visited[i])
		{
			prime.push_back(i);
			for(int j=2*i;j<=1000000;j+=i)
			{
				visited[j] = false;
			}
		}
	}
}
 
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n,t;
	vector <int> v;
	long long int res = 0;

	cin >> n;
 
	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}
 
	eratos();
 
	//cout << prime.size() << '\n';
 
	for(int i=0;i<n;i++)
	{
		if(visited[v[i]]==true)
		{
			arr[v[i]] = max(arr[v[i]],1);
			continue;
		}
		int temp = v[i];
		for(int j=0;j<prime.size();j++)
		{
			if(temp==1)
			{
				break;
			}
			if(temp%prime[j]==0)
			{
				int cnt = 0;
				while(1)
				{
					if(temp%prime[j]!=0)
					{
						break;
					}
					temp/=prime[j];
					cnt++;
				}
				arr[prime[j]] = max(arr[prime[j]],cnt);
			}
		}
		if(temp!=1)
		{
			arr[temp] = max(arr[temp],1);
		}
	}
 
	long long int val = 1;
	for(int i=0;i<prime.size();i++)
	{
		val = ((val%MOD)*(mypow(prime[i],arr[prime[i]])%MOD)%MOD);
		val%=MOD;
	}
 
	for(int i=0;i<n;i++)
	{
		long long int temp = ((val%MOD) * (mypow(v[i],MOD-2)%MOD)%MOD)%MOD;
		res = ((res%MOD) + (temp%MOD)%MOD);
		res%=MOD;
	}
 
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 7612
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a;
    cin >> a; 
    cout << (a/2) * ((a+1)/2);
    cout << endl;
}


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

namespace ABC169C
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            var A = AB[0];
            var B = AB[1];
            Console.WriteLine(Math.Truncate(A * B).ToString("0"));
        }
    }
}


Measured memory_bytes: 19308
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int main(){
	int d,n;
	int t[200] = {0};
	int a[200] = {0},b[200] = {0},c[200] = {0};
	scanf("%d%d",&d,&n);
	for(int i = 0; i < d; i++){
		scanf("%d",&t[i]);
	}
	for(int i = 0; i < n; i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	int dp[201][201] = {{0}};
	for(int i = 0; i < d - 1; i++){
		for(int j = 0; j < n; j++){
			if(a[j] > t[i+1] || b[j] < t[i+1])continue;
			for(int k = 0; k < n; k++){
				if(a[k] > t[i] || b[k] < t[i])continue;
				int val = abs(c[j] - c[k]);
				dp[i+1][j] = max(dp[i+1][j],dp[i][k] + val);
			}
		}
	}
	int ans = -1;
	for(int i = 0; i < n; i++){
		ans = max(ans,dp[d-1][i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int N; cin>>N;
  multiset<int> ms;
  rep(i,N){
    int a; cin>>a;
    ms.insert(a);
  }
  int ans = 0;
  while(!ms.empty()){
    auto it = --ms.end();
    int a = *it;
    ms.erase(it);
    int b = 1;
    while(b<=a) b*=2;
    auto jt = ms.find(b-a);
    if(jt != ms.end()){
      ans++;
      ms.erase(jt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << "No" << endl;
    exit(0);
}

int main() {
    sonic();
    int n, k;
    string s;
    R n >> k >> s;
    s[k-1]=char(s[k-1]+32);
    co(s);
}


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}
inline void sortsm(int &x, int &y) {int a = min(x, y), b = max(x, y); checkmin(x, a); checkmax(y, b);}
inline void sortbi(int &x, int &y) {sortsm(x, y); swap(x, y);}

const int maxn=1e5+10;

int n,m;
vi edge[maxn];
int dp[maxn];
queue<int> que;
int in[maxn];

int main() {
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	edge[a].pb(b);
    	in[b]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(in[i]==0)
		{
			que.pp(i);
		}
	}
	while(!que.empty())
	{
		int t=que.front();
		que.pop();
		for(auto i : edge[t])
		{
			checkmax(dp[i],dp[t]+1);
			in[i]--;
			if(in[i]==0)
			{
				que.pp(i);
			}
		}
	}
	cout<<*max_element(dp+1,dp+1+n)<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define _GLIBCXX_DEBUG
const int INF=1e15;
int N,A,B,C;
vector<int>L(8);

int dfs(int a,int b,int c,int i){
    if(i==N){
        if(min(a,min(b,c))!=0) return abs(a-A)+abs(b-B)+abs(c-C);
        else return INF;
    }
    int a1=dfs(a,b,c,i+1);
    int a2=dfs(a+L[i],b,c,i+1)+10;
  	if(a==0) a2-=10;
    int a3=dfs(a,b+L[i],c,i+1)+10;
  	if(b==0) a3-=10;
    int a4=dfs(a,b,c+L[i],i+1)+10;
  	if(c==0) a4-=10;
    return min(min(a1,a2),min(a3,a4));
}

signed main(){
    cin>>N>>A>>B>>C;
    REP(i,N)cin>>L[i];
    cout<<dfs(0,0,0,0)<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll L, R, D;
    cin >> L >> R >> D;
    ll ans = 0;
    rep2(i, L, R + 1) {
        if (i % D == 0) ans++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

#define IOS cin.tie(0);ios::sync_with_stdio(0)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//void print(){}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
//    IOS;
    CIN(N);
    vi L(N);
    rep(i,N)cin>>L[i];
    sort(all(L),greater<int>());
    int sum=0;
    Rep(i,1,N)sum+=L[i];
    Yes(L[0]<sum);    
    
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut ans = 0;
    let mut prev = 0;
    for i in 0..n {
        if v[i] > prev {
            ans += v[i] - prev;
        }
        prev = v[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()

                sr := ""
                xs := scanner.Text()
          u := strings.ToUpper(xs)
          l := strings.ToLower(xs)

                if u == xs {
                        sr = "A"
                } else if l == xs {
                        sr = "a"
                }
    fmt.Println(sr)
}


Measured memory_bytes: 1776
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define rem_space(x) x.erase(remove(all(x), ' '),x.end())
#define scl(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

int main() {
  int A,B;
  scanf("%d%d",&A,&B);

  if(A + B >= 10) puts("error\n");
  else printf("%d\n",A + B);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(){
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	rep(i,n){
		ll tmp;
		cin >> tmp;
		a[i] = tmp-1;
	}
	vector<ll> visited(n,0);
	ll now = 0;
	for(ll step=1; step<=k; step++){
		now = a[now];
		if(visited[now]){
			ll rest = (k-step) % (step - visited[now]);
			Rep(rest){
				now = a[now];
			}
			cout << now+1 << endl;
			return 0;
		}
		visited[now] =step;
	}
	cout << now+1 << endl;
}

Measured memory_bytes: 6388
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(B/A < C) print(B/A);
  else print(C);

 return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
vector<int> vc;
int a;
for(int i=0;i<n;i++)
{
cin>>a;
vc.push_back(a);
}
sort(vc.begin(),vc.end());
int ans=0;
for(int i=0;i<n;i++)
{
for(int o=i+1;o<n;o++)
{
int k=lower_bound(vc.begin()+o+1,vc.end(),vc[i]+vc[o])-vc.begin();
ans+=max(k-o-1,0);
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <unordered_set>

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

using namespace std;

inline int nextInt()       { int d;    cin >> d; return d; }
inline string nextString() { string s; cin >> s; return s; }

int main() {
  int N = nextInt();
  
  unordered_set<string> IDs;
  
  REP(i, N) {
    string str = nextString();
    IDs.insert(str);
  }
  
  int M = nextInt();
  
  bool isOpen = false;
  REP(i, M) {
    string str = nextString();
    if (IDs.find(str) != IDs.end()) {
      // if ID found
      if (isOpen) {
        cout << "Closed by " << str << endl;
      } else {
        cout << "Opened by " << str << endl;
      }
      isOpen = !isOpen;
    } else {
      // Not found
      cout << "Unknown " << str << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include<string>
using namespace std;
string tosmall(string s)
{
	for(int i=0;i<s.length();i++)if(s[i]>='A'&&s[i]<='Z')s[i]+='a'-'A';
	return s;
}

int main() {
	string s,in;cin>>s;s=tosmall(s);int c=0;
	while(cin>>in&&in!="END_OF_TEXT")
	{
		if(s==tosmall(in))c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>
int main()
{
	int x,y;
	

	while(1)
	{
		scanf("%d %d",&x,&y);
		
		if ( x == 0 && y == 0) break;
		
	if(x>y)
	{
		printf("%d %d\n",y,x);
	}
	else
	{
		printf("%d %d\n",x,y);
	}
	
	
	}
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y;  cin >> x >> y;
    vector<int> g(13);
    g[1] = 1, g[3] = 1, g[5] = 1, g[7] = 1, g[8] = 1, g[10] = 1, g[12] = 1;
    g[2] = 2;
    g[4] = 3, g[6] = 3, g[9] = 3, g[11] = 3;
    if (g[x] == g[y]) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

list = [0 for i in range(N)]

for i in range(K):
    for j in range(d[i]):
        list[A[i][j]-1] += 1

print(list.count(0))

Measured memory_bytes: 68036
import Control.Arrow
import Data.Char
import Data.List

main :: IO ()
main = do
  s <- getString
  print . uncurry (-) . (countIf (== '+') *** countIf (== '-')) $ (s, s)

getString :: IO String
getString = getLine

countIf :: (a -> Bool) -> [a] -> Int
countIf f = length . filter f


Measured memory_bytes: 380
import math

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    S = sum(A)
    l = A[0]
    I = 0
    m = math.ceil(S / 2)
    for i in range(1, N):
        if (l + A[i]) <= m:
            l += A[i]
        else:
            I = i - 1
            break
    if l == S / 2:
        print(0)
        exit()
    c = A[I + 1]
    r = S - l - c
    ans1 = abs(r - (l + c))
    ans2 = abs(l - (r + c))
    print(min(ans1, ans2))

if __name__ == "__main__":
    solve()


Measured memory_bytes: 105096
S = input()

kisuu_list = ['R', 'U', 'D']
gusuu_list = ['L', 'U', 'D']

flag = "Yes"
for i in range(len(S)):
  if i%2 == 0 and S[i] not in kisuu_list:
    flag = "No"
    break
  if i%2 == 1 and S[i] not in gusuu_list:
    flag = "No"
    break
print(flag)

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


int main()
{
	string S;
	cin>>S;
	ll ans=0;
	int N=S.size()-1;
	rep(bit,1<<N)
	{
		vector<bool> pls(N,false);
		rep(i,N)
		{
			if(bit&(1<<i))
			{
				pls[i]=true;
			}
		}
		ll res=0;
		ll buf=0;
		rep(i,N)
		{
			int v=(int)(S[i]-'0');
			buf*=10;
			buf+=v;
			if(pls[i])
			{
				res+=buf;
				buf=0;
			}
		}
		buf*=10;
		buf+=(int)(S[N]-'0');
		res+=buf;
		ans+=res;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
	unsigned short *A, *B;
	
	int C[VMAX+1];
	int n, i, j;
	scanf("%d",&n);
	
	A = malloc(sizeof(short)*n+1);
	B = malloc(sizeof(short)*n+1);
	
	for(i=0;i<=VMAX;i++) C[i] = 0;
	
	for(i=0;i<n;i++) {
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	
	for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
	
	for(j=1;j<=n;j++) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
	
	for(i=1;i<=n;i++) {
		if(i>1) printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 9640
#include<bits/stdc++.h> 
#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
#define M 1000000007 

#define int128 __int128
using namespace std; 
typedef  long long int lli; 

bool prime(lli );

int main(){
		
    AndIamIronMan;
	lli co=0,i,n,y,m,d,j,k,z,t,x=0,a,b,c;
	cin>>t;
	cin>>d;
	while(t--){
		cin>>a>>b;
		double val=sqrt(a*a+b*b);
		if(val<=d) co++;
	}
	cout<<co;
		
	return 0;
}

bool prime(lli n){
	bool x=true;
	int i;
	for(i=2;i<=sqrt(n);i++){
		if(n%i==0){
			x=false;
		}	
	}
	return x;
}

Measured memory_bytes: 3684
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int cost[9];
	int sum;
	int price[5];
	int a;
	
	for (i = 0; i < 9; i++){
		cost[i] = 0;
	}
	
	a = 0;
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		sum = 0;
		for (i = 0; i < 9; i++){
			scanf("%d", &cost[i]);
			sum += cost[i];
		}
		
		price[a] = n - sum;
		a++;
	}
	
	for (i = 0; i < a; i++){
		printf("%d\n", price[i]);
	}
	
	return (0);
}

Measured memory_bytes: 1704
#include <stdio.h>
#include <string.h>
#include <math.h>


int main(int argc, const char * argv[]) {
	
	int i,j,n,s;
	
	while(1){
		
		double a = 0,sum=0,avg=0,score[1000]={0},sigma=0;
		scanf("%d",&n);
		
		if(n == 0){
			break;
		}
		
		for(i = 0 ; i < n ; i++) {
			scanf("%d",&s);
			score[i] = s;
			sum += s;
		}
		
		avg = sum / n;
		
		for(i = 0; i < n ; i++) {
			sigma += pow((score[i] - avg),2);
		}
		
		a = sqrt(sigma/n);
		
		printf("%f\n",a);
	}
	
	return 0;
	
}

Measured memory_bytes: 640
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

dd0 = ((-1, 0), (-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1))
DD = []
for k in range(6):
    ddk = []
    for y in range(k):
        for x in range(k):
            v = 0
            for dx, dy in dd0:
                nx = x + dx; ny = y + dy
                if not 0 <= nx < k or not 0 <= ny < k:
                    continue
                v |= 1 << (ny*k + nx)
            ddk.append(v)
    DD.append(ddk)
L = (1 << 16)
bc = [0]*L
for v in range(1, L):
    bc[v] = bc[v ^ (v & -v)] + 1

def solve():
    N = int(readline())
    if N == 0:
        return False
    dd = dd0
    dk = DD[N]
    state = 0
    for i in range(N):
        s = readline().strip()
        for j, c in enumerate(s):
            if c == '#':
                state |= 1 << (N*i + j)
            elif c == '@':
                sx = j; sy = i
    U = {(state, sx, sy): 0}
    que = deque([(state, sx, sy)])
    while que:
        state, x, y = key = que.popleft()
        d = U[key]
        if state == 0:
            write("%d\n" % d)
            break
        for dx, dy in dd:
            nx = x + dx; ny = y + dy
            if not 0 <= nx < N or not 0 <= ny < N:
                continue
            b = 1 << (ny*N + nx)
            if state & b:
                continue
            state ^= b
            n_state = 0
            for k in range(N*N):
                v = state & dk[k]
                if state & (1 << k):
                    if v and 2 <= bc[v // (v & -v)] <= 3:
                        n_state |= (1 << k)
                else:
                    if v and bc[v // (v & -v)] == 3:
                        n_state |= (1 << k)
            if n_state & b:
                n_state ^= b
            n_key = (n_state, nx, ny)
            if n_key not in U:
                U[n_key] = d+1
                que.append(n_key)
            state ^= b
    else:
        write("-1\n")
    return True
while solve():
    ...


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

int main() {
	int r, d, x_2000;
	cin >> r >> d >> x_2000;

	int num = x_2000;
	int ans;
	for (int i = 0; i < 10; i++) {
		ans = r * num - d;
		cout << ans << endl;
		num = ans;
	}
	return 0;
}

Measured memory_bytes: 256
#
# abc085 c
#
n, y = map(int, input().split())

flag = 0
for i in range(n+1):
    for j in range(n+1):
        if y == 10000 * i + 5000 * j + 1000 * (n-i-j) and n-i-j >= 0:
            flag = 1
        if flag == 1:
            break
    if flag == 1:
        break

if flag == 0:
    print("-1 -1 -1")
else:
    print(i, j, n-i-j)


Measured memory_bytes: 3060