akhauriyash/Code-Regression huggingface dataset:
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public final class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		HashMap<Integer,ArrayList<Integer>> map = new HashMap<>();
		int p = s.nextInt();
// 		DSU dsu = new DSU(n);
		for(int i=0;i<p;i++){
			int a = s.nextInt();
			int b = s.nextInt();
			if(!map.containsKey(a-1)){
				map.put(a-1,new ArrayList<>());
			}
			if(!map.containsKey(b-1)){
				map.put(b-1,new ArrayList<>());
			}
			map.get(a-1).add(b-1);
			map.get(b-1).add(a-1);
// 			dsu.union(a-1,b-1);
		}
		HashMap<Integer,Integer> c = new HashMap<>();
		Queue<Integer> q = new LinkedList<>();
		q.offer(0);
// 		int count =1;
		while(!q.isEmpty()){
		    int size = q.size();
		    for(int i=0;i<size;i++){
		        int cur = q.poll();
		        for(int next : map.get(cur)){
		            if(c.containsKey(next)){
		                continue;
		            }
		            else{
		                c.put(next,cur);
		                q.offer(next);
		            }
		        }
		    }
		  //  count++;
		}
		if(c.size()<n){
		    System.out.println("No");
		}
		else{
		    System.out.println("Yes");
		    for(int i=1;i<n;i++){
		        System.out.println(c.get(i)+1);
		    }
		}
	}
}

Measured memory_bytes: 97204
# ans = 売る可能性がある場所の数 = 売って利益が最大値になる可能性がある場所
# Tは関係ない

N,T=map(int,input().split())
A=list(map(int,input().split()))

# 売る場所を一つず右にずらす
# それより前の場所の最安値を持っておく
# 差分のmaxvalを満たす回数をカウント、maxvalが更新されたら回数は1に戻す

INF=10**9+1
maxval=0
minval=INF
ans=0
for i in range(1,len(A)):
  minval=min(A[i-1],minval)
  diff=A[i]-minval
  if diff>maxval:
    maxval=diff
    ans=1
  elif diff==maxval:
    ans+=1

print(ans)


Measured memory_bytes: 15020
#include <stdio.h>

