akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// DeleteElement returns a *NEW* slice, that have the same and minimum length and capacity.
// DeleteElement makes a new slice by using easy slice literal.
func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}
	// appendのみの実装
	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

// Concat returns a *NEW* slice, that have the same and minimum length and capacity.
func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

// copy function
//a = []int{0, 1, 2}
//b = make([]int, len(a))
//copy(b, a)

/*******************************************************************/

var a, b, c int

func main() {
	tmp := NextIntsLine()
	a, b, c = tmp[0], tmp[1], tmp[2]
	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

namespace AtCoder_Beginner_Contest_167
{
    class A
    {
        static void Main(string[] args)
        {
			var s = Console.ReadLine();
			var t = Console.ReadLine();

			if (s.Length == 0)
			{
				Console.WriteLine("No");
			}
			else if (t.Length - s.Length != 1)
			{
				Console.WriteLine("No");
			}
			else if (t.IndexOf(s) == 0)
			{
				Console.WriteLine("Yes");
			}
			else {
				Console.WriteLine("No");
			}
#if HELLO
			Console.ReadKey();
#endif
		}

		private static List<int> ReadIntListFrom_StringSplit(string s)
		{
			return
				s.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
				.Select(int.Parse)
				.ToList();
		}

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

		private static int[] ReadIntArray() => ReadIntArrayFrom_StringSplit(Console.ReadLine());

		private static int[] ReadIntArray(int size) => ReadIntArrayFrom_FixedSize(Console.ReadLine(), size);

		private static int[] ReadIntArrayFrom_StringSplit(string s) =>
				s.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
				.Select(int.Parse)
				.ToArray();


		private static int[] ReadIntArrayFrom_FixedSize(string s, int size)
		{
			var sLen = s.Length;
			var res = new int[size];
			var resIdx = 0;
			var start = 0;
			string ss;

			for (int i = 1; i <= sLen; i++)
			{
				if ((i == sLen || s[i] == ' '))
				{
					ss = s.Substring(start, i - start);
					{
						res[resIdx++] = int.Parse(ss);
						start = i + 1;
					}
				}
			}
			return res;
		}

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

		private static int ReadInt(string s) => int.Parse(s);

		private static int ReadInt() => int.Parse(Console.ReadLine());

		/////////

		static int Mod(int A, int n)
		{
			var a = A / n;
			if (A < 0)
			{
				return A - a * n + n;
			}
			else
			{
				return A - a * n;
			}
		}
	}
}


Measured memory_bytes: 26180
nm = gets.chomp.split
n = nm[0].to_i
m = nm[1].to_i

p_a = Array.new(n+1){Array.new(2, 0)}
m.times do
    ps = gets.chomp.split
    number = ps[0].to_i
    judge = ps[1]
    case judge
    when "AC"
        p_a[number][0] += 1
    when "WA"
        if p_a[number][0] == 0
            p_a[number][1] += 1
        end
    end
end

ac_count = 0
wa_count = 0
n.times do |i|
    if p_a[i+1][0] > 0
        ac_count += 1
        wa_count += p_a[i+1][1]
    end
end

puts ac_count.to_s + " " + wa_count.to_s

Measured memory_bytes: 9340
#include<stdio.h>
#include<string.h>

#define N 1007

char X[N],Y[N];
int c[N][N];

int L[N];

int m,n;

int LCSlength(char *,char *);

int  main(){
  int i,j,num;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%s",X+1);
    scanf("%s",Y+1);

    L[i] =  LCSlength(X,Y);

  }

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

  }


  return 0;


}



int LCSlength(char *X,char *Y){
  int m,n;
  int i,j;
  int max=0;

  m = strlen(X+1);
  n = strlen(Y+1);
  
  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=0;j<=n;j++) c[0][j] = 0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      
      if(X[i] == Y[j]){
	c[i][j] = c[i-1][j-1] + 1;
      }

      else if(c[i-1][j] >= c[i][j-1]){
	c[i][j] = c[i-1][j];
      }

      else c[i][j] = c[i][j-1];
      if(max < c[i][j]) max = c[i][j];      
    }
  }

  return max;

}
  
  



