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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
    if (ch == 'A') {
        return 1;
    } else if (ch == 'C') {
        return 2;
    } else if (ch == 'G') {
        return 3;
    } else if (ch == 'T') {
        return 4;
    }
}

// 文字列から数値へ変換してkeyを生成する
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

// ハッシュ関数（1）
int hash1(int key) {
    return key % M;
}

// ハッシュ関数（2）
int hash2(int key) {
    return 1 + (key % (M - 1));
}

// findコマンド実行時
int find(char str[]) {
    long long key, i, h;
    key = getKey(str);

    for (i = 0;; i++) {
        h = (hash1(key) + i * hash2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

// insertコマンド実行時
int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);

    for (i = 0; ; i++) {
        h = (hash1(key) + i * hash2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(void)
{
    int i, n, h, j = 0;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';

    scanf("%d", &n);
    int findReply[n];
    for (i = 0; i < n; i++) findReply[i] = -1;

    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);

        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                findReply[j++] = 1;
            } else {
                findReply[j++] = 0;
            }
        }
    }

    i = 0;
    while (findReply[i] != -1) {
        
        if (findReply[i] == 1) {
            printf("yes\n");
        } else if (findReply[i] == 0) {
            printf("no\n");
        }
        i++;
    }

    return 0;
}


Measured memory_bytes: 19956
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    }
    let mut b=0;
    for i in 1..a{
        b+=(a-1)/i;
    }
    println!("{}",b)
}

Measured memory_bytes: 2136
#[allow(unused_imports)]
use std::cmp::max;
use std::io;

fn main() {
    let input = input_number();
    let n = input[0] as usize;
    let mut ai: Vec<i64> = Vec::new();
    let mut bi: Vec<i64> = Vec::new();
    let mut ci: Vec<i64> = Vec::new();

    for _ in 0..n {
        let input = input_number();
        ai.push(input[0]);
        bi.push(input[1]);
        ci.push(input[2]);
    }

    let mut dpa = vec![i64::max_value(); n];
    let mut dpb = vec![i64::max_value(); n];
    let mut dpc = vec![i64::max_value(); n];

    for i in 0..n {
        if i == 0 {
            dpa[i] = ai[i];
            dpb[i] = bi[i];
            dpc[i] = ci[i];
            continue;
        }

        dpa[i] = ai[i] + max(dpb[i - 1], dpc[i - 1]);
        dpb[i] = bi[i] + max(dpa[i - 1], dpc[i - 1]);
        dpc[i] = ci[i] + max(dpb[i - 1], dpa[i - 1]);
    }

    println!("{}", max(max(dpa[n - 1], dpb[n - 1]), dpc[n - 1]));
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (char, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: char = iter.next().unwrap().chars().nth(0).unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    (c, n)
}


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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
    }

    let ans: i32 = *[a * 10 + b + c, a + b * 10 + c, a + b + c * 10]
        .iter()
        .max()
        .unwrap();

    println!("{}", ans);
}


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

int main() {
    ll n, sum = 0;
    cin >> n;
    rep(i, n) {
        if((i + 1) % 3 == 0) {
            continue;
        } else if((i + 1) % 5 == 0) {
            continue;
        } else {
            sum += i + 1;
        }
    }
    cout << sum << endl;
    return 0;
}

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