int main(void){
	int m, d;
	int count = 0;
	scanf("%d %d", &m, &d);
	for(int i = 1; i <= m; i++){
		for(int j = 20; j <= d; j++){
			if(j % 10 >= 2 && j / 10 * (j % 10) == i){
				count++;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    map<int, ll> mp;
    irep(i, n) {
        ll tmp;
        cin >> tmp;
        mp[i+1] = tmp;
    }
    
    v2_int h(n);
    irep(i, m) {
        int a, b;
        cin >> a >> b;
        h[a-1].push_back(mp[b]);
        h[b-1].push_back(mp[a]);
    }

    int ans = 0;
    irep(i, n) {
        v_int to;
        to = h[i];
        if(to.empty()) { ans++; continue; }
        sort(to.rbegin(), to.rend());
        //for(auto t : to) { cout << t << ","; } cout << endl;
        //cout << to.front() << endl;
        if(to.front() < mp[i+1]) { ans++; }
    }
    cout << ans << endl; 
    return 0;
}
/** atcoder **/


Measured memory_bytes: 14752
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n, m, i, j;
struct node {
	int l, r;
	long long c;
} b[200001*4],a[200001];
bool cmp (node a,node b)
{
	return a.l<b.l;
}
void build(int x,int l,int r)
{
	b[x].l=l;
	b[x].r=r;
	b[x].c=1E18;
	if (l==r) {
		if (l==1) b[x].c=0;
		return;
	}
	int mid=l+r>>1;
	if (l<=mid) build(x*2,l,mid);
	if (mid+1<=r) build(x*2+1,mid+1,r);
}
long long query(int x,int y)
{
	if (b[x].l==b[x].r) return b[x].c;
	long long ans=b[x].c;
	if (y<=b[x*2].r) {
		ans=min(ans,query(x*2,y));
	}
	else {
		ans=min(ans,query(x*2+1,y));
	}
	return ans;
}
void update(int x,long long y,int l,int r)
{
	if (l<=b[x].l&&b[x].r<=r) {
		b[x].c=min(b[x].c,y);
		return;
	}
	if (l<=b[x*2].r) update(x*2,y,l,r);
	if (r>=b[x*2+1].l) update(x*2+1,y,l,r);
}
int main (void)
{
	scanf("%d%d",&n,&m);
	for (i=1; i<=m; i++) {
		scanf("%d%d%lld",&a[i].l,&a[i].r,&a[i].c);
	}
	sort(a+1,a+m+1,cmp);
	build(1,1,n);
	for (i=1; i<=m; ) {
		j=i;
		long long t=query(1,a[i].l);
		while (a[j].l==a[i].l&&j<=m) {
			update(1,t+a[j].c,a[j].l+1,a[j].r);
			j++;
		}
		i=j;
	}
	printf("%lld\n",query(1,n)==1E18?-1:query(1,n));
	return 0;
}

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

int main() {
  int h1, h2, h3, c1, c2, c3, c3_s, n;
  scanf("%d", &n);
  scanf("%d %d", &h1, &h2);
  c1 = 0;
  c2 = abs(h1 - h2);
  for (int i = 0; i < n - 2; i++) {
    scanf("%d", &h3);
    c3 = c1 + abs(h1 - h3);
    c3_s = c2 + abs(h2 - h3);
    h1 = h2;
    h2 = h3;
    c1 = c2;
    if (c3 <= c3_s) {
      c2 = c3;
    } else {
      c2 = c3_s;
    }
  }
  printf("%d\n", c2);
  return 0;
}


Measured memory_bytes: 1716
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (String i : in) {
            list.add(Integer.parseInt(i));
        }

        br.close();

        Collections.sort(list);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += list.get(i);
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    }
}

Measured memory_bytes: 32996
#include<iostream>
#include<stdio.h>

using namespace std;

int main() {
	int time[5];
	int a[5], b[5];
	for (int i = 0; i < 5; i++) {
		cin >> time[i];
		a[i] = time[i] / 10;
		b[i] = time[i] % 10;
	}
	int p = 10;
	int k = 0;
	for (int i = 0; i < 5; i++) {
		if (p > b[i] && b[i] > 0) {
			p = b[i];
			k = i;
		}
		else continue;
	}
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		if (i != k && b[i] > 0)ans += 10 * (a[i] + 1);
		else ans += time[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var abc = new[] { Input.ar, Input.ar, Input.ar };
        var res = 0L;
        abc = abc.Select(ar => ar.OrderBy(v => v).ToArray()).ToArray();
        for(var i = 0; i < num; i++)
        {
            var a = Search.LowerBound(abc[0], abc[1][i]);
            var c = Search.UpperBound(abc[2], abc[1][i]);
            res += (long)a * (num - c);
        }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class Search
{
    public static int UpperBound<T>(T[] array,T value)
        where T:IComparable<T>
    {
        var low = 0;
        var high = array.Length;
        while (high > low)
        {
            var mid = (high + low) / 2;
            if (array[mid].CompareTo(value) == 1) high = mid;
            else low = mid + 1;
        }
        return low;
    }

    public static int LowerBound<T>(T[] array,T value)
        where T : IComparable<T>
    {
        var low = 0;
        var high = array.Length;
        while (high > low)
        {
            var mid = (high + low) / 2;
            if (array[mid].CompareTo(value) != -1) high = mid;
            else low = mid + 1;
        }
        return low;
    }
}


Measured memory_bytes: 41116
package main

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

func mapf(f interface{}, list interface{}) interface{} {
	fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

	if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
		return nil
	}

	len := listv.Len()
	ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

	for i := 0; i < len; i++ {
		v := fv.Call([]reflect.Value{listv.Index(i)})
		ret.Index(i).Set(v[0])
	}

	return ret.Interface()
}

func ifval(cond bool, a interface{}, b interface{}) interface{} {
	return map[bool]interface{}{true: a, false: b}[cond]
}

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

	arr, _ := mapf(strconv.Atoi, strings.Split(scanner.Text(), " ")).([]int)
	a, b, c := arr[0], arr[1], arr[2]

	fmt.Println(ifval(a < b && b < c, "Yes", "No").(string))
}



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

#define ll long long
//~ #define endl '\n'

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	int cnt_R = 0, cnt = 0, r = n - 1;
	while(r >= 0 && s[r] == 'W') r--;
	for(int i = 0; i<n; i++){
		if(i > r) break;
		if(s[i] == 'W'){
			if(s[r] == 'R'){
				cnt++;
				swap(s[i], s[r]);
				while(r >= 0 && s[r] == 'W') r--;
			}else{
				cnt++;
				s[i] = 'R';
			}
		}
	}
	cout<<cnt<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1; //cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

string S;

string ans() {
	ll N = S.size();
	ll b[26] = {};

	rep(i, N) {
		b[S[i] - 'a'] = 1;
	}

	rep(i, 26) {
		if (b[i] == 0) {
			char c = 'a' + i;
			return S + c;
		}
	}

	for (ll i = N - 1; i >= 0; i--) {
		ll X = S[i]-'a';
		for (ll j = X + 1; j < 26; j++) {
			if (b[j] == 0) {
				char c = 'a' + j;
				S = S.substr(0, i);
				return S + c;
			}
		}

		b[X] = 0;

	}

	return "-1";
}


int main() {
	cin >> S;
	cout << ans();
	
	
	system("PAUSE");

}





Measured memory_bytes: 504
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Dec  1 02:30:33 2018
//
package main

import (
	"fmt"
	"sort"
)

type city struct {
	p int
	y int
}

var n, m int
var cityYears [100001][]int
var cities []city

func main() {
	fmt.Scan(&n, &m)

	cities = make([]city, m)
	for i := range cityYears {
		cityYears[i] = make([]int, 0)
	}

	for i := range cities {
		fmt.Scan(&cities[i].p, &cities[i].y)
		cityYears[cities[i].p] = append(cityYears[cities[i].p], cities[i].y)
	}

	for i := range cityYears {
		sort.Ints(cityYears[i])
	}

	for i := range cities {
		p, y := cities[i].p, cities[i].y
		index := sort.Search(len(cityYears[p]), func(i int) bool { return cityYears[p][i] >= y })
		fmt.Printf("%06d%06d\n", p, index+1)
	}
}


Measured memory_bytes: 11396
// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;

int main(){
	//cin.sync_with_stdio(false); cin.tie(0);
	//cin >> sth; cout << sth;
	int a;
	cin >> a;
	cout << 3*a*a;	
}


Measured memory_bytes: 256
#include <iostream> 
#include <sstream> // istringstream
#include <string> // 文字列
#include <algorithm> // アルゴリズム
#include <cmath> // 
#include <vector> // vector
#include <set> // set
#include <map> // map

using namespace std;

int main()
{   
    // input sample
    string N;
    cin >> N;
    // for (int i = 0; i < N; ++i) cin >> A[i]; 
    // string s = "";
    int ans = 0;

    // output sample
    for(int i=0; i<N.length(); ++i){
        int j = (int)N[i] - 48;
        ans += j;
    }

    if (ans % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n;
    cin >> n;
    switch (n%10)
    {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;
        case 3:
            cout << "bon";
            break;
        default:
            break;
    }
}


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

int main(){
  int A, B, C, D;
  string S;
  cin >> S;
  A=S.at(0)-'0';
  B=S.at(1)-'0';
  C=S.at(2)-'0';
  D=S.at(3)-'0';
  if(A+B+C+D==7){
    cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
  }
  else if(A+B+C-D==7){
    cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
  }
  else if(A+B-C+D==7){
    cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
  }
  else if(A+B-C-D==7){
    cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
  }
  else if(A-B+C+D==7){
    cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
  }
  else if(A-B+C-D==7){
    cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
  }
  else if(A-B-C+D==7){
    cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
  }
  else if(A-B-C-D==7){
    cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define y1 y11
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define skip continue
#define all(x) x.begin(), x.end()
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
 
const ll inf = 1e9;
const int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};
const int maxn = 1e5 + 11;

ll n, a[maxn * 3], ans;

int main(){

cin >> n;

for(int i = 1; i <= n * 3; ++i){
	cin >> a[i];
}

sort(a + 1, a + n * 3+ 1);

for(int i = n + 1; i <= n * 3; i += 2){
	ans += a[i];
}

cout << ans;

return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int result = 0;

        for(int i=N; i<=999; i++){
            if(i == 111 || i == 222 || i == 333 || i == 444 || i == 555 || i == 666 || i == 777 || i == 888 || i == 999 ){
                result = i;
                break;
            }
        }
        System.out.print(result);
    }
}

Measured memory_bytes: 23252
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));

        char[] s = br.readLine().toCharArray();
        int num1 = 0;
        int num2 = 0;
        for(int i = 0; i < s.length; i++) {
            boolean b = i % 2 == 0;
            if(b && s[i] == '1' || !b && s[i] == '0') num1++;
            else num2++;
        }

        System.out.println(Math.min(num1, num2));
    }
}