Measured memory_bytes: 5712
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ld pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld radian(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int x, a, b;
	cin >> x >> a >> b;
	a -= b;
	if (a >= 0)
		cout << "delicious\n";
	else if (a >= 0 - x)
		cout << "safe\n";
	else
		cout << "dangerous\n";
	getchar(); getchar();
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

ll n, a, b;

int main(){
	scanf("%lld%lld%lld", &n, &a, &b);
	if((b - a) & 1){
		ll ans = min(b - 1, n - a);
		ans = min(ans, a + ((b - a - 1) / 2));
		ans = min(ans, (n - b + 1) + (n - (a + (n + 1 - b))) / 2);
		printf("%lld\n", ans);
	}
	else{
		printf("%lld\n", (b - a) / 2);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"

typedef long long ll;
using namespace std;

//ll const N = 32000;

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

    string S;
    cin >> S;

    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R')
    {
        cout << 3;
        return 0;
    }
    
    else if((S[0] == 'R' && S[1] == 'R' && S[2] != 'R'))
    {
        cout << 2;
        return 0;
    }
    
    else if((S[1] == 'R' && S[2] == 'R' && S[0] != 'R'))
    {
        cout << 2;
        return 0;
    }
    
    else if(S[0] == 'R' || S[1] == 'R' || S[2] == 'R')
    {
        cout << 1;
        return 0;
    }
    else if(S[0] == 'S' || S[1] == 'S' || S[2] == 'S')
    {
        cout << 0;
    }

    return 0;
}


Measured memory_bytes: 3648
import heapq
N = int(input())
arr = list(map(int,input().split()))
arr = sorted(arr, reverse = True)
ans = 0
q = []
heapq.heappush(q, -arr[0])
#人１がすでに到着しているとしたら得られる値はa0に等しい
for n in range(1, N):
    tmp  = heapq.heappop(q)
    tmp *= -1
#優先度付きキューは最小値取り出すからー１かけて最大値取り出せるように
    ans += tmp  #各時点でのmin(ai,aj)の最大値を答えに足す
    heapq.heappush(q, -arr[n])
    heapq.heappush(q, -arr[n]) #新たに割り込める場所２個追加
print(ans)


Measured memory_bytes: 31660
package main

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

func solve() {
	n := getInt()
	as := make([]int, n)
	for i := range as {
		as[i] = getInt() - (i + 1)
	}
	sort.Ints(as)

	center := n / 2
	b := as[center]
	ans := 0
	for _, a := range as {
		ans += abs(a - b)
	}
	fmt.Fprintln(wr, ans)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
#define unique 1000000007;
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int n,m;
    lli ans,a=1,b=1; 
    cin>>n>>m;
    if(abs(n-m)>=2){
        ans=0;
    }
    else{
        rep(i,n){
            a*=(i+1);
            a=a%unique;
        }
        rep(i,m){
            b*=(i+1);
            b=b%unique;
        }
        if(abs(n-m)==1){
            ans=(a*b)%unique;
        }
        else{
            ans=(a*b)%unique;
            ans*=2;
        }
    }
    while(ans>=1000000007){
        ans=ans%unique;
    }
    cout<<ans;
}

Measured memory_bytes: 256
from itertools import permutations
import math
n,m = map(int,input().split())
G = [[] for i in range(n)]
ans = 0
for i in range(m):
  a,b = map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
for per in permutations(range(n)):
  if per[0] != 0:
    continue
  for i in range(n-1):
    if not (per[i+1]  in G[per[i]]):
      break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 8972
import bisect

n = int(input())
s = input()
ans = 0
INDEX = [list() for i in range(10)]
len_index = []
for key,i in enumerate(s):
  i = int(i)
  INDEX[i].append(key)
for i in INDEX:
  len_index.append(len(i))
for first in range(10):
  if len_index[first]:
    f = INDEX[first][0]
    for second in range(10):
      r = bisect.bisect_right(INDEX[second],f)
      if r < len_index[second]:
        s = INDEX[second][r]
        for third in range(10):
          t = bisect.bisect_right(INDEX[third],s)
          if t < len_index[third]:
            ans += 1
print(ans)

Measured memory_bytes: 39920
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;


int main(){
  int s[3];
  for(int i=0;i<3;i++){
    cin >> s[i];
  }
  sort(s,s+3);
  for(int i=0;i<2;i++){
    cout << s[i] << " ";
  }
  cout << s[2] << endl;
  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
#include <map>
#include <cstdio>
#include <stack>
using namespace std;
typedef long long ll;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

const int MAX_H = 60;
const int MAX_W = 60;

string str[MAX_H];
bool check[MAX_H][MAX_W];
int H,W;

int dfs(int x,int y){
    //printf("dfs(%d,%d)\n",x,y);
    check[y][x] = true;
    int cnt = 1;
    if(x+1 < W){//→
        if(str[y][x+1] == '#' && !check[y][x+1]) cnt += dfs(x+1,y);
    }
    if(x-1 >= 0){//←
        if(str[y][x-1] == '#' && !check[y][x-1]) cnt += dfs(x-1,y);
    }
    if(y+1 < H){//↓
        if(str[y+1][x] == '#' && !check[y+1][x]) cnt += dfs(x,y+1);
    }
    if(y-1 >= 0){//↑
        if(str[y-1][x] == '#' && !check[y-1][x]) cnt += dfs(x,y-1);
    }
    //cout << cnt << endl;
    return cnt;
}

int main(){
    int num = 0;
    rep(i,MAX_H){
        rep(j,MAX_W){
            check[i][j] = false;
        }
    }
    cin >> H >> W;
    rep(i,H){
        cin >> str[i];
    }
    rep(y,H){
        rep(x,W){
            if(str[y][x] == '#' && !check[y][x]){
                num = dfs(x,y);
                //cout << "ret:" << num << endl;
                if(num == 1){
                    cout << "No" << endl;
                    return 0;
                }
            }
            
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int num[]=new int[n];
for(int i=0;i<n;i++){
num[i]=sc.nextInt();
}
for(int i=n-1;i>=0;i-=2)System.out.print(num[i]+" ");
for(int i=n%2;i<n;i+=2)System.out.print(num[i]+" ");
}
}

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

int main() {
  std::string S, T;
  std::cin >> S >> T;
  int count = 0;
  for (std::size_t i = 0; i < S.size(); ++i) {
    count += S[i] != T[i];
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 3912
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

double distance(double x1, double y1, double x2, double y2)
{
	double dx = x1-x2;
	double dy = y1-y2;
	return sqrt(dx*dx+dy*dy);
}

int main()
{
	double x[4], y[4];
	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf\n"
		, x, y, x+1, y+1, x+2, y+2, x+3, y+3) != EOF)
	{
		bool f1 = x[0] == x[1] && y[2] == y[3]
		|| x[2] == x[3] && y[0] == y[1];

		double a[2];
		for (int i = 0; i < 2; ++i)
			a[i] = (y[2*i+1]-y[2*i])/(x[2*i+1]-x[2*i]);

		bool f2 = fabs(a[0]*a[1] + 1) <= 0.000001;

		if (f1 || f2)
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

Measured memory_bytes: 0
import queue, math
while True:
    n = int(input())
    if n == 0: break
    p = [[float(x) for x in input().split()] for _ in range(n)]
    g = [i for i in range(n)]

    def root(x):
        if x == g[x]: return x
        g[x] = root(g[x])
        return g[x]

    q = queue.PriorityQueue()
    cnt_g = n
    ans = 0.0
    for i in range(n-1):
        for j in range(i,n):
            d = math.sqrt((p[i][0]-p[j][0])**2 + (p[i][1]-p[j][1])**2 + (p[i][2]-p[j][2])**2)
            if d <= p[i][3] + p[j][3] :
                if root(i) != root(j):
                    g[root(i)] = root(j)
                    cnt_g -= 1
            else:
                q.put((d-p[i][3]-p[j][3],i,j))

    while not q.empty():
        if cnt_g <= 1 : break
        d, i, j = q.get()
        if root(i) != root(j):
            g[root(i)] = root(j)
            cnt_g-= 1
            ans += d

    print ('{:.3f}'.format(ans))




Measured memory_bytes: 7632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 107;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;
int a[maxN];
int cnt, c[2];

int main() {

	n = ri(), m = ri();

	if (m == 1) {
		int x = ri();
		if (x != 1) printf("%d\n2\n1 %d\n", x, x - 1);
		else printf("%d\n1\n%d\n", x, x);
		return 0;
	}

	rep (i, 1, m) {
		a[i] = ri();
		if (a[i] & 1) {
			if (cnt == 2) {
				puts("Impossible");
				return 0;
			}
			c[cnt++] = i;
		}
	}

	if (cnt >= 1) swap(a[1], a[c[0]]);
	if (cnt >= 2) swap(a[m], a[c[1]]);

	rep (i, 1, m) printf("%d%c", a[i], " \n"[i == m]);
	printf("%d\n", m - (a[1] == 1));
	rep (i, 1, m) {
		if (i == 1) {if (a[i] != 1) printf("%d ", a[i] - 1);}
		else if (i == m) printf("%d\n", a[i] + 1);
		else printf("%d ", a[i]);
	}

	return 0;
}


Measured memory_bytes: 128
N,M = map(int,input().split())
PS = []

T = [0] * (N + 1)
A = 0
W = [0] * (N + 1)

ans = [0,0]

for i in range(M):
  p,s = input().split()
  p = int(p)
  PS.append([p,s])

for i in range(M):
  p = PS[i][0]
  s = PS[i][1]

  if T[p] == 0:
    if s == "AC":
      A += 1
      T[p] = "AC"
    elif s == "WA":
      W[p] += 1
      T[p] = "WA"
      
  elif T[p] == "AC":
    continue

  elif T[p] == "WA":
    if s == "AC":
      T[p] = "AC"
      A += 1
    elif s == "WA":
      W[p] += 1

w = 0

for i in range(1,N + 1):
  if T[i] == "AC":
    w += W[i]
      
print(A,w)



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

const int MAX = 10000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int abs(int a){
	return a<0? -a:a;
}
void swap(int* a, int* b){
	int c = *a;
	*a=*b;
	*b=c;
}

int main(){
	COMinit();
	int x,y;
	cin >>x>>y;
	if (x<y)
		swap(&x,&y);

	if ((x+y)%3!=0){
		cout << 0;
		return 0;
	}

	int cy=((x+y)/3),cx=(x-cy);
	cout <<COM(cy,cx)<<endl;
}

Measured memory_bytes: 234624
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

K,X=LI()

for i in range(max(X-K+1, -1000000), min(X+K, 1000000)):
    print(i, end=" ")
print("")


Measured memory_bytes: 3188
#include<stdio.h>
int main(){
	int n,k;
	int i;
	int x,y[5],j=0,m;
	while(scanf("%d%d",&n,&k),n!=0 && k!=0){
		int a[100000]={0},u=0,sum=0,w=0,h=0;
		for(i=0;i<k;i++){
			scanf("%d",&x);
			if(x==0) h=1,u=1;
			else a[x-1]=x;
		}
		for(i=0;i<n;i++){
			if(a[i]!=0) sum++;
			else if(h==1) sum++,h=0,m=i+1;
			else{
				if(sum>w) w=sum;
				sum=0;
				if(u==1) h=1,i=m-1;
			}
	 	}
		if(sum>w) y[j]=sum,j++;
		else y[j]=w,j++;
		sum=0,w=0,h=0;
	}
	for(i=0;i<j;i++) printf("%d\n",y[i]);
	return 0;
}



Measured memory_bytes: 2120
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, l;
		String s[];
		
		n = sc.nextInt();
		l = sc.nextInt();	
		
		s = new String[n];
		
		for(int i = 0; i < n; ++i) {
			s[i] = sc.next();
		}
		
		for(int i = 0; i < n; ++i) {
			for(int j = i + 1; j < n; ++j) {
				if(s[i].compareToIgnoreCase(s[j])>0) {
					String tmp = s[i];
					s[i] = s[j];
					s[j] = tmp;
				}
			}
		}
		
		for(int i = 0; i < n; ++i) {
			System.out.print(s[i]);
		}
		System.out.println();
		
		sc.close();
		
	}

}


Measured memory_bytes: 25684
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int forward = Integer.parseInt(s.substring(0, 2));
        int back = Integer.parseInt(s.substring(2));

        String result = "NA";
        if (forward <= 12 && forward > 0 && back <= 12 && back > 0) {
            result = "AMBIGUOUS";
        } else if (back <= 12 && back > 0) {
            result = "YYMM";
        } else if (forward <= 12 && forward > 0) {
            result = "MMYY";
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 23636
a,b,k=map(int,input().split())
if a+k-1>=b-k+1:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)

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

typedef pair<int, string> PS;

bool cmp(PS &i, PS &j) {
  bool ret = i.first > j.first;
  if (i.first == j.first) {
    ret = i.second < j.second;
  }
  return ret;
}

int main() {

  int N;
  cin >> N;

  map<string, int> m;
  rep(i, N) {
    string s;
    cin >> s;

    decltype(m)::iterator it = m.find(s);
    if (it != m.end()) {
      int cnt = it->second;
      m.erase(s);
      m.emplace(s, cnt + 1);
    } else {
      m.emplace(s, 1);
    }
  }

  vector<pair<int, string>> p;
  for (auto kv : m) {
    p.push_back(make_pair(kv.second, kv.first));
  }
  sort(p.begin(), p.end(), cmp);

  int max = p[0].first;
  cout << p[0].second << endl;
  repi(i, 1, N) {
    if (p[i].first < max) break;
    cout << p[i].second << endl;
  }
}

Measured memory_bytes: 29680
#include <iostream> 
#include<string.h>
#include<stdio.h>
using namespace std;
long long cc( long  long  q, long long  p)
{

	if(q%p==0)
	{
		return p;
	}
	else
	return cc(p,q%p);
}
main()
{
	long long x,y,a[1000],b[1000];
	int i=0;
	while(scanf("%lld%lld",&x,&y)!=EOF)
	{
	  
		 a[i]=cc(x,y);
		 b[i]=x*y/a[i];
	     i++;	
	     
	    
	}
	for(int j=0;j<i;j++)
	{
		printf("%lld %lld\n",a[j],b[j]);
	}
}


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

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

Measured memory_bytes: 256
import numpy as np

n, k = list(map(int, input().split()))
a = 0

for i in range(k + 1, n + 1, 1):
    if k == 0:
        a += n ** 2
        break

    b, c, d= i - k, (n - k) // i, 0
    if i - 1 + i * c > n:
        d = i - 1 + i * c - n

    a += b * (c + 1) - d

print(a)


Measured memory_bytes: 14440
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
    int a, b, ans;
    cin >> a >> b;
    ans = max(a+b, a-b);
    ans = max(ans, a*b);
    cout << ans << endl;

}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vll a(n), b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  
  ll c=0, d=0;
  rep(i,n){
    if(a[i]<b[i]) c+=(b[i]-a[i])/2;
    else d+=a[i]-b[i];
  }
  if(c>=d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	string s[h + 1];
	for(int i = 0; i < h; i++)
	{
		cin >> s[i];
	}
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < s[i].size(); j++)
		{
			if(s[i][j] == '.')
			{
				int cnt = 0;
				for(int k = 0; k < 8; k++)
				{
					int ny = i + dy[k];
					int nx = j + dx[k];
					if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
					if(s[ny][nx] == '#') cnt++;
				}
				s[i][j] = cnt + 48;
			}
		}
	}
	for(int i = 0; i < h; i++)
	{
		cout << s[i] << endl;;
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        long n = stdin.nextLong();
        long x = stdin.nextLong();
        long ans = 3 * (n - gcd(x, n));
        System.out.println(ans);
    }

    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else {
            return gcd(b % a, a);
        }
    }
}


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