/*void swapchar(char *p1,char*p2){
    char p;
     p=*p1;
    *p1=*p2;
    *p2=p;
}*/
void rollstr(char *p,int psize){
    char pz;
    for(int i=0;i<psize;i++){
        if(i==0){
            pz=*p;
            p[0]=*(p+1);
        }
        else if(i==psize-1){
            p[psize-1]=pz;
        }
        else {
            p[i]=p[i+1];
        }
    }
}
int main(){
   
    
    string s;
    string p;
    cin>>p;
    cin>>s;
    
    int psize=p.size();
    int ssize=s.size();
    
    //swapchar(&p[1],&p[2]);
    //cout<<p;
   
    
    for(int i=0;i<psize;i++){
    rollstr(&p[0],p.size());
        int ans=0;
        
        for(int j=0;j<ssize;j++){
            if(s[j]==p[j]){
                ans++;
            }
            if(ans==ssize){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        
        
        
    }
    cout<<"No"<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3224
def solve():
    max_weight, list_of_weight_and_value = read()
    result = think(max_weight, list_of_weight_and_value)
    write(result)
 
 
def read():
    n, max_weight = read_int(2)
    list_of_weight_and_value = []
    for i in range(n):
        list_of_weight_and_value.append(read_int(2))
    return max_weight, list_of_weight_and_value
 
 
def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]
 
 
def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]
 
 
def think(max_weight, list_of_weight_and_value):
    MAX_WEIGHT = 10 ** 5
    MAX_N = 100
    INVALID_VALUE = MAX_WEIGHT * MAX_N + 1
 
    # dp[w] means max value at total weight 'w'
    dp = [INVALID_VALUE for x in range(max_weight + len(list_of_weight_and_value) + 1)]
    dp[0] = 0
 
    for weight, value in list_of_weight_and_value:
        for i in range(len(dp) - 1, -1, -1):
            if dp[i] != INVALID_VALUE and i + weight < len(dp):
                if dp[i + weight] == INVALID_VALUE:
                    dp[i + weight] = dp[i] + value
                else:
                    dp[i + weight] = max(dp[i + weight], dp[i] + value)
    return max(filter(lambda x: x != INVALID_VALUE, dp[:max_weight + 1]))
 
 
def write(result):
    print(result)
 
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 44784
#include <cstdio>
using namespace std;
int n, m, q, l, r, d[505][505];
int main() {
	int i, j;
	scanf("%d%d%d", &n, &m, &q);
	while(m--) scanf("%d%d", &l, &r), d[l][r]++;
	for(i=1; i<=n; i++) for(j=1; j<=n; j++) d[i][j] += d[i][j-1];
	for(i=1; i<=n; i++) for(j=1; j<=n; j++) d[i][j] += d[i-1][j];
	while(q--) {
		scanf("%d%d", &l, &r);
		printf("%d\n", d[r][r] - d[l-1][r] - d[r][l-1] + d[l-1][l-1]);
	}
	return 0;
}

Measured memory_bytes: 1792
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]
 
A = [0]
B = [0]
C = [0]
for i in range(N):
    a = abc[i][0] + max(B[-1], C[-1])
    b = abc[i][1] + max(A[-1], C[-1])
    c = abc[i][2] + max(A[-1], B[-1])
    A += [a]
    B += [b]
    C += [c]
print(max(A[-1], B[-1], C[-1]))

Measured memory_bytes: 109388
N = gets.chomp.to_i
l = gets.split.map(&:to_i)

l.sort!
ans = 0
size = l.size - 1
size.times do |i|
  (i+1).step(size) do |j|
     upper = l[i] + l[j]
     ans += (l.bsearch_index {|x| x >= upper }&.-(1) || size) - (j + 1) + 1
  end
end

p ans

Measured memory_bytes: 1788
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
  boolean result = false;
int D;
int T;
int S;
  
  Scanner scan = new Scanner(System.in);
        String in = scan.nextLine();

String[] ins = in.split(" ");
D = Integer.parseInt(ins[0]);
T = Integer.parseInt(ins[1]);
S = Integer.parseInt(ins[2]);
result = (D <= T*S);
String output;
if(result){
  output = "Yes";
}else{
  output = "No";
}
System.out.println(output);
  
};
}


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