Measured memory_bytes: 26452
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int[int] C(int[] X) {
    int[] Y = X.sort.uniq.array;
    int[int] ret;
    foreach (i; 0 .. cast(int)Y.length) {
        ret[Y[i]] = i;
    }
    return ret;
}

void main() {
    int n, m; readf("%d %d\n", &n, &m);
    int[] X, Y;
    foreach (i; 0 .. n) {
        int x, y; readf("%d %d\n", &x, &y);
        X ~= x;
        Y ~= y;
    }
    int[] _X = X ~ [int.min, int.max],
          _Y = Y ~ [int.min, int.max];

    int[int] xM = C(_X.dup);
    int[int] yM = C(_Y.dup);
    int[] sX = _X.dup.sort.uniq.array;
    int[] sY = _Y.dup.sort.uniq.array;
    auto nx = _X.length, ny = _Y.length;
    auto F = new short[][](ny, nx);
    auto G = new short[][](ny + 1, nx + 1);
    foreach (i; 0 .. n) {
        F[ yM[ Y[i] ] ][ xM[ X[i] ] ] += 1;
    }
    foreach (i; 1 .. ny + 1) {
        short x = 0;
        foreach (j; 1 .. nx + 1) {
            x += F[i - 1][j - 1];
            G[i][j] = cast(short)(G[i - 1][j] + x);
        }
    }

    short f(int sy, int sx, int gy, int gx) {
        return cast(short)(G[gy][gx] - G[sy][gx] - G[gy][sx] + G[sy][sx]);
    }

    int g(int[] r, int[int] map, int v) {
        if (v in map) return map[v];
        //writeln("r: ", r, "map: ", map, " v: ", v);
        auto ub = r.assumeSorted.upperBound(v);
        if (ub.empty) return map[r.back];
        else return map[ub.front];
    }

    int h(int[] r, int[int] map, int v) {
        if (v in map) return map[v] + 1;
        v--;
        //writeln("r: ", r, "map: ", map, " v: ", v);
        auto ub = r.assumeSorted.upperBound(v);
        if (ub.empty) return map[r.back];
        else return map[ub.front];
    }

    //[sY, sX].writeln;
    foreach (i; 0 .. m) {
        int sx, sy, gx, gy; readf("%d %d %d %d\n", &sx, &sy, &gx, &gy);
        //write([sy, sx, gy, gx], " -> ");
        sx = g(sX, xM, sx);
        sy = g(sY, yM, sy);
        gx = h(sX, xM, gx);
        gy = h(sY, yM, gy);
        //writeln([sy, sx, gy, gx]);
        writeln(f(sy, sx, gy, gx));
    }

    /*
    foreach (_; F) _.writeln;
    writeln;
    foreach (_; G) _.writeln;
    */
}