int main() {
    int n,m;
    cin>>n>>m;
    int ans=0;
    int na=(n*(n-1)/2);
    int ma=(m*(m-1)/2);
    ans+=na+ma;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int n,a[50],b[50],c[50],ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	    scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	    scanf("%d",&b[i]);
	for(int i=1;i<=n-1;i++)
	    scanf("%d",&c[i]);
	int now;
	for(int i=1;i<=n;i++)
	{
		ans=ans+b[a[i]];
		if(a[i]==now+1)
		    ans=ans+c[now];
		now=a[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

vector<vector<pair<ll,ll>>> edge(320);
vll d(320);

void dijkstra(ll s){
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> q;
    fill(all(d),INF);
    d[s]=(ll)0;
    q.push(mp(0,s));
    while(q.size()){
        auto p=q.top();q.pop();
        auto v=p.second;
        if(d[v]<p.first)continue;
        if(edge[v].size()==0)continue;
        for(auto e:edge[v]){
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                q.push(mp(d[e.first],e.first));
            }
        }
    }
}

int main(){
    int n;cin>>n;
    priority_queue<tuple<ll,int,int>,vector<tuple<ll,int,int>>,greater<tuple<ll,int,int>>> q;
    ll a;
    rep(i,n)rep(j,n){
        cin>>a;
        if(i>=j)continue;
        q.push(make_tuple(a,i+1,j+1));
    }
    ll x;int y,z;ll ans=(ll)0;
    while(q.size()){
        auto p=q.top();q.pop();
        x=get<0>(p);y=get<1>(p);z=get<2>(p);
        dijkstra(y);
        if(d[z]>x){//d[z]==INFでもok
            edge[y].push_back(mp(z,x));
            edge[z].push_back(mp(y,x));
            ans+=x;
        }
        else if(d[z]<x){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n;
	cin >> n;
	fcout << pow((n / 3.0), 3) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, x;
    scanf("%d %d %d", &a, &b, &x);
    if (x >= a && x - a <= b && x < a + b)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
}

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

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			int N = Integer.parseInt(br.readLine());
			Dice dice[] = new Dice[N];
			for(int i = 0; i < dice.length; i++)dice[i] = new Dice();

			int array[] = new int[6];

			for(int i = 0; i < N; i++){
				String str[] = br.readLine().split("\\s+");

				for(int k = 0; k < str.length; k++){
					array[k] = Integer.parseInt(str[k]);
				}

				dice[i].setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);
			}

			boolean FLG = true;

			for(int i = 0; i < N-1; i++){
				for(int k = i+1; k < N; k++){
					if(dice[i].equals(dice[k])){
						FLG = false;
						break;
					}
				}
				if(!FLG)break;
			}

			if(FLG){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Dice{

	private int number[];
	private int work[];
	private final String order = "NNNNWNNNWNNNENNNENNNWNNN";

	Dice(){
		number = new int[6];
		work = new int[6];
	}


	public void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	public int getTop(){
		return number[0];
	}

	public void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

	public boolean equals(Object object){

		if(object == this)return true;
		if(object == null)return false;
		if(!(object instanceof Dice))return false;

		Dice another = (Dice)object;

		boolean FLG;

		for(int i = 0; i < order.length(); i++){
			roll(order.charAt(i));
			FLG = true;
			for(int k = 0; k < 6; k++){
				if(this.number[k] != another.number[k]){
					FLG = false;
					break;
				}
			}
			if(FLG)return true;
		}

		return false;
	}
};



Measured memory_bytes: 26188
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a, b, c, d = inl()
if a + b > c + d:
    print('Left')
elif a + b < c + d:
    print('Right')
else:
    print('Balanced')


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ff first
#define ss second
const int maxn=1e5+5, mod=1e9+7;
// (a-b+mod)%mod
// cout<<setprecision(9)<<fixed<<ans<<endl;
// cout<<x<<" "<<flush;

int main()
{
    int n; string grid[305];
	cin>>n;
	for (int i=0; i<n; i++) cin>>grid[i];
	int ans = 0;
	for (int i=0; i<n; i++){
		bool is = true;
		for (int j=0; j<n&&is; j++){
			for (int k=j+1; k<n&&is; k++){
				
if (grid[j][(k+i)%n] != grid[k][(j+i)%n]) is = false;

			}
		}
		if (is) ans += n;
	}
	
cout<<ans<<endl;
    return 0;
}

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

const int N = 100 + 5; // Cantidad de elementos
const int V = 100000 + 5; // Suma máxima de valores (100*1000)

int n;
int w[N];
int v[N];
long long W;
bool vis[N][V];
long long memo[N][V];

long long DP(int pos, int val){
	if(pos == n){
		if(val == 0){
			return 0LL;
		}
		else return W+1; // No se pudo obtener el valor, damos una respuesta no valida
	}
	if(vis[pos][val]) return memo[pos][val];
	long long ans = DP(pos+1,val); // Inicializamos la respuesta con no tomar el elemento
	if(val >= v[pos]){
		ans = min(ans,w[pos] + DP(pos+1,val-v[pos])); // Tomamos el elemento, así que debemos formar val-v[pos] ahora y ya agregamos w[pos]
	}
	vis[pos][val] = true;
	return memo[pos][val] = ans;
}

int main(){
	scanf("%d %lld",&n,&W);
	int suma_de_valores = 0; // Maximo valor que podría ser obtenido
	for(int i=0; i<n; i++){
		scanf("%d %d",w+i,v+i);
		suma_de_valores += v[i];
	}
	/* Observación importante:
	 * No necesitamos memsetear el vis, dado que los elementos no cambian,
	 * así que los posibles valores formados se mantienen, no se descartan
	*/ 
	for(int i=suma_de_valores; i>=0; i--){ // Vamos del mas grande al menor
		if(DP(0,i) <= W){ // El primero valido es la respuesta
			cout << i << endl; 
			return 0; // Aca nomas cortamos xD
		}
	}
	return 0;
}


Measured memory_bytes: 90112
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        double a = (double) W * H / 2;
        int dup = 0;
        if(x*2==W && y*2==H) {
            dup = 1;
        }

        System.out.println(a + " " + dup) ;

    }

}


Measured memory_bytes: 21844
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        String original = sc.next();
        int firstIndex = original.indexOf("RL");
        int nowIndex = 0;

        StringBuilder builder = new StringBuilder();

        while (firstIndex >= 0) {

            // 左辺の計算
            String left = original.substring(nowIndex, firstIndex);

            for (int i = 0; i < left.length(); i++) {
                builder.append("0 ");
            }

            int rCount = 1;
            int lCount = 1;
            rCount += left.length() / 2;
            lCount += Math.ceil((double) left.length() / 2);

            // 右辺の計算
            int nextIndex = firstIndex + 2 > original.length() ? - 1 : original.substring(firstIndex + 2).indexOf("RL");
            String right = "";
            // 右辺が存在する
            if (firstIndex + 3 <= original.length() && original.substring(firstIndex + 2, firstIndex + 3).equals("L")) {
                // まだRLがある
                if (nextIndex >= 0) {
                    nextIndex += firstIndex + 2;
                    right = original.substring(firstIndex + 2, nextIndex);
                    right = right.replace("R", "");
                    nowIndex = firstIndex + 2 + right.length();
                } else {
                    // もうない
                    right = original.substring(firstIndex + 2);
                    right = right.replace("R", "");
                    nowIndex = firstIndex + 2;
                }
                lCount += right.length() / 2;
                rCount += Math.ceil((double) right.length() / 2);
            } else {
                nowIndex = firstIndex + 2;
                if (nextIndex >= 0) {
                    nextIndex += firstIndex + 2;
                }
            }

            builder.append(rCount).append(" ").append(lCount).append(" ");

            for (int i = 0; i < right.length(); i++) {
                builder.append("0 ");
            }
            firstIndex = nextIndex;
        }
        System.out.println(builder);
    }
}

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

