akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let s: String = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        sc.next()
    };
    let s = s.as_bytes();
    println!("{}", 700 + f(s[0]) + f(s[1]) + f(s[2]));
}

fn f(b: u8) -> u32 {
    if b == b'o' {
        100
    } else {
        0
    }
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
import std.stdio;
import std.string;
import std.conv;


int main()
{
	string s;
	while((s = readln()).length != 0)
	{
		int count = 0;
		int number = to!(int)(chomp(s));
		foreach(int i;0..10)
		{
			foreach(int j;0..10)
			{
				foreach(int k;0..10)
				{
					foreach(int l;0..10)
					{
						if(i+k+j+l == number) count++;
					}
				}
			}
		}
		writeln(count);
	}
	return 0;
}

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


void solve(long long A, long long B){
    int ans = A - 2 * B;
    cout << max(ans, 0) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

#define CMAX 15
#define DMAX 30
#define WMAX 50
#define XMAX 5

#define max(a,b) (a>b?a:b)

int main() {
  int c, d, w, x, ans;
  int dp[DMAX+1][XMAX+1][WMAX+1];
  int e[CMAX][DMAX], f[CMAX][DMAX];
  while(cin >> c >> d >> w >> x && c+d+w+x) {
    for(int i=0; i<c; ++i) for(int j=0; j<d; ++j) cin >> e[i][j];
    for(int i=0; i<c; ++i) for(int j=0; j<d; ++j) cin >> f[i][j];
    for(int j=0; j<x+1; ++j) for(int k=0; k<w+1; ++k) dp[0][j][k] = 0;
    for(int i=0; i<d; ++i) {
      for(int j=0; j<x+1; ++j) for(int k=0; k<w+1; ++k) {
          dp[i+1][j][k] = dp[i][j][k];
        }
      for(int s=0; s<c; ++s) {
        int sume = 0, sumf = 0;
        for(int t=s; t<c; ++t) {
          if(e[t][i]==0) break;
          sume += e[t][i]; sumf += f[t][i];
          if(s==t) {
            for(int j=sumf; j<w+1; ++j) for(int k=0; k<x+1; ++k) {
                dp[i+1][k][j] = max(dp[i+1][k][j], dp[i][k][j-sumf]+sume);
              }
          }else {
            for(int j=sumf; j<w+1; ++j) for(int k=0; k<x; ++k) {
                dp[i+1][k+1][j] = max(dp[i+1][k+1][j], dp[i][k][j-sumf]+sume);
              }
          }
        }
      }
    }
    ans = 0;
    for(int i=0; i<x+1; ++i) for(int j=0; j<w+1; ++j) {
        ans = max(ans, dp[d][i][j]);
      }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
n=int(input());w=[input()for i in range(n)]
def sortex(X):
  b=sorted(X)
  b.append("null")
  a=[]
  for i in range(len(X)):
    if b[i]!=b[i+1]:a.append(b[i])
  return a
if len(w)!=len(sortex(w)):
  print("No")
  exit()
for i in range(len(w)-1):
  if w[i][-1]!=w[i+1][0]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N,A,B;
ll h[100100];

bool C(ll n){
  ll cnt = 0;
  rep(i,N){
    ll tmp = h[i];
    tmp -= n*B;
    if(tmp>0){
      cnt += (tmp+(A-B)-1)/(A-B);
    }
    /*
    */
  }
    //cerr << n << " " << cnt << endl;
  if(cnt <= n) return true;
  return false;
}
int main(){
  cin >> N >> A >> B;
  rep(i,N){
    cin >> h[i];
  }
  ll l= 0,r= 1001001001;
  ll mid = (r+l)/2;
  rep(_,500){
    if(C(mid)){
      r = mid;
    }
    else{
      l = mid;
    }
    mid = (l+r)/2;
  }
  cout << r << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
 
ll M = pow(10,18);
 
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
int main(int argc, const char * argv[]) {

    
    ll N; cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for(ll i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }
    
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    
    ll ans;
    if(N%2==0){
        ans = B[N/2]+B[N/2 - 1] - (A[N/2]+A[N/2 - 1]) + 1;
    }else{
        ans = B[N/2] - A[N/2] + 1;
    }
    
    cout << ans << endl;
    
    
    
}



Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  ll n;
  cin >> n;
  ll m = n;

  int ans = 0;
  int cnt = 0;
  for(int i = 2; i<=sqrt(m); i++){
    int e = 0;
    while(n%i == 0){
      e++;
      n /= i;
    }
    if(e != 0){
      int cnt = -1;
      int j = 1;
      int sumj = 0;
      while(e >= sumj){
        cnt++;
        sumj += j;
        j++;
      }
      ans += cnt;
    }
  }

  if(n != 1) ans++;
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define max(a,b) (a > b ? a : b)

int main(){
	int n;
	long res = 0;
	cin >> n;
	int g[10][10] = {0};
	for(int i=1;i<=n;++i){
		string s = to_string(i);
		int l = s.length();
		int h = s[0] - '0';
		int t = s[l-1] - '0';
		g[h][t]++;
	}
	for(int i=1;i<10;++i){
		for(int j=0;j<10;++j){
			res += g[i][j] * g[j][i];
		}
	}
	cout << res << endl;
}

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

using namespace std;

void printState( int val ) {
  for ( int i = 6; i >= 0; i-- ){
	if ( val & ( 1 << i ) ) {
	  cout << 1;
	} else {
	  cout << 0;
	}
  }
  cout << endl;
}

int main() {

  array<int, 10> table = {{
	  0b111111, 0b110, 0b1011011, 0b1001111, 0b1100110,
	  0b1101101, 0b1111101, 0b100111, 0b1111111, 0b1101111
	}};
  
  while ( true ){
	int n;
	cin >> n;
	if ( n <= 0 ) break;
	
	int state = 0;
	for ( int i = 0; i < n; i++ ) {
	  int nval;
	  cin >> nval;
	  printState( state ^ table[ nval ] );
	  state = table[ nval ];
	}	
  }
}

Measured memory_bytes: 1160
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	N := getInt()
	M := getInt()

	s := make([]int, M)
	c := make([]int, M)

	for i := 0; i < M; i++ {
		s[i] = getInt() - 1
		c[i] = getInt()
	}

	result := make([]int, N)
	for i := 0; i < N; i++ {
		result[i] = -1
	}

	for i := 0; i < M; i++ {
		if N != 1 && s[i] == 0 && c[i] == 0  {
			fmt.Println(-1)
			return
		}

		if result[s[i]] != -1 {
			if result[s[i]] != c[i] {
				fmt.Println(-1)
				return
			}
		}

		result[s[i]] = c[i]
	}

	str := ""
	for i := 0; i < N; i++ {
		if result[i] == -1 {
			if N != 1 && i == 0 {
				str += "1"
			} else {
				str += "0"
			}
		} else {
			str += strconv.Itoa(result[i])
		}
	}

	fmt.Println(str)
}

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

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p % 2 == 0 {
		t := powMod(n, p / 2)
		return calcMod(t * t)
	} else {
		return n * powMod(n, p - 1)
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,k;cin>>a>>b>>c>>k;
  ll ans = 0;
  if(k > a){
    k-=a;
    ans += a;
  }else{
    cout<<k<<endl;
    return 0;
  }
  if(k > b){
    k-=b;
  }else{
    cout<<ans<<endl;
    return 0;
  }
  cout<<ans-k<<endl;

  return 0;
}


Measured memory_bytes: 3640
void main() {
	alias Point = Tuple!(int, "x", int, "y");

	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	Point[] students;
	Point[] checks;

	foreach(i; 0..N) {
		auto ip2 = readAs!(int[]);
		students ~= Point(ip2[0], ip2[1]);
	}
	foreach(i; 0..M) {
		auto ip3 = readAs!(int[]);
		checks ~= Point(ip3[0], ip3[1]);
	}
	foreach(i; students) {
		ulong min_p = 0;
		foreach(ind, j; checks) {
			if(abs(checks[min_p].x - i.x) + abs(checks[min_p].y - i.y) > abs(j.x - i.x) + abs(j.y - i.y)) {
				min_p = ind;
			}
		}
		(min_p+1).writeln;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;


ll ccc[200005];

int main()
{
    ll N;
    vector<int> A;
    cin >> N;
    

    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        A.push_back(a);
        ccc[a]++;
    }

    ll ans =0;
    for(int i=1;i<=N;i++){
        if(ccc[i]>=2){
            ans += ccc[i] * (ccc[i]-1)/2;
        } 
    }


    for(int k=0;k<N;k++){
        ll a= A[k];
        ll b = ccc[a];
        ll c=0;
        if ( b-1 > 0){
            c = (ccc[a] -1)* (ccc[a]-2)/2;
        }

        cout << ans - ccc[a] * (ccc[a]-1)/2 + c << endl;  // +  (ccc[a] -1)* (ccc[a]-2)/2 << endl ;

    }

    

    return 0;
}

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

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

  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else if(S == "Rainy"){
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		Console.WriteLine("2018"+s.Substring(4));
	}

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 11092
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

long int ni(long int a){
	if(a%2 ==1) return 0;
	else return ni(a/2)+1;
}

int main (){
	int NNN;
	cin >> NNN;
	long int a[NNN];
	int sum =0;
	rep(i,NNN){
		cin >> a[i];
		sum += ni(a[i]);
	}
	cout << sum ;

	cout << endl;


	return 0;
}


Measured memory_bytes: 384
#include<queue>
#include<cctype>
#include<cstdio>

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

using namespace std;

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

struct state{
	int x,y,u,S; // u: 今一階か二階か, S: 押したスイッチの集合
	state(int x,int y,int u,int S):x(x),y(y),u(u),S(S){}
};

int main(){
	int W,H; scanf("%d%d",&W,&H);
	char B[50][51];
	rep(i,H) scanf("%s",B[i]);

	int m; scanf("%d",&m);
	char sw[10][50][51];
	rep(k,m) rep(i,H) scanf("%s",sw[k][i]);

	int sx,sy,gx,gy;
	rep(i,H) rep(j,W) {
		if(B[i][j]=='%') sx=j, sy=i, B[i][j]='_';
		if(B[i][j]=='&') gx=j, gy=i, B[i][j]='_';
	}

	static int dp[50][50][2][1<<10];
	rep(x,W) rep(y,H) rep(k,2) rep(S,1<<m) dp[x][y][k][S]=INF;
	dp[sx][sy][0][0]=0;

	int ans=-1;
	queue<state> Q; Q.push(state(sx,sy,0,0));
	while(!Q.empty()){
		int x=Q.front().x,y=Q.front().y,u=Q.front().u,S=Q.front().S; Q.pop();

		if(x==gx && y==gy){ ans=dp[x][y][u][S]; break; }

		// 同じ階の隣接マスへの移動
		rep(k,4){
			int xx=x+dx[k],yy=y+dy[k];
			int u2=(B[yy][xx]=='^'||isupper(B[yy][xx])?1:0); // (xx,yy) が今何階にあるか
			rep(i,m) if(S&1<<i && sw[i][yy][xx]=='*') u2=1-u2;
			if(B[yy][xx]=='|') u2=u; // 階段にはどちらの階からも行ける

			if(B[yy][xx]=='#' || u2!=u) continue; // (xx,yy) に進入できない

			if(dp[xx][yy][u][S]>dp[x][y][u][S]+1){
				dp[xx][yy][u][S]=dp[x][y][u][S]+1;
				Q.push(state(xx,yy,u,S));
			}
		}
		// 階段の上り下り
		if(B[y][x]=='|'){
			if(dp[x][y][1-u][S]>dp[x][y][u][S]+1){
				dp[x][y][1-u][S]=dp[x][y][u][S]+1;
				Q.push(state(x,y,1-u,S));
			}
		}
		// スイッチを押す
		if(isalpha(B[y][x])){
			int id=tolower(B[y][x])-'a';
			int u2=u;
			int S2=S^(1<<id);
			if(sw[id][y][x]=='*') u2=1-u2;

			if(dp[x][y][u2][S2]>dp[x][y][u][S]+1){
				dp[x][y][u2][S2]=dp[x][y][u][S]+1;
				Q.push(state(x,y,u2,S2));
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 21580
#!/usr/bin/env python3
#ABC112 C

n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]

maxh = 0
for x,y,h in xyh:
    maxh = max(maxh,h)
for H in range(maxh,maxh+201):
    for cx in range(101):
        for cy in range(101):
            for x,y,h in xyh:
                if h != max(H-abs(x-cx)-abs(y-cy),0):
                    break
            else:
                print(cx,cy,H)
                quit()


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

using namespace std;
int main(){
  double a,b;
  cin >> a >> b;
  if(a>b){
    cout << "GREATER" << endl;
  }
  else if(a<b){
    cout << "LESS" << endl;
  }
  else if(a==b){
    cout << "EQUAL" << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int a[9];
    bool c[9];
    rep(i,3){
        cin >> a[3*i] >> a[3*i+1] >> a[3*i+2];
        c[3*i] = false;
        c[3*i+1] = false;
        c[3*i+2] = false;
    }
    int n;
    cin >> n;
    int b[n];
    rep(i,n){
        cin >> b[n];
        rep(j,9){
            if(a[j] == b[n]){
                c[j] = true;
            }
        }
    }
    bool ok = false;
    rep(i,3){
        if(c[3*i]&&c[3*i+1]&&c[3*i+2]){
            ok = true;
        }
        if(c[i]&&c[3+i]&&c[6+i]){
            ok = true;
        }
    }
    if(c[0]&&c[4]&&c[8]){
        ok = true;
    }
    if(c[2]&&c[4]&&c[6]){
        ok = true;
    }
    if(ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main(void) {

	int D, N;

	std::cin >> D >> N;

	int ans = 0;
	int base = 0;
	if (D == 0) {
		// unable to divide by 100
		base = 1;
	} else {
		base = std::pow(100, D);
	}

	int by = (N % 100) != 0 ? N: N + 1;
	ans = base * by;

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



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}












const int limit = 51;
int n,m;
bool vec[limit][limit];
bool vis[limit];

void DFS(int x){
    if(vis[x]) return;

    vis[x] = true;

    REP(i,n){
        if(vec[i][x]){
            DFS(i);
        }
    }
}
using namespace std;
int main(){
    int n,ans = 0;
    cin >> n;

    vector<int> vec(n);

    REP(i,n){
        cin >> vec[i] ;
    }

    SORT(vec);

    REP(i,vec[n-1]){
        if(vec[n/2 -1] <= i && i < vec[n/2]) ans ++;
    }

    cout << ans <<endl;
}

Measured memory_bytes: 768
while True:
 
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
 
    print()


Measured memory_bytes: 7004
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
// #define base 100001
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld:\n", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const int N = 300010;
ll s, v, t;
int solve() {
	cin>>s>>t>>v;
	if(s<=v*t){
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return solve();
}

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

void input(int& rnNum, int& rnTrg, vector<int>& rvnCandls)
{
  cin >> rnNum >> rnTrg;
  rvnCandls.resize(rnNum);

  for (int& rnCandls : rvnCandls)
    cin >> rnCandls;
}

int calcMinPutonTime(int nNum, int nTrg, const vector<int>& cnrvnCandls)
{
  int nMinPutonTime = INT_MAX;
  int nLeft = 0;
  int nRigt = nLeft + nTrg - 1;

  while ( nLeft < nNum &&
          nRigt < nNum    )
  {
    int nPutonTime =  min( abs(cnrvnCandls[nLeft]), abs(cnrvnCandls[nRigt]) )
                    + cnrvnCandls[nRigt] - cnrvnCandls[nLeft];
    nMinPutonTime = min(nMinPutonTime, nPutonTime);

    ++nLeft;
    ++nRigt;
  }
  return nMinPutonTime;
}
 
int main()
{
  int nNum, nTrg;
  vector<int> vnCandls;

  input(nNum, nTrg, vnCandls);
  cout << calcMinPutonTime(nNum, nTrg, vnCandls) << endl;

  return 0;
}

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

#define MOD 1000000007
typedef unsigned long long ull;

int n;

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

  int sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (i != j) {
        sum += d[i] * d[j];
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#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_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
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=1000000007;




int main(){
    ll mx=100100;
    vector<map<ll,ll>> A(mx,map<ll,ll>());
    for(int i=1;i<mx;i++){
        A[i][1]=1;
        for(auto t=A[i].begin();t!=A[i].end();++t){
            for(ll h=2;i*h<mx;h++){
                A[i*h][t->first+1]+=t->second;
            }
        }
    }
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=A[i][k];
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}



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

using namespace std;

int main( void )
{
	string str;

	cin >> str;

	if ( (str[2] == str[3]) && (str[4] == str[5]) ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

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

  int a, b;
  cin >> a >> b;

  cout << (a - 1) * (b - 1) << '\n';

  return (0);
}


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

#define ll long long

int main(){

	ll N,M;
  	cin >> N >> M;
  	long long A,B;
  	vector<pair<ll,ll>> pairs(N);
  	for(int i = 0; i < N ; i++){
    	cin >> A >> B;
    	pairs[i]=make_pair(A,B);
    }
  	
  	sort(pairs.begin(),pairs.end());
  	long long sum = 0;

  	for(int i = 0;i<N;i++){
      	if(M>=pairs[i].second){
			sum = sum + pairs[i].first*pairs[i].second;
          	M=M-pairs[i].second;
        }else{
        	sum = sum + (M)*pairs[i].first;
          	M=0;
          	break;
        }
      	
    }
	
  	cout<< sum << endl;

}

Measured memory_bytes: 1792
#include <stdio.h>
#define MAX 110000
int p[MAX];
int prime[13000];
int c;
void hurui(){
  int i,j;
  for(i=0;i<MAX;i++)p[i]=1;
  p[0]=0;p[1]=0;c=0;
  for(i=2;i<MAX;i++){
    //printf("%d\n",i);
    if(p[i]==1){
      prime[c++]=i;
      for(j=2*i;j<MAX;j+=i)p[j]=0;
    }
  }

}
int main(){
  int i,n;
  hurui();
  long long int s;
  while(1){
    s=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++)s+=prime[i];
    printf("%lld\n",s);
  }
  return 0;
}

Measured memory_bytes: 1072
import string
import collections

n = int(input())
s = []
for i in range(n):
  s.append(input())

d = {}
for a in string.ascii_lowercase:
  d[a] = 100
#print(d)

for si in s:
  c = collections.Counter(si)
  # print(c)
  for a in string.ascii_lowercase:
    if a in d:
      d[a] = min(c[a],d[a])
    else:
      d[a] = 0
ans = []
for dk,dv in d.items():
  for i in range(dv):
    ans.append(dk)
print(''.join(ans))

Measured memory_bytes: 74808
S = input()

div = ["dream", "dreamer", "erase", "eraser"]

S_rev = ""
div_rev = []

S_rev = S[::-1] #reverse input string
for i in range(4):
    div_rev.append(div[i][::-1]) #reverse divider words

str_len = len(S)
div_len = 0
cnt = 0
temp = cnt
flag = True

while(cnt < str_len):
    temp = cnt
    for j in range(4):
        div_len = len(div_rev[j])
        if(S_rev[cnt:(cnt+div_len)] == div_rev[j]):
            cnt += div_len
    if(temp == cnt):
        flag = False
        break

if(flag == True):
    print("YES")
else:
    print("NO")



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

    if(n==1 && m==1){
        cout << 1;
    }
    else if(n==1){
        cout << m-2;
    }
    else if(m==1){
        cout << n-2;
    }
    else{
        cout << (m-2)*(n-2);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
int a,b;
  cin >>a>>b;
  int ans =0;
  for(int i=a;i<=b;i++){
   if(i/10000==i%10 && (i-(i/10000)*10000)/1000 == (i - (i/100)*100)/10) ans++; 
  }
  cout <<ans <<endl;
}
  


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


int main() {
    int ABCD;
    cin>>ABCD;
    for(int tmp=0;tmp<(1<<3);tmp++){
        bitset<3> op(tmp);
        int sum=0,abcd=ABCD;
        for(int i=0;i<3;i++){
            if(op.test(i)){
                sum+=abcd%10;
            }
            else{
                sum-=abcd%10;
            }
            abcd/=10;
        }
        sum+=abcd;
        if(sum==7){
            cout<<ABCD/1000;
            if(op.test(2)){
                cout<<'+';
            }
            else{
                cout<<'-';
            }
            cout<<(ABCD%1000)/100;
            if(op.test(1)){
                cout<<'+';
            }
            else{
                cout<<'-';
            }
            cout<<(ABCD%100)/10;
            if(op.test(0)){
                cout<<'+';
            }
            else{
                cout<<'-';
            }
            cout<<ABCD%10<<"=7"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;


int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL A,P;
	LL ans = 0;

	cin >> A >> P;

    ans = (A*3+P)/2;

	cout  << ans << endl;

	return 0;

}


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

int main(){
  string s;
  cin >> s;
  
  int l = s.size();
  long long ans = 0;
  long long cntb = 0;
  for(int i = 0; i < l; i++){
    if(s.at(i) == 'B') cntb++;
    if(s.at(i) == 'W') ans += cntb;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
def wari(x,y) 
n = x%y;re = 0
n === 0 ? re = x/y : re = (x/y)+1
return re
end

a,b,c,d = $stdin.gets.chomp.split(' ').map(&:to_i)
takaatk = wari(c,b)
aoatk = wari(a,d)


if takaatk <= aoatk
puts "Yes"
  else
puts "No"
end

Measured memory_bytes: 14280
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    long long n,a[200005];
    cin>>n;
    long long ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i!=0){
            if(a[i-1]>a[i]){
                ans+=a[i-1]-a[i];
                a[i]=a[i-1];
            }
        }
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 5152
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

constexpr int INF = 1e9+7;
constexpr ll INFL = 9*1e18;

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

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

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
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; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}


// TODO: write
int main() {
  #define int ll
  
  ll n,x,m;cin>>n>>x>>m;
  vector<ll> a;
  
  a.pb(x);
  map<ll,int> tmp;
  tmp[x]++;
  ll begin = -1;
  for(int i = 0;;i++){
    if(tmp[a[i]*a[i]%m]){
      begin = a[i]*a[i]%m;
      break;
    }
    a.pb(a[i]*a[i]%m);
    if(a[i+1] == 0){
      print(SUM(a));
      return 0;
    }
    tmp[a[i+1]]++;
  }
  
  vector<ll> b;
  ll ans = 0;
  bool exist = false;
  rep(i,min((ll)a.size(),n)){
    if(begin == a[i])exist = true;
    if(exist){
      b.pb(a[i]);
    }else{
      ans += a[i];
    }
  }
  if(!b.size() || a.size() >= n){
    print(ans + SUM(b));
    return 0;
  }
  
  n -= a.size() - b.size();
  ans += (n / b.size()) * SUM(b);
  rep(i,n%b.size()){
    ans += b[i];
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 7452
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n,a[N];
struct node { int l,r,p; };
bool operator <(node x,node y) { return a[x.p]>a[y.p]; }
priority_queue<node> Q;

#define ls (o<<1)
#define rs (o<<1|1)
struct SGT {
	int minv[N<<2],type;
	int cmp(int x,int y) { return a[x]<a[y]?x:y; }
	void pushup(int o) { minv[o]=cmp(minv[ls],minv[rs]); }
	void build(int o,int l,int r) {
		if (l==r) { minv[o]=(l&1)==type?l:0; return; }
		int mid=(l+r)>>1;
		build(ls,l,mid),build(rs,mid+1,r);
		pushup(o);
	}
	int query(int o,int l,int r,int ql,int qr) {
		if (ql<=l&&r<=qr) return minv[o];
		int mid=(l+r)>>1,res=0;
		if (ql<=mid) res=cmp(res,query(ls,l,mid,ql,qr));
		if (qr>mid) res=cmp(res,query(rs,mid+1,r,ql,qr));
		return res;
	}
} t[2];
#undef ls
#undef rs

int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	a[0]=1e9;
	t[0].type=0,t[0].build(1,1,n);
	t[1].type=1,t[1].build(1,1,n);
	Q.push((node){1,n,t[1].query(1,1,n,1,n)});
	for (int i=1;i<=(n>>1);++i) {
		int l=Q.top().l,r=Q.top().r,lx=Q.top().p; Q.pop();
		int rx=t[(lx&1)^1].query(1,1,n,lx,r);
		printf("%d %d ",a[lx],a[rx]);
		if (l<lx) Q.push((node){l,lx-1,t[l&1].query(1,1,n,l,lx-1)});
		if (lx<rx) Q.push((node){lx+1,rx-1,t[(lx&1)^1].query(1,1,n,lx+1,rx-1)});
		if (rx<r) Q.push((node){rx+1,r,t[(rx&1)^1].query(1,1,n,rx+1,r)});
	}
	puts("");
	return 0;
}

Measured memory_bytes: 9920
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import depth_first_order

MOD = 10**9 + 7

N = int(readline())
XY = list(map(int,read().split()))

graph = csr_matrix(([1]*(N-1),(XY[::2],XY[1::2])),(N+1,N+1))
dfs_order, par = depth_first_order(graph,1,directed=False)
dfs_order = dfs_order.tolist()
par = par.tolist()

subtree_size = [1] * (N+1)
is_cent = [True] * (N+1)

for v in dfs_order[::-1]:
    if subtree_size[v] < (N+1)//2:
        is_cent[v] = False
    p = par[v]
    if p < 0:
        break
    if subtree_size[v] > N//2:
        is_cent[p] = False
    subtree_size[p] += subtree_size[v]

centroid = [v for v in range(1,N+1) if is_cent[v]]
Ncent = len(centroid)

if Ncent == 1:
    c = centroid[0]
    sizes = [N-subtree_size[c]] + [subtree_size[v] for v in range(1,N+1) if par[v] == c]
else:
    sizes = [N//2,N//2]

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

fact,fact_inv = make_fact(N+100,MOD)

def create_component_arr(n):
    x = np.full(n+1,fact[n],dtype=np.int64)
    x *= fact_inv[n::-1]; x %= MOD
    x *= x; x %= MOD
    x *= fact_inv[:n+1]; x %= MOD
    x[1::2] *= (-1); x %= MOD
    return x

def convolve(x,y):
    Lx = len(x); Ly = len(y)
    if Lx < Ly:
        Lx,Ly = Ly,Lx
        x,y = y,x
    z = np.zeros(Lx+Ly-1,np.int64)
    for n in range(Ly):
        z[n:n+Lx] += x*y[n]%MOD
    return z%MOD

x = np.array([1],np.int64)
for s in sizes:
    x = convolve(x,create_component_arr(s))

if Ncent == 1:
    answer = (x * fact[N:0:-1] % MOD).sum() % MOD
else:
    answer = (x * fact[N::-1] % MOD).sum() % MOD
print(answer)

Measured memory_bytes: 17536
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int64_t a, b; cin >> a >> b;
  auto c = boost::integer::gcd(a, b);
  ull ans{1};
  if(c % 2 == 0){
    ++ans;
    while(c % 2 == 0)
      c /= 2;
  }
  for(int64_t i = 3; i*i <= c; i += 2){
    if(c % i != 0){
      continue;
    }
    ++ans;
    while (c % i == 0){
      c /= i;
    }
  }
  if(c != 1) ++ans;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll N, K;
  cin >> N >> K;
  ll ans = min(N%K,K-N%K);
  
  cout << ans <<endl;
  return 0;
}




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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  cout << B + min(A + B + 1, C) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int []h = new int[N];
		for(int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(h);
		int e = Integer.MAX_VALUE;

		for(int i = 0; i <= N - K; i++) {
			int t = h[i + K - 1] - h[i];
			//System.out.println(h[i]);
			e = Math.min(e, t);
		}
		System.out.println(e);
	}
}

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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if (a+b==c+d)
	   cout << "Balanced" << endl;
	else if(a+b>c+d)
	   cout << "Left" << endl;
	else
	   cout << "Right" << endl;
	   
	return 0;
}

Measured memory_bytes: 256
import sys
import math


def input():
    return sys.stdin.readline()[:-1]


def main():
    n, d = map(int, input().split())
    x = []
    ans = 0
    for i in range(n):
        x.append([int(i) for i in input().split()])

    for a in range(0, n-1):
        for c in range(a+1, n):
            s = 0
            for b in range(d):
                s += abs(x[a][b]-x[c][b])**2
            if math.floor(math.sqrt(s)) == math.sqrt(s):
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	const string yaku[] = {
		"null", "one pair", "two pair", "three card", "straight",
		"full house",	"four card" };
//	cut here before submit 
//	freopen("testcase.ph", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		string res = "";
		if (str.empty() ){
			break;
		} // end if
		while (str.find(',') != string::npos ){
			str = str.replace(str.find(','), 1, " ");
		} // end while
		stringstream ss(str);
		vector <int> card (5, 0);
		int i,j;

		for (i = 0; i < 5; ++i){
			ss >> card[i];
		} // end for
		sort (card.begin(), card.end() );

//		for (i = 0; i < 5; ++i){
//			cout << card[i] << ' ';
//		} // end for
//		cout << endl;

		for (j = 0; j < 4; ++j){
			if (card[j + 1] == card[j] + 1){
				continue;
			}else{
				break;
			} // end if
		} // end for
		if (j == 4){
			res = yaku[4];	// "straight"
//			goto result;
		} // end if
		if (card[0] == 1 && card[1] == 10){
			for (j = 1; j < 4; ++j){
				if (card[j + 1] == card[j] + 1){
					continue;
				}else{
					break;
				} // end if
			} // end for
			if (j == 4){
				res = yaku[4];	// "straight"
//				goto result;
			} // end if
		} // end if
		if (res.empty() ){

			set <int> Card;
			for (i = 0; i < 5; ++i){
				Card.insert (card[i]);
			} // end for
//			set <int>::iterator it = Card.begin();
//			for (; it != Card.end(); ++it){
//				cout << *it << ' ';
//			} // end for
//			cout << endl;
//			cout << "card kind: " << Card.size() << endl;

			if (Card.size() == 5){
				res = yaku[0];		// null
			}else if (Card.size() == 4){
				res = yaku[1];		// one pair
			}else if (Card.size() == 3){
//				res = yaku[2];
				map<int, int> D;
				for (i = 0; i < 5; ++i){
					++D[card[i]];
				} // end for
				int maxnum = 0;
				map<int, int>::iterator it = D.begin();
				for (; it != D.end(); ++it){
					if (maxnum < (*it).second ){
						maxnum = (*it).second;
					} // end if
				} // end for
				if (maxnum == 2){
					res = yaku[2];	// two pair
				}else if (maxnum == 3){
					res = yaku[3];	// three card 
				} // end if

			}else{	// if (Card.size() == 2)
				map<int, int> D;
				for (i = 0; i < 5; ++i){
					++D[card[i]];
				} // end for
				int maxnum = 0;
				map<int, int>::iterator it = D.begin();
				for (; it != D.end(); ++it){
					if (maxnum < (*it).second ){
						maxnum = (*it).second;
					} // end if
				} // end for
				if (maxnum == 3){
					res = yaku[5];	// full house
				}else if (maxnum == 4){
					res = yaku[6];	// four card
				} // end if
			} // end if
		} // end if

		if (!res.empty() ){
			cout << res << endl;
		} // end if
	} // end while
		
	return 0;
}

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

int main() {
  vector<ll> t(2), a(2), b(2), d(2);
  cin >> t[0] >> t[1] >> a[0] >> a[1] >> b[0] >> b[1];

  for (int i = 0; i < 2; i++) d[i] = t[i] * a[i] - t[i] * b[i];
  for (int i = 0; i + 1 < 2; i++) d[i + 1] += d[i];

  if (d[1] == 0) {
    cout << "infinity" << endl;
    return 0;
  } else if (d[1] < 0) {
    for (int i = 0; i < 2; i++) d[i] = -d[i];
  }

  if (d[0] > 0) {
    cout << 0 << endl;
  } else {
    cout << -d[0] / d[1] * 2 + int(-d[0] % d[1] != 0) << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,M;
double a[22][3];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N>>M;
	rep(i,N)rep(j,3){
		cin>>a[i][j];
	}
	double ans=0;
	rep(mask,1<<N)if(__builtin_popcount(mask)==M){
		double res=0;
		rep(i,N)if(mask>>i&1)rep2(j,i+1,N)if(mask>>j&1){
			rep(k,3)res+=pow(a[i][k]-a[j][k],2);
		}
		ans=max(ans,res);
	}
	cout<<fixed<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 1308
n = gets.to_i

r = (0...n).map { |i|
    x, l = gets.split(' ').map(&:to_i)
    [x - l, x + l]
  }.sort_by { |x| x[1] }

answer = 0
t = -100_000_001
(0...n).each do |i|
  if r[i][0] >= t
    answer += 1
    t = r[i][1]
  end
end

puts answer

Measured memory_bytes: 12664