Measured memory_bytes: 124252
#include<iostream>
#include<vector>

using namespace std;

int N,W;
vector<int>v;
vector<int>w;
int dp[101][10001]={0};


int main(){
    cin>>N>>W;
    v=vector<int>(N);
    w=vector<int>(N);
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=W;j++){
            dp[i][j]=-1;
        }
    }
    for(int i=0;i<=N;i++){
        dp[i][0]=0;
    }
    for(int i=0;i<=W;i++){
        dp[0][i]=0;
    }
    
    for(int i=0;i<N;i++){
        for(int j=1;j<=W;j++){
            if(w[i]>j){
                dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
                if(j+w[i]<=W)dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
            }
            else{
                dp[i+1][j]=max(v[i],max(dp[i][j],dp[i+1][j]));
                if(j+w[i]<=W)dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
            }
        }
    }
    
    cout<<dp[N][W]<<endl;

    return 0;
}


Measured memory_bytes: 7092
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 305;
double dp[MAXN][MAXN][MAXN];
int n; 
double calc(int a, int b, int c)
{
    if (a == 0 && b == 0 && c == 0) return 0;
    double& x = dp[a][b][c];
    if (abs(x - 0) > 1e-9) return x;
    double m = (a + b + c);
    x = n / m;
    if (a) x += a/m * calc(a-1, b, c);
    if (b) x += b/m * calc(a+1, b-1, c);
    if (c) x += c/m * calc(a, b+1, c-1);
    return x;
}
int a[3];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a[x-1]++;
    }
    cout << setprecision(15) << fixed << calc(a[0], a[1], a[2]);
    return 0;
}

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

using namespace std;