int main(){
  char c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3;j++){
      cin >> c[i][j];
    }
  }
  cout << c[0][0] << c[1][1] << c[2][2] << endl;

  return 0;
   
}


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


using namespace std;

int main(){
	int n;
	
	while(cin>>n){
		vector<int> prime(n);
		int ptr=0;
		if(n<=3){
		switch(n){
		case 0:
		case 1: ptr=0; break;
		case 2: ptr=1; break;
		case 3: ptr=2; break;
		}
		}
		else{
			prime[ptr++]=2;
			prime[ptr++]=3;
		
		for(int no=5;no<=n;no+=2){
			int flag=0;
			for(int i=1;prime[i]*prime[i]<=no;i++){
		if(no%prime[i]==0){
				flag=1;
				break;
		}
	}
	if(!flag)
		prime[ptr++]=no;
	}
		}
		cout<<ptr<<endl;
	}
	
	
	
}

Measured memory_bytes: 5424
from itertools import permutations

N,M = map(int,input().split())
masu = [[0]*N for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    masu[a][b] = 1
    masu[b][a] = 1
ans = 0
for i in permutations(range(N)):
    if i[0] != 0:continue
    for j in range(N):
        if j==N-1:
            ans += 1
            break
        if not masu[i[j]][i[j+1]]:
            break
print(ans)

Measured memory_bytes: 9212
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=998244353;



int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    for(auto &I:a){cin>>I; sum+=I;}
    vector<vector<ll>> dp(sum+1,vector<ll>(3,0));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(ll t=sum;t>=0;t--){
            for(int h=0;h<3;h++){
                if(a[i]+t<=sum){
                    dp[t+a[i]][h]+=dp[t][h];
                    dp[t+a[i]][h]%=MOD;
                }
            }
            dp[t][2]*=2;
            dp[t][2]+=dp[t][1];
            dp[t][1]+=dp[t][0];
            dp[t][1]%=MOD;
            dp[t][2]%=MOD;
            dp[t][0]=0;
        }
    }
    ll ans=0;
    for(int t=1;t<=sum;t++){
        //cout<<t<<" "<<dp[t][2]<<endl;
        ans+=dp[t][2]*2;
        if(t*2>=sum){ans-=dp[t][2]*6;}
        ans%=MOD;
    }
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
using namespace std;
int main() {
	int h1, h2, k1, k2, a, b, c, d,hh,kk;
	cin >> h1 >> h2;
	cin >> k1 >> k2;
	cin >> a >> b >> c >> d;
	hh = h1 * a;
	kk = k1 * a;
	hh = hh + h2 * b;
	kk = kk + k2 * b;
	hh = hh + (h1 - h1 % 10) / 10 * c;
	kk = kk + (k1 - k1 % 10) / 10 * c;
	hh = hh + (h2 - h2 % 20) / 20 * d;
	kk = kk + (k2 - k2 % 20) / 20 * d;
	if (hh > kk) {
		cout << "hiroshi" << endl;
	}
	if (hh < kk) {
		cout << "kenjiro" << endl;
	}
	if (hh == kk) {
		cout << "even" << endl;
	}
}