int main()
{
    long long N;
    cin >> N;

    if (N % 2 != 0)
    {
        cout << 0 << endl;
        exit(0);
    }

    long long ans = 0, den = 10;

    while (N >= den)
    {
        ans += N / den;
        den *= 5;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#define MOD 1000000007LL
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	for(int i = 0; i < a; i++){
		string s;
		cin >> s;
		cout << s << endl;
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

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

void Main() {
    int A, B; cin >> A >> B;
    if(1 <= A && A <= 9 && 1 <= B && B <= 9){
      cout << A * B << endl;
    }else{
      cout << -1 << endl;
    }
}

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

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

  Main();
}


Measured memory_bytes: 8064
local n,a,b,c,d=io.read("*n","*n","*n","*n","*n","*l")
local s=io.read()

if c<d then
    local flag=true
    for i=a,c-1 do
        if s:sub(i,i+1)=="##" then
            flag=false
        end
    end
    for i=b,d-1 do
        if s:sub(i,i+1)=="##" then
            flag=false
        end
    end
    print(flag and "Yes" or "No")
elseif c>d then
    local flag=true
    for i=a,c-1 do
        if s:sub(i,i+1)=="##" then
            flag=false
        end
    end
    for i=b,d-1 do
        if s:sub(i,i+1)=="##" then
            flag=false
        end
    end
    if flag then
        flag=false
        for i=b-1,d-1 do
            if s:sub(i,i+2)=="..." then
                flag=true
            end
        end
    end
    print(flag and "Yes" or "No")
end

Measured memory_bytes: 760
Scanf.scanf "%d %d %d %s" (fun n a b s ->
    let rec loop i pass passb =
        if i = n then () else
        if pass < a + b && s.[i] <> 'c' then (
            if s.[i] = 'a' then (print_endline "Yes"; loop (i + 1) (pass + 1) passb) else
                if passb < b then (print_endline "Yes"; loop (i + 1) (pass + 1) (passb + 1))
                else (print_endline "No"; loop (i + 1) pass passb)
        ) else (print_endline "No"; loop (i + 1) pass passb)
    in
    loop 0 0 0
)

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

int main() {
	int a;
	int b;
	int c;

	cin >> a >> b >> c;
	
	int i;
	int yaku;
	
	yaku = 0;

	for(i = a;i <= b;i++){
		if (c % i == 0) {
			yaku = yaku + 1;
		}
	}

	cout << yaku << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(){
  int chg, i, j;
  char pw1[51], pw2[51];
  scanf("%s", pw1);
  scanf("%s", pw2);
  chg=i=j=0;
  do{
    switch (chg){
     case 0:
       printf("%c", pw1[i]);
       i++;
       break;
     case 1:
       printf("%c", pw2[j]);
       j++;
       break;
    }
    if (chg==0){
      chg=1;
    }else if(chg==1){
      chg=0;
    }
  }while (pw1[i]!='\0'||pw2[j]!='\0');
    printf("\n");

  return 0;
}


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

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

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

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

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

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

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

class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll N;
	cin >> N;

	ll ans = 0;
	repn(i, N) {
		ans += (N-1) / i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n;
  string s,t;
  cin >> n >> s >> t;
  rep(i,n){
    cout << s[i] << t[i];
  }
  cout << endl;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {

  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N * A, B) << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split(' '))
K = []
S = []
for i in range(m):
    l = list(map(int, input().split(' ')))
    K.append(l[0])
    S.append(l[1:])
p = list(map(int, input().split(' ')))
ans = 0
for i in range(2**n):
    light = 0
    for j in range(m):
        sw = 0
        for s in S[j]:
            if (i>>(s-1))&1:
                sw += 1
        if sw%2 == p[j]:
            light+=1
    if light == m:
        ans += 1
print(ans)

Measured memory_bytes: 9096
/*input
a
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=3e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    char a;
    cin>>a;
    cout<<(char)(a+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
typedef pair<string, string> PS;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    // vector<PS> vs;
    map<PS, int> mp;
    for(int mask = 0; mask < (1LL << n); mask++){
        string r = "", b = "";
        rep(i, 0, n){
            if(mask & (1LL << i)){
                r += s[n + i];
            }else{
                b += s[n + i];
            }
        }
        mp[{r, b}]++;
    }
    int ans = 0;
    for(int mask = 0; mask < (1LL << n); mask++){
        string r = "", b = "";
        rep(i, 0, n){
            if(mask & (1LL << i)){
                r += s[i];
            }else{
                b += s[i];
            }
        }
        // vs.push_back({r, b});
        reverse(r.begin(), r.end());
        reverse(b.begin(), b.end());
        ans += mp[{b, r}];
    }
    cout << ans << endl;
}

Measured memory_bytes: 87040
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var array = ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long H = array[0];
        long W = array[1];
        bool[,] field = new bool[W+2, H+2];
        for (int i = 0; i < W+2; i++)
        {
            field[i, 0] = false;
            field[i, H + 1] = false;
        }
        for (int j = 1; j < H+1; j++)
        {
            field[0, j] = false;
            field[W + 1, j] = false;
        }
        for (long i = 1; i < H+1; i++)
        {
            var line = ReadLine().Select(x=>x=='#').ToArray();
            for (long j = 0;j<W;j++)
            {
                field[j+1, i] = line[j];
            }
        }
        //for (int i = 0; i < H+2; i++)
        //{
        //    /* テスト */
        //    for (int j = 0; j < W+2; j++)
        //    {
        //        if (field[j, i]) Write('#');
        //        else Write('.');
        //    }
        //    Write("\n");
        //}
        /* 4連結を調べる */
        for (int i = 1; i < H+1; i++)
        {
            for (int j = 1; j < W+1; j++)
            {
                if (field[j,i]&&!(field[j - 1, i] || field[j, i - 1] || field[j + 1, i] || field[j, i + 1]))
                {
                    WriteLine("No");
                    return;
                }
            }
        }
        WriteLine("Yes");
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
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;
  }

}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, deque
N = int(input())
w = defaultdict(int)
edge = [[] for _ in range(N + 1)]

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    w[str(a) + "_" + str(b)] = c
    w[str(b) + "_" + str(a)] = c
    edge[a].append(b)
    edge[b].append(a)

Q, K = map(int, input().split())

root = K
done = [True for _ in range(N + 1)]
done[root] = False
d = [0 for _ in range(N + 1)]
q = deque([root])

while q:
    parent = q.pop()
    for child in edge[parent]:
        if done[child]:
            key = str(parent) + "_" + str(child)
            done[child] = False
            d[child] = d[parent] + w[key]
            q.append(child)

for _ in range(Q):
    x, y = map(int, input().split())
    print(d[x] + d[y])

Measured memory_bytes: 57724
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
#define LL long long
const int mod = 1e9 + 7;
int n;
LL x[N], pre[N], suf[N], D[N];
int fac[N], inv[N];
int read(){
    int x = 0, fl = 1;
    char ch = getchar(); 
    while(ch > '9' || ch < '0')fl = (ch == '-' ? -1 : fl), ch = getchar();
    while(ch >= '0' && ch <= '9')x = 10 * x + ch - 48, ch = getchar();
    return x * fl;
}
inline int M(int x, int y){
    return 1LL * x * y % mod;
}
inline int A(int x, int y){
    return x + y - (x + y >= mod ? mod : 0);
}
inline int C(int n, int m){
    if(n > m)return 0;
    return M(fac[m], M(inv[n], inv[m-n]));
}
int main(){
    inv[0] = inv[1] = fac[1] = fac[0] = 1;
    for(int i = 2;i <= 1e5; i++){
        fac[i] = M(fac[i-1], i);
        inv[i] = mod - M(mod / i, inv[mod%i]);
    }
    for(int i = 1;i <= 1e5; i++){
        inv[i] = M(inv[i], inv[i-1]);
    }
    cin>>n;
    for(int i = 1;i <= n; i++){
        x[i] = read();
        pre[i] = pre[i-1] + x[i];
    }
    for(int i = n - 1;i >= 1; i--){
        suf[i] = suf[i+1] + x[i];
    }
    int ans = 0;
    for(int k = 1;k <= n - 2; k++){
        D[k] = suf[k+1] - pre[n-1-k];
        //printf("k=%d Dk=%lld\n", k, D[k]);
        D[k] %= mod;
        ans = A(ans, M(C(k + 1, n - 1), M(fac[k-1], M(D[k], fac[n-1-(k+1)]))));
    }
    for(int i = 1;i <= n - 1; i++){
        ans = A(ans, M(fac[n-i-1], M(fac[i-1], M(C(n - i, n - 1), x[n] - x[i]))));
        //printf("xn=%d xi=%d facn-i-1=%d faci-1=%d C(n-i,n-1)=%d\n", x[n], x[i], fac[n-i-1], fac[i-1], C(n - i, n - 1));
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <deque>
#include <bits/stdc++.h>
#define P  pair<int,int>
using namespace std;
const vector<int> di{-1,0,1,0};
const vector<int> dj{0,-1,0,1};

int main(){
  int H, W;
  cin >> H >> W;
  int Ch, Cw, Dh, Dw;
  cin >> Ch >> Cw >> Dh >> Dw;
  vector<vector<char>> S(H+1, vector<char>(W+1));
  vector<vector<int>> num(H+1, vector<int>(W+1,-1));;
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
      cin >> S.at(i).at(j);
    }
  }
  num.at(Ch).at(Cw) = 0;
  deque<P> q;
  q.push_front(make_pair(Ch,Cw));
  while(!q.empty()){
    int i, j;
    tie(i, j) = q.front();
    q.pop_front();
    for(int v=0; v<4; v++){
      int ni = i+di.at(v);
      int nj = j+dj.at(v);
      P nij = make_pair(ni, nj);
      if(ni<1||ni>H) continue;
      if(nj<1||nj>W) continue;
      if(S.at(ni).at(nj)=='#') continue;
      if(num.at(ni).at(nj)<0
         ||num.at(ni).at(nj)>num.at(i).at(j)){
        num.at(ni).at(nj) = num.at(i).at(j);
        q.push_front(nij);
      }
    }
    for(int ii=-2; ii<3; ii++){
      for(int jj=-2; jj<3; jj++){
        int ni = i+ii;
        int nj = j+jj;
        P nij = make_pair(ni, nj);
        if(ni<1||ni>H) continue;
        if(nj<1||nj>W) continue;
        if(S.at(ni).at(nj)=='#') continue;
        if(num.at(ni).at(nj)<0){
          num.at(ni).at(nj) = num.at(i).at(j)+1;
          q.push_back(nij);
        }
      }
    }
  }
  cout << num.at(Dh).at(Dw);
  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  bitset<6> bs(s);
  cout << bs.count() << endl;
  
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//总体原理：让大的数据分几个小组，逐渐有序
public class Main {
	private static int cnt = 0;
	private static void  insertI(int[] a, int g) {//给每一个间隔为g的组排序
		//g为第一个组的第二个元素
		for (int i = g; i < a.length; ++i) {//组不一定规则
			int v = a[i];
			int j = i - g;//寻找前一个元素
			//从小到大排序
			
			while (j >= 0 && a[j] > v) {//索引存在，且当前索引指向的值大于插入值
				a[j + g] = a[j];//当前j被空下来
				j -= g;//找到组中的前一个元素
				cnt++;
			}
			a[j + g] = v;
		}
		
		System.out.print(g);
		if (g == 1)
			System.out.println();
		else
			System.out.print(" ");
	}

	private static void shellSort(int[] a, List<Integer> G) {
		for (int i = G.size() - 1; i >= 0; --i) //增量逐渐减小必定有1
			insertI(a, G.get(i));
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i)
			a[i] = scan.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int h = 1;;) {
			if (h > n) break;
			list.add(h);
			h = 3 * h + 1;
		}
		System.out.println(list.size());
		shellSort(a, list);
		
		//show(list);
		System.out.println(cnt);
		for (int i : a)
			System.out.println(i);
	}
}