int main(){
string S,T; cin >> S >> T;
  
  bool flag = false;
  
  for(int i = 0; i < S.size(); i++)
  {if(S == T){ flag = true; break;}
   
    S = S.back() + S.substr(0,S.size() - 1);}
  
  if( flag){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  
  return 0;}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
K = int(input())
count = 0
j = 1


while(A>=B):
    if(count<K):
        B *= 2
        count += 1
    else:
        j = 0
        break
while(C<=B):
    if(count<K):
        C *= 2
        count += 1
    else:
        j=0
        break
    
if(j == 1):
    print('Yes')
else:
    print('No')

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> a(n), b(n), c(n); cin >> a >> b >> c;
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans = 0;
    rep(i, n) {
        ll anum = lower_bound(all(a), b[i]) - a.begin();
        ll cnum = c.end() - upper_bound(all(c), b[i]);
        ans += anum * cnum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
n = int(input())
s = input()
ans = 0
for i in range(10):
  a = s.find(str(i))
  for j in range(10):
    b = s.find(str(j), a+1)
    for k in range(10):
      c = s.find(str(k), b+1)
      if a == -1 or b == -1 or c == -1:
        continue
      else:
        ans += 1
print(ans)

Measured memory_bytes: 9220
public class Main {
	public static void main(String[]args) {
		for(int i = 1 ; i <10; i++) {
			for(int j = 1; j <10 ; j++) {
				int ans = i * j;
				System.out.println(i + "x" + j + "=" + ans);
			}
		}
	}
}


Measured memory_bytes: 24436
#include <iostream>

int main() {
  char c;
  std::cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    std::cout << "vowel" << '\n';
  else
    std::cout << "consonant" << '\n';
  return 0;
}


Measured memory_bytes: 256
void main() {
    writeln(readln.chomp.count('9') ? "Yes" : "No");
}

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.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            var n = Line;
            if (n.Last() == '3')
            {
                System.Console.WriteLine("bon");
            }
            else if (n.Last() == '0' || n.Last() == '1' || n.Last() == '6' || n.Last() == '8')
            {
                System.Console.WriteLine("pon");
            }
            else
            {
                System.Console.WriteLine("hon");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 26172
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(long long *)a-*(long long *)b;
}

int main(void){
	int a=in(),b=in();
	if(a%3==0||b%3==0||(a+b)%3==0){
		puts("Possible");
	}
	else{
		puts("Impossible");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
const int mo=924844033;
const int N=2005;
int n,k,ans,las,vis[N];
int f[N][N][2],g[N],fac[N];
int main(){
	scanf("%d%d",&n,&k); f[0][0][0]=1;
	For(i,1,n) if (!vis[i]){
		int cnt=1,beg=(i<=k),ed,id=i; vis[i]=1;
		for (;id+2*k<=n;vis[id+=2*k]=1,cnt++);
		ed=(id+k<=n);
		For(j,0,las){
			UPD(f[las][j][beg],f[las][j][beg^1]);
			f[las][j][beg^1]=0;
		}
		For(j,1,cnt){
			las++;
			For(k,0,las-1){
				UPD(f[las][k+1][1],f[las-1][k][0]);
				UPD(f[las][k+1][1],f[las-1][k][1]);
				UPD(f[las][k+1][0],f[las-1][k][0]);
				UPD(f[las][k][0],f[las-1][k][0]);
				UPD(f[las][k][0],f[las-1][k][1]);
			}
		}
		For(j,0,las)
			if (!ed) f[las][j][1]=0;
	}
	For(i,0,n){
		g[i]=f[n][i][0];
		UPD(g[i],f[n][i][1]);
	}
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mo;
	For(i,0,n){
		g[i]=1ll*g[i]*fac[n-i]%mo;
		if (i&1) UPD(ans,mo-g[i]);
		else UPD(ans,g[i]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 30208
def solve():
    mod = 10**9+7
    N, K = map(int, input().split())
    ans = []
    combs1 = [1]*K
    combs2 = [1]*(K+1)
    for i in range(1,K):
        combs1[i] = combs1[i-1]*(K-i)*pow(i,mod-2,mod)%mod
    for i in range(1,K+1):
        combs2[i] = combs2[i-1]*(N-K+2-i)*pow(i,mod-2,mod)%mod
    for i in range(1,K+1):
        ans.append(combs1[i-1]*combs2[i]%mod)
    return ans
print(*solve(),sep='\n')

Measured memory_bytes: 41456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

template<typename T>
struct Edge {
    int from, to;
    T cost;
};

template<typename T>
using Edges = vector<Edge<T>>;

template<typename T>
struct Graph {
    vector<Edges<T>> g;
    Graph(int n): g(n) {}
    int size() { return g.size(); };
    bool add_edge(int from, int to, T cost = 1) {
        g[from].emplace_back((Edge<T>){ from, to, cost });
    }
};

template<typename T>
struct MST {
    T cost;
    Edges<T> edges;
};

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

template<typename T>
MST<T> kruskal(Edges<T> &edges, int V) {
    sort(begin(edges), end(edges), [](const Edge<T> &a, const Edge<T> &b) {
        return a.cost < b.cost;
    });
    UnionFind tree(V);
    T total = T();
    Edges<T> es;
    for(auto &e : edges) {
        if(tree.unite(e.from, e.to)) {
            total += e.cost;
            es.emplace_back(e);
        }
    }
    return { total, es };
}

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

    int v,e;
    cin>>v>>e;
    Edges<int> edges(e);
    for(int i=0;i<e;i++){
        int s,t,w;
        cin>>s>>t>>w;
        edges.emplace_back((Edge<int>){s,t,w});
        edges.emplace_back((Edge<int>){t,s,w});
    }
    cout<<kruskal<int>(edges,v).cost<<endl;
}


Measured memory_bytes: 7596
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string S;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
import math
M = int(input())
dc = [tuple(map(int, input().split())) for i in range(M)]


def func(a, b):
    return((a+b // 10) + (a+b)-10)


num = 0
for i in range(M):
    num += dc[i][1]*9 + dc[i][1]*dc[i][0]

print(math.ceil((num-18) / 9))


Measured memory_bytes: 23828
////**********CODED BY :- DURGESH KUMAR***************////
    #include<bits/stdc++.h>
    #define ff double
    #define endl "\n"
    #define ll long long
    #define pb push_back
    #define vi vector<int>
    #define mii map<int,int>
    #define pii pair<int,int>
    #define test ll t;cin>>t;while(t--)
    #define REP(i,n) for(int i=0;i<(n);i++)
    #define FOR(i,a,b) for(int i=(a);i<=(b);i++)
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
    #define M 1000000007
    using namespace std;
int main()
{
    ll n;
    cin>>n;
    cout<<pow(n,3)<<endl;
      return 0;
    }


Measured memory_bytes: 384
// Tazoe

#include <iostream>
using namespace std;

int main()
{
while(true){
	int n;
	cin >> n;
if(cin.eof())
break;
	int m = n%39;

	if(m==0){
		cout << "3C39" << '\n';
	}
	else if(m>=1&&m<=9){
		cout << "3C0" << m << '\n';
	}
	else{
		cout << "3C" << m << '\n';
	}
}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 




bool s[405][405];
bool used[405][405];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int main()
{
     ll n,m,d;
     cin>>n>>m>>d;
     ll t=(n-d);
     if(d!=0)t*=2;
     ld res=(double)(1.0*t/(1LL*n*n))*(m-1.0);
    cout<<fixed<<setprecision(10)<<res;
}



































Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main()
{
     long long t,i,j,n,l;
       
       string s,b;
       cin>>s;
       cin>>b;
       l=0;
       
       for(i=0;i<s.length();i++)
       {   
         if(s[i]!=b[i])
         l++;
         
       }
     
     cout<<l;
     
}
   

Measured memory_bytes: 3884
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include <cmath>

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

int main(void) {
    ll n;
    cin >> n;
    vll a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());

    double mid = a[0] / 2.0;

    double prev = 999999999.0f;
    ll ans = 0;
    for (int i = 1; i < n; ++i) {
        double diff = abs(a[i] - mid);
        if (diff < prev) {
            ans = a[i];
        }
        prev = diff;
    }
    cout << a[0] << " " << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<string>vec(N);
  set<string>se;
  for(int i=0;i<N;++i){
    cin>>vec.at(i);
    se.insert(vec.at(i));
  }
  cout<<se.size()<<endl;
}

Measured memory_bytes: 25176
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long n, k;
    cin >> n >> k;
    unsigned long long x;
    x = (n>k) ? n-k : k-n;
    if(x>k){
        x = x % k;
    }
    if(x > k-x){
        x=k-x;
    }
    cout << x << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

string S,T;

signed main(){
    cin>>S>>T;

    vector<string>latte;
    for(int i=0;i+T.size()<=S.size();i++){
        bool ok=true;
        for(int j=0;j<T.size();j++){
            if(S[i+j]=='?')continue;
            if(S[i+j]!=T[j])ok=false;
        }
        if(!ok)continue;

        string s=S;
        rep(j,T.size())s[i+j]=T[j];
        rep(j,s.size())if(s[j]=='?')s[j]='a';
        latte.pb(s);
    }
    if(latte.size()==0){
        cout<<"UNRESTORABLE"<<endl;
    }
    else{
        cout<<*min_element(all(latte))<<endl;
    }
    return 0;
}


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

using namespace std;

int n, m;
int correct[100100], pen[100100];

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") correct[p] = 1;
        else {
            if (correct[p]) continue;
            pen[p]++;
        }
    }
    int pens = 0, cor = 0;
    for (int i = 1; i <= n; i++) {
        if (correct[i]) {
            cor++;
            pens += pen[i];
        }
    }
    cout << cor << ' ' << pens << '\n';
}

Measured memory_bytes: 1024
#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 ALL(a) (a).begin(),(a).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using ll = long long;
using P = pair<long long, long long>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

const long long MOD = 1000000007;

struct Sieve {
  long long n;
  vector<long long> f, primes;
  Sieve(long long n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(long long x) { return f[x] == x;}
  vector<long long> factorList(long long x) {
    vector<long long> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<P> factor(long long x) {
    vector<long long> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, make_pair(fl[0], 0));
    for (long long p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

long long pow(long long a, long long key) {
  long long x = key;
  long long temp = 1;
  while(x > 0) {
    if(x & 1) {
      temp *= a;
      temp %= MOD;
    }
    a *= a;
    a %= MOD;
    x >>= 1;
  }
  return temp;
}


int main() {
  long long N;
  vector<long long> a;
  cin >> N;
  rep(i, N) {
    long long temp;
    cin >> temp;
    a.push_back(temp);
  }

  Sieve si(1000000);

  long long b[1000001] = {0};
  rep(i, N) {
    vector<pair<long long, long long>> factor = si.factor(a[i]);
    rep(j, factor.size()) {
      b[factor[j].first] = max(b[factor[j].first], factor[j].second);
    }
  }

  // vector<long long> factors(1000001, 0);
  // vector<long long> b(a);
  // b.erase(unique(ALL(b)), b.end());
  // for(const auto& bv : b)
  // {
  //   for(const auto& v : si.factor(bv))
  //   {
  //     factors[v.first] = max(factors[v.first], v.second);
  //   }
  // }
  long long lcm = 1;
  rep(i, 1000001) {
    lcm *= pow(i, b[i]);
    lcm %= MOD;
  }
  long long ans = 0;
  rep(i, N) {
    long long temp = 1;
    temp = lcm * pow(a[i], MOD-2);
    temp %= MOD;
    ans += temp;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

const ll p = 1e9+7;

int n, m, k, cond[25][25], bit[20];
ll dp[1<<20], dp2[1<<20];
vector<int> pre[1<<20];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> m >> k;
    n--;

    for (int i = 0; i < 25; ++i)
    	for (int j = 0; j < 25; ++j)
    		cond[i][j] = -1;

    for (int i = 0; i < k; ++i) {
    	int a, b, c;
    	cin >> a >> b >> c;
    	cond[a-1][b-1] = c;
    }

    dp[0] = 1;
    for (int j = 0; j < (1<<n); ++j) {
		for (int k = 0; k < n; ++k)
			if (((1<<k)&j) == 0)
				bit[k] = 0;
			else
				bit[k] = 1;
		vector<int> w;
    	for (int k = 0; k < n-1; ++k)
			if (bit[k] == 1 && bit[k+1] == 0)
				w.push_back(1<<k);
		int s = w.size();
    	vector<int> t(1<<s);
		for (int k = 1; k < (1<<s); ++k) {
			int y = __builtin_ctz(k);
			t[k] = w[y] + t[k-(1<<y)];
		}
		pre[j] = t;
    }

    for (int i = 0; i < m; ++i) {
    	memset(dp2, 0, sizeof(dp2));

    	for (int j = (1<<n)-1; j >= 0; --j) {
    		dp2[j] = dp[j];
    		int u = pre[j].size();
    		for (int k = 1; k < u; ++k) {
    			if (__builtin_popcount(k)%2 == 1)
    				dp2[j] = (dp2[j] + dp2[j + pre[j][k]]);
    			else
    				dp2[j] = (dp2[j] + p - dp2[j + pre[j][k]]);
    		}
    		dp2[j] %= p;
    	}

    	for (int j = 0; j < (1<<n); ++j) {
    		for (int k = 0; k < n; ++k)
    			if (((1<<k)&j) == 0)
    				bit[k] = 0;
    			else
    				bit[k] = 1;
    		if (j == 0)
    			continue;
    		int last = -1;
    		for (int k = 0; k < n; ++k)
    			if (bit[k] == 1)
    				last = k;
    		dp2[j] = (dp2[j] + dp2[j-(1<<last)])%p;
    	}

      	for (int j = 0; j < (1<<n); ++j) {
    		for (int k = 0; k < n; ++k)
    			if (((1<<k)&j) == 0)
    				bit[k] = 0;
    			else
    				bit[k] = 1;

    		for (int k = 0; k < n; ++k)
    			if (cond[i][k] != -1 && cond[i][k] != bit[k])
    				dp2[j] = 0;
    	}

    	for (int j = 0; j < (1<<n); ++j) {
    		dp[j] = dp2[j];
    	}
    }

    ll ans = 0;

    for (int i = 0; i < (1<<n); ++i)
    	ans = (ans + dp[i])%p;

   	cout << ans << endl;
}

Measured memory_bytes: 110336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
int gcf(int a, int b) {return (b == 0) ?  a : gcf(b, a%b);}
ll gcf(ll a, ll b) {return (b == 0) ? a : gcf(b, a%b);} 
int lcm(int a, int b) {return (a*b)/gcf(a, b);}
ll lcm(ll a, ll b) {return (a*b)/gcf(a, b);}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}

const int MAXN = 4001;
int n;
int hoa[3][MAXN]; 

ll llb(bool b) {
    return (ll) (int) b;
}

void solve() {
    cin >> n;
    string s; cin >> s;
    fo(i, 3) hoa[i][n] = 0;
    for(int j = n-1; j >= 0; j--) {
        fo(i, 3) hoa[i][j] = hoa[i][j+1];
        if (s[j] == 'R') hoa[0][j]++;
        else if (s[j] == 'G') hoa[1][j]++;
        else hoa[2][j]++;
    }
    
    ll ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            if (s[i] == s[j]) continue;
            int fk = 2*j-i;
            if (s[i] != 'R' && s[j] != 'R') ans += (ll) hoa[0][j+1] - llb(s[fk] == 'R');
            else if (s[i] != 'G' && s[j] != 'G') ans += (ll) hoa[1][j+1] - llb(s[fk] == 'G');
            else ans += (ll) hoa[2][j+1] - llb(s[fk] == 'B');
        }
    } 
    cout << ans;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
int main(){
	long double a,b;
	scanf("%Lf%Lf",&a,&b);
	ll c=a*b;
	printf("%lld",c);
	return 0;
} 

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,i,p=1;
  cin>>n;
  long long a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]==0)
    {
      cout<<"0"<<endl;
      return 0;
    }
  }
  for(i=0;i<n;i++)
  {
    if(a[i]<=1000000000000000000/p)
    {
      p=p*a[i];
    }
    else
    {
      cout<<"-1"<<endl;
      return 0;
    }
  }
  cout<<p<<endl;
  return 0;
}
    

Measured memory_bytes: 4388
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define rg register
using namespace std;
inline int read(){
	rg int x=0; 
	rg char c=getchar();
	while(c<'0'||c>'9') 
		c=getchar();
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x;
}
const int N=1e5+5;
int l,n,q,x[N],a,b;
int pre[N][20],ans;
inline int get_power(int k){
	int ans=1;
	while(k--) 
		ans<<=1;
	return ans;
}
void prework(){
	for(rg int i(0);i<n;++i)
		pre[i][0]=upper_bound(x,x+n,x[i]+l)-x-1;
	for(rg int i(1);i<20;++i)
		for(rg int j(0);j<n;++j)
			pre[j][i]=pre[pre[j][i-1]][i-1];
}
int main(){
	n=read();
	for(rg int i(0);i<n;++i)
		x[i]=read();
	l=read();
	prework();
	q=read();
	while(q--){
		a=read();
		b=read();
		ans=1;
		if(a>b)
			swap(a,b);
		--b; --a;
		while(pre[a][0]<b)
			for(rg int i(0);i<20;++i)
				if(pre[a][i]>=b){
					a=pre[a][i-1];
					ans+=get_power(i-1);
					break;
				}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 9088
# 2 ABC106 B 105

def factorization(n):
    ret = []
    i = 2
    if n == 1:
        return ret
    while i ** 2 <= n:
        while n % i == 0:
            n //= i
            ret.append(i)
        i += 1
    if n > 1:
        ret.append(n)
    return ret
    
n = int(input())
ans = 0
for i in range(1,n+1,2):
    _num = 0
    for j in range(1,i+1):
        if i % j == 0:
            _num += 1
    if _num == 8:
        ans += 1

print(ans)

Measured memory_bytes: 38640
#include<iostream>
using namespace std;
int main() {
    char a, b; cin >> a >> b;
    if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
        cout << 'H' << endl;
    } else {
        cout << 'D' << endl;
    }
}

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

using namespace std;

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

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

    for (int i = 0; i < k; i++) {
        vector<int> b(n + 1, 0);
        for (int j = 0; j < n; j++) {
            b[max(j - a[j], 0)]++;
            b[min(j + a[j] + 1, n)]--;
        }

        for (int j = 0; j < n; j++) {
            b[j + 1] += b[j];
        }

        for (int j = 0; j < n; j++) {
            a[j] = b[j];
        }

        if (*min_element(a.begin(), a.end()) == n) {
            break;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << (i == 0 ? "" : " ") << a[i];
    }
    cout << endl;
}


Measured memory_bytes: 4772
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int tmpmin=1e9;
int main(int argc,char const* argv[])
{
  int h,w;
  cin >> h >> w;
  int board[105][105];
  vector<string> check(h);
  for(int i=0;i<h;i++)
    {
      cin >> check[i];
    }
  for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
	{
	  if(check[i][j]=='#')
	    {
	      board[i][j]=1;
	    } 
	  else if(check[i][j]=='.')
	    {
	      board[i][j]=0;
	    } 
	}
    }
  for(int i=0;i<h;i++)
    {
      bool allw=true;
      for(int j=0;j<w;j++)
	{
	  if(board[i][j]==1) allw=false;
	}
      if(allw)
	{
	  for(int j=0;j<w;j++)
	    {
	      board[i][j]=2;
	    }
	}
    }
  for(int j=0;j<w;j++)
    {
      bool allw=true;
      for(int i=0;i<h;i++)
	{
	  if(board[i][j]==1) allw=false;
	}
      if(allw)
	{
	  for(int i=0;i<h;i++)
	    {
	      board[i][j]=2;
	    }
	}
    }
  for(int i=0;i<h;i++)
    {
      bool el=false;
      for(int j=0;j<w;j++)
	{
	  if(board[i][j]==0)
	    {
	      cout << '.';
	      el=true;
	    }
	  else if(board[i][j]==1)
	    {
	      cout << '#';
	      el=true;
	    }
	}
      if(el) cout << endl;
    }
}


Measured memory_bytes: 256