Measured memory_bytes: 3104
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math
def inpl(): return list(map(int, input().split()))

#### START
N, M = map(int,input().split())

all_li = []
for i in range(N):
  li = list(map(int,input().split()))[1:]
  all_li.extend(li)

c = collections.Counter(all_li)

cnt = 0
for i, size in c.most_common():
  if size == N:
    cnt += 1
  else:
    break

print(cnt)

Measured memory_bytes: 3316
n,A,B,C = map(int,input().split())
l = list(int(input())for _ in range(n))
def dfs(depth,a,b,c):
    if depth == n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30  if min(a,b,c) >0 else 10**9
    x = dfs(depth+1,a,b,c)
    y = dfs(depth+1,a+l[depth],b,c) +10
    z = dfs(depth+1,a,b+l[depth],c) +10
    w = dfs(depth+1,a,b,c+l[depth]) +10
    return min(x,y,z,w)
print(dfs(0,0,0,0))
    
        

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    cin>>N;
    ll Minim=N-1;
    rep1(i, sqrt(N)+1){
        if(N%i==0){
            Minim=min(Minim, (i-1)+(N/i-1));
        }
    }
    cout<<Minim<<endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

per=[i for i in range(2,N+1)]
permu=[]
for i in itertools.permutations(per):
    lst=[1]
    lst.extend(i)
    permu.append(lst)
num=0
for lst in permu:
    can=True
    for i in range(N-1):
        if not([lst[i],lst[i+1]] in ab) and not([lst[i+1],lst[i]] in ab):
            can=False
            break
    if can:
        num+=1
print(num)


Measured memory_bytes: 43244