Measured memory_bytes: 299208
#include<stdio.h>
int main(){
  int a[4];
  int n;
  scanf("%d",&n);
  a[0] = (n-n%1000)/1000;
  a[1] = (n-a[0]*1000-n%100)/100;
  a[2] = (n-a[0]*1000-a[1]*100)/10;
  a[3] = n%10;
  int m = a[0]*10+a[1];
  int l = a[2]*10+a[3];
  if(l>0 && l<=12 && m>0 && m <=12){
    printf("AMBIGUOUS");
  }else if(m <=12 && (l >12 || l==0) && m!= 0){
    printf("MMYY");
  }else if(l <=12 && (m >12 || m ==0) && l!= 0){
    printf("YYMM");
  }else{
    printf("NA");
  }
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <iomanip> 

#define PI 3.1415926535897932384

using namespace std;

int main(){
  
  int len1, len2, hour, min;
  
  cin >> len1 >> len2 >> hour >> min;
  
  long double hourDegree = 1.0*30*hour + 0.5 * min;

  long double minDegree = 6.0 * min;

  long double degree;

  if(hourDegree > minDegree){
      degree = hourDegree-minDegree;
  }
  else{
      degree = minDegree-hourDegree;
  }

  if(degree > 180){
      degree = 360 - degree;
  }

//   cout << setprecision(10) << degree << endl;

  long double res;

  res = len1*len1 + len2*len2 - (2*len1*len2*cos(degree*PI/180));

  cout << setprecision(20) << sqrt(res) << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll Ai;
    vector<ll> A;
    ll vmax1 = 0;
    ll vmax2 = 0;
    ll imax = -1;
    for(int i=0;i<N;i++){
        cin >> Ai;
        A.push_back(Ai);
        if(Ai >= vmax1){
            imax = i;
            vmax2 = vmax1;
            vmax1 = Ai;
        }else if(Ai > vmax2){
            vmax2 = Ai;
        }
    }
    for(int i=0;i<N;i++){
        if(i==imax) cout<<vmax2<<endl;
        else        cout<<vmax1<<endl;
    }


    return 0;
}

Measured memory_bytes: 3312
#include <iostream>

using namespace std;

int n, cnt[7], in;
bool d[7];

main(){
  while(cin >> n){
    for(int i=0;i<7;i++) cnt[i] = d[i] = 0;
    for(int i=0;i<n;i++){
      cin >> in;
      if(in/10 == in%10) d[in/10] = true;
      else{
        cnt[in/10]++;
        cnt[in%10]++;
      }
    }
    bool f = true;
    int t = 0;
    for(int i=0;i<7;i++){
      if(d[i] && !cnt[i] && n > 1) f = false;
      if(cnt[i]&1) t++;
    }
    if(t > 2) f = false;
    cout << (f ? "Yes" : "No") << endl;
  }
}

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

int main(){
  int n,m,ac=0,wa=0,w;
  string s;
  cin >> n >> m;
  vector<int> a(n),b(n);
  rep(i,m){
    cin >> w >> s;
    if(a[w]==0) {
      if(s=="AC"){
      	wa+=b[w];
      	a[w]=1;
      	ac++;
      }else b[w]++;
    }
  }
  cout << ac <<" "<<wa<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int N,K;
int S[18],T[18];
int A[50][18];
bool cA[50];
long cnt[55];
long comb[51][51];
void rd(int X[18])
{
	int Y;cin>>Y;
	for(int i=0;i<18;i++)X[i]=Y>>i&1;
}
int pc(long X)
{
	return __builtin_popcountll((long long)X);
}
main()
{
	cin>>N>>K;
	rd(S);
	rd(T);
	for(int i=0;i<N;i++)
	{
		rd(A[i]);
		bool now=false;
		for(int j=0;j<18;j++)
		{
			if(S[j]==1&&A[i][j]==0||T[j]==0&&A[i][j]==1)
			{
				now=true;
				break;
			}
		}
		cA[i]=!now;
	}
	comb[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		comb[i][0]=comb[i][i]=1;
		for(int j=1;j<i;j++)comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
	}
	for(int i=0;i<=50;i++)
	{
		for(int j=1;j<=i&&j<=K-1;j++)cnt[i]+=comb[i][j];
	}
	for(int i=0;i<18;i++)
	{
		if(S[i]==1&&T[i]==0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	long ans=0;
	for(int i=0;i<N;i++)
	{
		if(!cA[i])continue;
		long ok=0;
		long check[18]={};
		for(int j=i+1;j<N;j++)
		{
			if(!cA[j])continue;
			ok|=1L<<j;
			for(int k=0;k<18;k++)
			{
				if(S[k]==0&&T[k]==1)
				{
					if(A[i][k]==A[j][k])check[k]|=1L<<j;
				}
			}
		}
		long now=cnt[pc(ok)];
		for(int j=1;j<1<<18;j++)
		{
			long take=ok;
			for(int k=0;k<18;k++)if(j>>k&1)take&=check[k];
			long X=cnt[pc(take)];
			if(pc(j)%2==0)now+=X;
			else now-=X;
		}
		ans+=now;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

typedef long double ld;
typedef tuple<ld, ld, ld> tup;
const ld pi = acos(-1);

int main() {
	cout << fixed << setprecision(30);
	int n;
	cin >> n;
	vector<tup> v;
	rep(i, n) {
		ld x, y, arg;
		cin >> x >> y;
		if(x == 0.0 && y >= 0.0) {
			arg = pi / 2.0;
		}
		else if(x == 0.0 && y < 0.0) {
			arg = -pi / 2.0;
		}
		else {
			arg = atan(y / x);
			if(x < 0.0) arg += pi;
		}
		v.push_back(tup(arg, x, y));
	}
	sort(v.begin(), v.end());
	ld ans = 0.0;
	for(int i = 0; i < n; i++) {
		ld tmp_x = get<1>(v[i]);
		ld tmp_y = get<2>(v[i]);
		ans = max(sqrt(pow(tmp_x, 2.0) + pow(tmp_y, 2.0)), ans);
		for(int j = 1; j <= n - 1; j++) {
			tmp_x += get<1>(v[(i + j) % n]);
			tmp_y += get<2>(v[(i + j) % n]);
			ans = max(sqrt(pow(tmp_x, 2.0) + pow(tmp_y, 2.0)), ans);
		}
	}
	cout << ans << endl;
}


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

int main(){
  int N,W;
  cin>>N>>W;
  vector<int> vec(N,0);
  for(int i=0;i<W;i++){
    int a,b;
    cin>>a>>b;
    vec[a-1]++;
    vec[b-1]++;
  }
  for(int i=0;i<N;i++){
    cout<<vec[i]<<endl;
  }
}
    

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

long int combination(long int n, long int r);

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int combination(long int n, long int r)
{
	if(r>n-r) r = n-r;
	if(r == 0) return 1;
	else if(r == 1) return n;
	return (combination(n-1, r) + combination(n-1, r-1));
	//大きくなるとき
	/*
	long int tmp1, tmp2, tmp3;
	tmp1 = combination(n-1, r);
	if(tmp1>=MOD) tmp1 = tmp1%MOD;
	tmp2 = combination(n-1, r-1);
	if(tmp2>=MOD) tmp2 = tmp2%MOD;
	tmp3 = tmp1+tmp2;
	if(tmp3>=MOD) tmp3 = tmp3%MOD;
	return (tmp3);
	*/
}


int main(){
	long long int a, b, n;
	scanf("%lld%lld%lld", &n, &a, &b);

	long long int count, tmp;
	tmp = n/(a+b);
	count = tmp*a;
	if(n-tmp*(a+b)<a) count += n-tmp*(a+b);
	else count += a;
	printf("%lld\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100010
string s;
int n;
string c;
map<string,int> mp;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(mp[s]==1)return puts("No"),0;
		int len=s.size();
		if(i==1)c=s[len-1];
		else if(s[0]!=c[0])return puts("No"),0;
		mp[s]=1;c[0]=s[len-1];
	}
	return puts("Yes"),0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    while(1) {
        int n,m;
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        int a[n];
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int ans = -1;
        for(int i = 0; i< n; i++) {
            for(int j = i + 1; j < n; j++) {
                if(a[i] + a[j] <= m) {
                    ans = max(a[i] + a[j],ans);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <typeinfo>
using namespace std;
int main(){
  string s;
  cin >> s;
  string m=s.substr(5,2);
  int mi=stoi(m);
  if (mi < 5) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  return 0;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s, t;
    cin >> s >> t;
    for(int i=0; i<s.size(); i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3628
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
    public static void Swap<T>(ref T a, ref T b)
    {
	var t = a;
	a = b;
	b = t;
    }
}

class Bisect
{
    /* BisectRight(a, x) returns the index where to insert x in a sorted list a.
     * 
     * The return value i is such that for all j < i, a[j] <= x and
     * for all j >= i, a[j] > x.
     */
    public static
	int BisectRight<T>(T[] a, T x, int lo=0, int hi=-1) where T:IComparable
    {
	if (hi < 0)  hi = a.Length;
	while (lo < hi)
	{
	    int mid = (lo + hi) / 2;
	    if (x.CompareTo(a[mid]) < 0) { hi = mid; }
	    else { lo = mid + 1; }
	}
	return lo;
    }
								    
    /* BisectLeft(a, x) returns the index where to insert x in a sorted list a.
     * 
     * The return value i is such that for all j < i, a[j] < x and
     * for all j >= i, a[j] >= x.
     */
    public static
	int BisectLeft<T>(T[] a, T x, int lo=0, int hi=-1) where T:IComparable
    {
	if (hi < 0)  hi = a.Length;
	while (lo < hi)
	{
	    int mid = (lo + hi) / 2;
	    if (a[mid].CompareTo(x) < 0) { lo = mid + 1; }
	    else { hi = mid; }
	}
	return lo;
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] L = ReadIntArray();
	Array.Sort(L);

	//for (int i = 0; i < n; i++) Write($"{L[i]} ");
	//WriteLine("");
	
	long ans = 0;
	for (int i = n-1; i >= 2; i--)
	{
	    int a = L[i];
	    for (int j = i-1; j >= 1; j--)
	    {
		int b = L[j];

		int kmax = Bisect.BisectRight(L, a+b, 0, j);
		int kmin = Bisect.BisectRight(L, a-b, 0, j);
		ans += (kmax - kmin);
		
		//WriteLine($"i={i}, j={j}, a={a}, b={b}");
		//WriteLine($"kmax = {kmax}, kmin={kmin}, ans={ans}");
	    }
	}

	WriteLine(ans);
    }
}


Measured memory_bytes: 19572
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long w,h;
  string s;
  cin >> w >> h >> s;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if((i==0 or i==h-1) and j==0){
        cout << "+";
      }else if((i==0 or i==h-1) and j==w-1){
        cout << "+";
      }else if((i==0 or i==h-1) and j!=0 and j!=w-1){
        cout << "-";
      }else if((j==0 or j==w-1) and i!=0 and i!=h-1){
        cout << "|";
      }else if(i==h/2 and j==w/2){
        cout << s;
      }else{
        cout << ".";
      }
    }
    cout << endl;
  }
  return 0;
}



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

int main()
{
    string str;
    cin>>str;
    char c = str.back();
   if(c == 's')
   {
  str.append("es");
   }
  
 else
 {
  str.append("s");
}
cout<<str;
    

    return 0;
}


Measured memory_bytes: 3624
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

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

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long A, B, C;
    scan(A, B, C);
    long c;
    foreach_reverse (i; 1 .. 101)
    {
        if (A % i == 0 && B % i == 0)
        {
            c++;
            if (C == c)
            {
                writeln(i);
                return;
            }
        }
    }
}


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

int main()
{
    int N, K;
    cin >> N >> K;

    int maximum = (N - 1) * (N - 2) / 2;

    if (K > maximum)
    {
        cout << -1 << endl;
        return 0;
    }

    int M = (N - 1) + (maximum - K);
    cout << M << endl;

    for (int i = 2; i <= N; i++)
    {
        cout << 1 << " " << i << endl;
        M--;
    }

    for (int i = 2; i <= N; i++)
    {
        for (int j = i + 1; j <= N; j++)
        {

            if (M > 0)
            {
                cout << i << " " << j << endl;
                M--;
            }
            else
            {
                return 0;
            }
        }
    }
}


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

int main (){
    int ans = 0;
    int toy = 0;

    int N;
    cin >> N;
    
    //配列１行目の入力を定義する
    string array1[N];
    for (int i = 0; i < N; i++){
        cin >> array1[i];
    }
    
    int M;
    cin >> M;
    
    //配列2行目の入力を定義する
    string array2[M];
    for (int t = 0; t < M; t++){
        cin >> array2[t];
    }

    for (int a = 0; a < N; a++ ){
        for(int b = 0; b < N; b++){
            if(array1[a] == array1[b]){
                toy += 1;
            }
        }

        for(int c = 0; c < M; c++){
            if(array1[a] == array2[c]){
                toy -= 1;
            }
        }
        if(ans <= toy){
            ans = toy;
        }
        
        toy = 0;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e5 + 6;
pii A[105];
int dp[3003][3003];
pii nxt[3003][3003];
int n , w;

void solve()
{
    string s1 , s2;
    cin >> s1 >> s2;

    int n1 = s1.length() , n2 = s2.length();

    loop(i,1,n1+1)
    {
        loop(j,1,n2+1)
        {
            if(s1[i-1] == s2[j-1])
            {
                dp[i][j] = max(dp[i][j] , dp[i-1][j-1]+1);
                nxt[i][j] = {i-1,j-1};
            }
            else 
            {
                if(dp[i-1][j] > dp[i][j-1])
                {
                    dp[i][j] = dp[i-1][j];
                    nxt[i][j] = {i-1,j};
                }
                else 
                {
                    dp[i][j] = dp[i][j-1];
                    nxt[i][j] = {i,j-1};
                }
            }
        }
    }

    int st = n1, en = n2;

    string ans = "";


      while(st > 0 && en > 0)
      {
            pii p1 = nxt[st][en];
            if(st-1 == p1.ff && en-1 == p1.ss)
            {
                  ans += s1[st-1];
            }
            st = p1.ff;
            en = p1.ss;
      }

      reverse(ans.begin(),ans.end());

      cout << ans;
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
     

     int t = 1;
     // cin >> t;
     while(t--)solve();
  
}

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

using namespace std;

int main(){
    int N,moti=0;
    cin >> N;
    vector<int>d(N);
    for(int i=0;i<N;i++)cin >> d.at(i);

    for(int i=0;i<110;i++){
        if(count(d.begin(),d.end(),i)>=1){
            moti++;
        }
    }
    
    cout << moti << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int n, i;
    long long ans = 0;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        if (i % 3 && i % 5) ans += i;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

//		long ans2 = 0;
//		long ans = 0;
		int ans = 0;
//		String ans = "";

		Scanner sc = new Scanner(System.in);


		int n = sc.nextInt();
//		int k = sc.nextInt();
//		String s = sc.next();
//		String t = sc.next();

//		String string = sc.next();
//		StringBuilder s = new StringBuilder(string);

		boolean f = false;

//

		int[] b = new int[n];
//		int[][] aa = new int[h][w];
//		int[] bb = new int[n];
//		for (int i = 0; i < h; i++) {
//			for(int j = 0; j < w; j++) {
//				a[i][j] = sc.nextInt();
//			}
//		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
//			bb[i] = b[i];
		}
		int tmp = 1;

		for(int i=0; i < n; i++) {
			if(tmp != b[i]) {
				ans++;
			} else {
				tmp++;
			}
		}
		if(ans == n) {
			ans = -1;
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 72960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;

int main(){
	int l,r,d,sum=0;
	scanf("%d%d%d",&l,&r,&d);
	int k=0;
	while(k<l){
		k+=d;
	}
	for(int i=k;i<=r;i+=d){
		sum++;
	}
	printf("%d",sum);
	return 0; 
}





Measured memory_bytes: 3808