akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#include <map>
#include <string>
int main(){
	
    string s;
    long long N;
    cin >> N;
    cin >> s;

    map<long long,long long> m;

    for(long long i=0; i<s.size();i++){
        long long tmp = s[i] - 'a';
        m[tmp]++;
    }
    
    long long ans = 1;

    for(long long i=0;i<m.size();i++){
        long long  n = m[i];
        ans *=  (n+1);
        ans %=  1000000007;
    }

    cout << ans-1 << endl; 

}

Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();        

		if(k%10==7||k/100==7||(k%100)/10==7){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}		
	    scan.close();	
    }
}

Measured memory_bytes: 35780
import sys
A, B, C, D = list(input())

def iter_p_adic(p, n):
    from itertools import product
    tmp = [range(p)] * n
    return product(*tmp)

operator = ['+', '-']

iterator = iter_p_adic(2, 3)
for idxs in iterator:
    fomula = A + operator[idxs[0]] + B + operator[idxs[1]] + C + operator[idxs[2]] + D
    if eval(fomula) == 7:
        print(fomula + '=7')
        sys.exit()

Measured memory_bytes: 3064
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	a, err := strconv.Atoi(scanner.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func powUInt2(n int) uint {
	ret := uint(1)
	for i := 0; i < n; i++ {
		ret *= 2
	}
	return ret
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := scanInt()
	m := scanInt()

	a := make([]int, m)
	b := make([]uint, m)
	for i := 0; i < m; i++ {
		a[i] = scanInt()
		nb := scanInt()
		for j := 0; j < nb; j++ {
			b[i] |= powUInt2(scanInt() - 1)
		}
	}

	bMaskMap := map[uint]uint{}
	bMaskMap[0] = uint(0)
	for i := 1; i <= n; i++ {
		for j := powUInt2(i - 1); j < powUInt2(i); j++ {
			bMaskMap[j] = powUInt2(i) - 1
		}
	}

	dp := make([][]int, m+1)
	for i := range dp {
		dp[i] = make([]int, powUInt2(n))
	}

	dp[0][0] = 0
	for i := 1; i < int(powUInt2(n)); i++ {
		dp[0][i] = math.MaxInt32
	}

	for i := 0; i < m; i++ {
		for j := uint(0); j < powUInt2(n); j++ {
			l := dp[i][(j&b[i])^j] + a[i]
			r := dp[i][j]
			if l > r {
				dp[i+1][j] = r
			} else {
				dp[i+1][j] = l
			}
		}
	}
	if dp[m][powUInt2(n)-1] == math.MaxInt32 {
		fmt.Println(-1)
	} else {
		fmt.Println(dp[m][int(powUInt2(n))-1])
	}
}


Measured memory_bytes: 33920
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	private static int n; // ?????????????????°
	private static int sumA, sumB; // A???B???????¨???????
	private static int cardA, cardB; // A???B?????????????????????

	// ??????????????????
	private static int isWinner;
	private static final int A_WIN = 0;
	private static final int B_WIN = 1;
	private static final int DRAW = 2;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(new InputStreamReader(System.in));

		while ((n = sc.nextInt()) != 0) {
			// ???????????????
			init();
			// ????±???????
			for (int i = 0; i < n; i++) {
				cardA = sc.nextInt();
				cardB = sc.nextInt();
				battle();
			}
			// ???????????????
			System.out.println(String.format("%d %d", sumA, sumB));
		}
	}

	/**
	 * ???????????????
	 */
	private static void init() {
		sumA = 0;
		sumB = 0;
	}

	/**
	 * ????±???????
	 */
	private static void battle() {
		if (cardA > cardB) {
			isWinner = 0;
		} else if (cardB > cardA) {
			isWinner = 1;
		} else if (cardA == cardB) {
			isWinner = 2;
		}
		calculate();
	}

	/**
	 * ???????¨????
	 */
	private static void calculate() {
		switch (isWinner) {
		case A_WIN:
			sumA += (cardA + cardB);
			break;
		case B_WIN:
			sumB += (cardA + cardB);
			break;
		case DRAW:
			sumA += cardA;
			sumB += cardB;
			break;
		}
	}
}

Measured memory_bytes: 53380
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll n;
vector<pair<ll, ll>> f;
vector<ll> t;
ll qry(int v, int tl, int tr, int l, int r)
{
    if(l > r) return 0;
    if(tl == l && tr == r) return t[v];
    int tm = (tl + tr)/2;
    return max(qry(v * 2, tl, tm, l, min(r, tm)), qry(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
void upd(int v, int tl, int tr, int u, ll x)
{
    if(tl == tr) t[v] = max(x, t[v]);
    else
    {
        int tm = (tl + tr)/2;
        if(u > tm) upd(v * 2 + 1, tm + 1, tr, u, x);
        else upd(v * 2, tl, tm, u, x);
        t[v] = max(t[v * 2], t[v * 2 + 1]);
    }
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    f.assign(n, {0, 0});
    F0R(i, n) cin >> f[i].f;
    F0R(i, n) cin >> f[i].s;
    t.assign(4 * n + 50, 0);
    F0R(i, n)
    {
        ll p = qry(1, 0, n + 1, 0, f[i].f) + f[i].s;
        upd(1, 0, n + 1, f[i].f, p);
    }
    ll res = qry(1, 0, n + 1, 0, n + 1);
    cout << res;
    return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const int MAXN = -1;

int main()
{
    int n,m;
    cin>>n>>m;
    map<int,int> a;
    rep(i,n)
    {
        a[i]=MAXN;
    }
    rep(i,m)
    {
        int s,c;
        cin>>s>>c;
        s-=1;
        if(a[s]!=MAXN & a[s]!=c)
        {
            cout<<"-1";
            return 0;
        }
        else
        {
            a[s]=c;
        } 
    }
    if(a[0]==MAXN & n!=1){
        a[0]=1;
    }
    if(a[0]==0 & n!=1){
        cout<<"-1"<<endl;
        return 0;
    }
    rep(i,n)
    {
        if(a[i]==MAXN)a[i]=0;
    }
    string ans="";
    

    map<int,int>::iterator it;
    for(it=a.begin();it!=a.end();it++)
    {
        ans+=to_string(it->second);
        
    }

    
    cout<<ans;
}

Measured memory_bytes: 256
def main():
    import sys
    import math

    asa =  sys.stdin.readline
    n = int(input())
    s = list(map(int, asa().split()))
    q = int(input())
    t = list(map(int, asa().split()))
    c = 0

    stopper = math.log2(n) + 1

    for i in t: # tの中のiを探索vim
        time = 0
        middle = int(n/2)
        small = 0
        large = n
        time = 0

        while s[middle] != i and time < stopper:
            if s[middle] > i:
                large = middle
                middle = int((middle + small) / 2)

            else:
                small = middle
                middle = int((middle + large) / 2)

            time += 1
        if s[middle] == i:
            c += 1

    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16240
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n,m;
    cin >> n >> m;
    vi city(n,0);
    rep(i,m)
    {
        int a,b;
        cin >> a >> b;
        if(a!=b)
        {
            ++city[a-1];
            ++city[b-1];
        }
    }
    rep(i,n)
    {
        cout << city[i] << endl;
    }
}


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

int ans[365],c[26],s[365][26],last[26],csum,nowscore,newscore;
const int INF=1e9,d=365,starttemp=4000,endtemp=50;
double temperature,prob;
const double TIMELIMIT=1.97*CLOCKS_PER_SEC;

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

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

void FIN(bool a){
  if(a){
    ofstream fout("output.txt");
    REP(i,d)fout<<ans[i]+1<<"\n";
    fout.close();
    exit(0);
  }
  REP(i,d)cout<<ans[i]+1<<"\n";
  exit(0);
}
/*
int score(){
  int res=0;
  memset(last,-1,sizeof(last));
  REP(day,d){
    res+=s[day][ans[day]];
    last[ans[day]]=day;
    REP(i,26)res-=c[i]*(day-last[i]);
  }
  return res;
}
*/
int score(){//上のがO(26*365)、こっちがO(365)のスコア計算
  int res=0,minus=csum;
  memset(last,-1,sizeof(last));
  REP(day,d){
    res+=s[day][ans[day]];
    minus-=c[ans[day]]*(day-last[ans[day]]);
    last[ans[day]]=day;
    res-=minus;
    minus+=csum;
  }
  return res;
}
void swap(){
  int RAND=rand();
  int day=RAND%(d-1);
  RAND^=newscore;
  int diff=RAND%min(d-day-1,10)+1;
  swap(ans[day],ans[day+diff]);
  newscore=score();
  prob=exp((newscore-nowscore)/temperature);
  if(prob>(rand()%INF)/(double)INF)nowscore=newscore;
  else swap(ans[day],ans[day+diff]);
}
void onechange(){
  int day=rand()%365;
  REP(i,26){
    int tmp=ans[day];
    ans[day]=i;
    newscore=score();
    prob=exp((newscore-nowscore)/temperature);
    if(prob>(rand()%INF)/(double)INF)nowscore=newscore;
    else ans[day]=tmp;
  }
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  clock_t start=clock();
  memset(last,-1,sizeof(last));
  cin>>c[0];
  REP(i,26){cin>>c[i];csum+=c[i];}
  REP(i,d)REP(j,26)cin>>s[i][j];
  REP(day,d){
    int idx,mx=-INF;
    REP(i,26){
      int A=c[i]*((day-last[i])*2+6)*7+s[day][i],B=0;
      REP(j,min(10,d-day))chmax(B,s[day+j][i]-c[i]*((day-last[i])*2+j)*(j+1));
      if(mx<A-B/2)mx=A-B/2,idx=i;
    }
    ans[day]=idx,last[idx]=day;
  }
  nowscore=score();
  while(true){
    clock_t nowt=clock();
    const double Time=static_cast<double>(nowt-start);
    if(Time>TIMELIMIT)FIN(0);
    temperature=starttemp+(double)(endtemp-starttemp)*Time/TIMELIMIT;
    REP(_,50)
      if((_^newscore)&1)swap();
      else onechange();
  }
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

vector<int> vb;
int H;
int N;
int main()
{
    int max_a = 0;
    scanf("%d %d\n",&N,&H);
    _for(i,0,N){
        int a,b;
        scanf("%d %d",&a,&b);
        max_a = max(max_a,a);
        vb.PB(b);
    }
    sort(ALL(vb),greater<int>());

    int res = 1e9+7;
    int t = H;

    _for(i,0,N){
        t -= vb[i];
        if(t <= 0){
            res = min(res,i+1);
            break;
        }
        int k = (t-1)/max_a + 1;
        res = min(res,i+1+k);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 892
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize k:i64)(list:[i64]));
    //必ず小さくなる
    //n log nまで
    //nとkがあればn-kを作れる
    //n-kとnがあればkを作れる
    //偶数-偶数=偶数
    //奇数-奇数=奇数
    //偶数-奇数=奇数
    //nとkn→n(k-1)
    //dpは無理

    /*
    全部作れる
    9 3 4
    6 5 1 2 7 8
     */

    /*
    倍数？
    6 9 3
     */

    //例4:偶数のみから奇数x

    /*10,1
    9 8 7 6 5 4 3 2
     */

    /*10 2
    8 6 5 4 2
     */

    /*
    10 3
    7 4 1
    ...
     */

    /*
    9 3
    6
     */

    /*
    11 3
    8 5 2
    9 1...
     */

    //1があればmax以下のを全部作れる

    //11 3 7 15
    //4 1...

    //公約数？

    let mut g = list[0];
    for x in list.clone() {
        g = gcd(g, x);
    }

    let max = list.into_iter().max().unwrap();

    if k <= max && k % g == 0 {
        "POSSIBLE"
    } else {
        "IMPOSSIBLE"
    }.to_string()
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 7\n9 3 4" => "POSSIBLE",
    test2: "3 5\n6 9 3" => "IMPOSSIBLE",
    test3: "4 11\n11 3 7 15" => "POSSIBLE",
    test4: "5 12\n10 2 8 6 4" => "IMPOSSIBLE",
}


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

using namespace std;
int a[35][35],v[70];
int palindrom(char s[])
{
    int n=strlen(s);
    for(int i=0;i<strlen(s)/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return 0;
    }
    return 1;
}
int main()
{
    //ifstream fin("fis.in");
    //ofstream fout("fis.out");
    char s[101],q[101],p[101];
    cin>>s;
    int n=strlen(s);
    strcpy(q,s+(n+3)/2-1);
    strcpy(p,s);
    p[n/2]='\0';
    if(palindrom(s) && palindrom(q) && palindrom(p))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int n,m;
int a[100010];
vector<int> v[100010];
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		int mx=a[i]-1;
		for(int j=0;j<v[i].size();j++){
			mx=max(mx,a[v[i][j]]);
		}
		if(mx>a[i]-1);
		else cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 9024
#include <iostream>
#include <algorithm>
using namespace std;
const int N=102;
int n,tot;
struct Item{
    string s; int p, id;
    void read(){
        cin>>s>>p;id=++tot;
    }
    bool operator<(const Item&o)const{
        if(s==o.s) return p>o.p;
        return s<o.s;
    }
} it[N];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) it[i].read();
    sort(it+1,it+1+n);
    for(int i=1;i<=n;i++) cout<<it[i].id<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define LL long long
#define N 100005
#define INF 0x3f3f3f3f
const double esp = 1e-6;
const LL Mod = 1e9+7;
LL a[N];
void init()
{
    LL sum = 1;
    for(int i = 1; i < N; i++)
    {
        sum = ((LL)i*sum)%Mod;
        a[i] = sum;
        //printf("%lld\n",a[i]);
    }
}
int b[N];
int main()
{
    init();
    int n;
    while(~scanf("%d",&n))
    {
        for(int i = 1; i <= n; i++)
            scanf("%d",&b[i]);
        LL sum = 1;
        int k = 1;
        int i;
        for(i = 1; i <= n; i++)
        {
            int i1 = i;
            int k1 = k;
            while(b[i1--] < 2*(i-k))
                k++;
            if(b[i1+1] == 2*(i-k) && i != n)
                k++;
            if(k1 < k)
                sum = (sum*(i-k+2))%Mod;
            //printf("%d  %d  %d\n",b[i],k,2*(i-k)+1);
            //printf("%lld\n",sum);
        }
        sum = (sum*(n-k+1))%Mod;
        sum = sum*a[n-k]%Mod;
        printf("%lld\n",sum);
    }
    return 0;
}


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

int main(int argc, char *argv[])
{
    int n, cnt;
    string f, s;
    while (cin >> n, n) {
        cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (i % 2) {
                cin >> s;
                if (f[0] != s[0])
                    cnt++;
            }
            else {
                cin >> f;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

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 INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    string S, T;
    REP(i, b) S += a + '0';
    REP(i, a) T += b + '0';
    if(S < T) cout << S << endl;
    else cout << T << endl;
}

Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:break
    com=[int(input())for i in range(n)]
    seq=[1]
    isW=com[0]==0
    stW=isW
    for i in range(1,n):
        if i%2!=0:
            if len(seq)!=1:
                if (isW and com[i]==1)or(not isW and com[i]==0):
                    seq[len(seq)-2]+=seq.pop()+1
                else:seq[len(seq)-1]+=1
            else:
                seq[0]+=1
                if (isW and com[i]==1)or(not isW and com[i]==0):stW=not stW
            isW=com[i]==0
        else:
            if isW:
                if com[i]==0:seq[len(seq)-1]+=1
                else:
                    seq.append(1)
                    isW=False
            else:
                if com[i]==0:
                    seq.append(1)
                    isW=True
                else:seq[len(seq)-1]+=1
    total=0
    if stW:total=sum(seq[0::2])
    else:total=sum(seq[1::2])
    print(total)

Measured memory_bytes: 8708
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {

    int n,k,h;
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    k = sc.nextInt();
    int data[] = new int [n];
    int x = 0;

    if(1<=k && k<=500){
      for(int i=0 ; i<n ; i++){
        data[i] = sc.nextInt();
        if(data[i]>=k && data[i]<=500){
          x++;
        }
      }
    }
    System.out.println(x);
  }
}


Measured memory_bytes: 50676
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
int a,b,c,x,y;
scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);

long long ans1=a*x+b*y;
long long ans2,ans3;

int geshu=min(x,y);
int shengyu=max(x,y)-geshu;
if(x>y) {
     ans2 = geshu * c * 2+ shengyu * a;
}else {
    ans2=geshu * c * 2+ shengyu * b;
}
int maxnum=max(x,y);
ans3=maxnum*2*c;

ans1=min(ans1,min(ans2,ans3));

printf("%lld",ans1);
return 0;

}


Measured memory_bytes: 256
/** Which of the favors of your Lord will you deny ? **/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

int match[25][25];

const LL mod = 1e9+7;

void add_self(LL &a,LL b)
{
    a += b;
    if(a>=mod) a -= mod;
}

LL dp[22][1<<22];
LL dp2[1<<22];
int n;

LL solve(int m,int mask)
{
    LL &ret = dp[m][mask];

    if(ret!=-1) return ret;

    if(m==n) return ret = (mask==(1<<n)-1); /// n pair is matched

    ret = 0;

    for(int w=0;w<n;w++)
    {
        if(match[m][w] && !(mask&(1<<w)))
            add_self(ret , solve(m+1,mask |(1<<w)));
    }

    return ret;
}

LL solve2(int mask)
{
    LL &ret = dp2[mask];

    if(ret!=-1) return ret;

    int m = __builtin_popcount(mask);

    if(m==n) return ret = (mask==(1<<n)-1); /// n pair is matched

    ret = 0;

    for(int w=0;w<n;w++)
    {
        if(match[m][w] && !(mask&(1<<w)))
            add_self(ret ,solve2( mask |(1<<w)));
    }

    return ret;
}

int main()
{
    optimizeIO();

    cin>>n;

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>match[i][j];

//    memset(dp,-1,sizeof dp);
    memset(dp2,-1,sizeof dp2);

    cout<<solve2(0)<<endl;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 36432
#include <bits/stdc++.h>
#define l_ength size
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n; 
	vector<int> a(n);
	for( auto &k : a ) cin >> k;
	sort( a.begin(), a.end() );
	int bound = a.back();
	if( a[0] == 1 ){
		if( a[1] == 1 ){
			cout << 0 << endl;
			return 0;
		} else {
			cout << 1 << endl;
			return 0;
		}
	}
	vector<int> ans(n, 1);
	for( auto itr = a.begin(); itr != a.end(); ++itr ){
		int k = *itr;
		auto tmp = itr; ++tmp;
		if( ans[itr-a.begin()] == 0 ) continue;
		if( tmp != a.end() and *itr == *tmp ){
			ans[itr-a.begin()] = ans[tmp-a.begin()] = 0;
		}
		int cnt = 1;
		while( k*cnt <= bound ){
			int l = lower_bound( tmp, a.end(), k*cnt ) - a.begin();
			int r = upper_bound( tmp, a.end(), k*cnt ) - a.begin();
			for( int t = l; l != r and t < r; ++t ){
				ans[t] = 0;
			}
			++cnt;
		}
	}
	cout << accumulate( ans.begin(), ans.end(), 0 ) << endl;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> number(n);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    number.at(a - 1)++;
    number.at(b - 1)++;
  }
  for(int i = 0; i < n; i++){
    cout << number.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N;
    cin >> N;
    vl A(N);
    ll ans[N + 1];
    FOR(i, 0, N) {
        cin >> A[i];
        ans[A[i]] = i + 1;
    }
    FOR(i, 1, N + 1) {
        cout << ans[i] << ' ';
    }
}

Measured memory_bytes: 2432
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;

ll comb(int a, int b){ //aCb
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll ans;
    double tmp;

    tmp=1.0;
    for(int i=a; i>a-b; i--){
        //cout << "comb i= " << i << endl;
        tmp *= (double) i/max(i-(a-b),1);  
        //cout << "tmp " << tmp << endl;
    }

    ans = (long long) round(tmp);

    return ans;
}

int main(){
    int A, B, N;
    cin >> N >> A >> B;
    long long v[N];
    for(int i=0; i<N; i++){
        cin >> v[i];
    }

    double vave;
    bool flag;
    int count, count_p, istart;
    ll ans;
    sort(v,v+N);
    
    vave=0.0;
    for(int i=N-A; i<N; i++){
        vave += (double) v[i];
    }
    vave = (double) vave/A;
    cout << fixed << setprecision( 7 ) << vave << endl;

    count=1;
    count_p=1;
    flag=true;
    int ii=N-1;
    while( ii>=N-A || count_p!=1  ){
    //for(int i=N-1; i>N-B; i--){
        if( ii<=0 ){
            count=count_p;
            break;
        }
        if( v[ii]!=v[ii-1] ){
            count=count_p;
            count_p=1;
            if( ii>=N-A ){
                flag=false;
                istart=ii;
                //cout << "new istart= " << istart << endl;
            }
        }else{
            count_p++;
        }
        ii--;
    }
    //cout << "ii " << ii << endl;
    //cout << "count " << count << endl;

    if( flag ){ //case only maximum: 10 10 10 10 10 10 A=3, B=5
        int C;
        C=min(B,count);
        ans=0;
        for(int i=A; i<=C; i++){
            ans+=comb(count, i);
            //cout << "i comb ans " << i << " " << comb(count, i) << " " << ans << endl;
        }
    }else{ // case: 10 10 9 9 9 9, A=4, B=4or5or6
        //cout << "A N istart A-(N-istart)= " << A << " " << N << " " << istart << " " << A-(N-istart) << endl; 
        ans=comb(count, A-(N-istart));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

memo1 = 10**9
memo2 = 10**9

lf = [0 for i in range(n)]
rgt = [0 for i in range(n)]

lf[0] = a[0]
rgt[0] = a[n-1]

for i in range(1,n):
	lf[i] = gcd(lf[i-1],a[i])
	rgt[i] = gcd(rgt[i-1],a[i*(-1)-1])


mx = 0
mx = max(mx,lf[n-2])
mx = max(mx,rgt[n-2])

for i in range(1,n-1):
	mx = max(mx,gcd(lf[i-1],rgt[i*(-1)-2]))

print(mx)     

    


Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, a[500][500];
int main() {
	read(m), n = (m+3)/4*2;
	if (m == 1) return puts("1\n1"), 0;
	for (int i = 0; i < n; i++) a[0][i] = i;
	for (int i = 1; i < n; i++)
		for (int j = 0; j < n; j++)
			a[i][j] = (a[i-1][j]+1)%n;
	for (int i = 1; i < n; i += 2)
		for (int j = 0; j < n; j++)
			a[i][j] += n;
	for (int c = n*2; c >= m; c--)
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (a[i][j] == c) a[i][j] -= n;
	printf("%d\n", n);
	for (int i = 0; i < n; i++, puts(""))
		for (int j = 0; j < n; j++)
			printf("%d ", a[i][j]+1);
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

struct Edge{
  int src, dest;
  int idx;
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

bool dfs(const Graph& g, const vector<bool>& vb,
    vector<bool>& vis, vector<bool>& cut, int i, int p = -1, int ei = -1) {
  vis[i] = true;
  bool parity = false;
  for (auto&& e : g[i]) {
    if (e.dest == p) continue;
    bool child = dfs(g, vb, vis, cut, e.dest, i, e.idx);
    parity = parity != child; // XOR
  }
  bool flip = vb[i] != vb[i+1];
  if (flip != parity) {
    if (ei != -1) {
      cut[ei] = true;
      return true;
    } else {
      throw std::runtime_error("invalid");
    }
  }
  return false;
}

int main()
{
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> vp;
  for(auto&& _:irange(0,n)) {
    int a,b;
    cin>>a>>b;
    vp.emplace_back(a,b);
  }
  boost::sort(vp);
  Graph g(n+1);
  UnionFind uf(n+1);
  for(auto&& i:irange(0,m)) {
    int l,r;
    cin>>l>>r;
    int il = boost::lower_bound(vp,make_pair(l,0)) - begin(vp);
    int ir = boost::lower_bound(vp,make_pair(r+1,0)) - begin(vp);
    if (uf.merge(il, ir)) {
      g[il].push_back({il, ir, i});
      g[ir].push_back({ir, il, i});
    }
  }
  vector<bool> vb(n+2, false);
  for(auto&& i:irange(0,n)) {
    vb[i+1] = vp[i].second;
  }
  vector<bool> vis(n+1, false);
  vector<bool> cut(m, false);
  for(auto&& i:irange(0,n+1)) {
    if (vis[i]) continue;
    try {
      dfs(g, vb, vis, cut, i);
    } catch(...) {
      cout << -1 << endl;
      return 0;
    }
  }
  int k = boost::count(cut, true);
  cout<<k<<endl;
  int cnt = 0;
  for(auto&& i:irange(0,m)) {
    if (cut[i]) {
      if (cnt) cout<<" ";
      cout<<i+1;
      ++cnt;
    }
  }
  cout<<endl;
  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    std::string S;
    std::cin >> S;

    string s = "";
    rep(i, 5) {
        s += "hi";
        if (S == s) {
            cout << YES << endl;
            return 0;
        }
    }
    cout << NO << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdlib>
#include<fstream>
#include<iostream>
#include<complex>
#include<math.h>
#include<string>
#include<sstream>

using namespace std;

int main(){
    int N;
    cin >>N;
    char s[N];
    int fusion=0;
    for (int i = 0; i < N; i++){
        cin >> s[i];
        if(i>0 && s[i]==s[i-1]){
            fusion++;
        }
    }
    int ans = N-fusion;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
use std::io::BufRead;

fn main() -> Result<(), Error> {
    let stdin = std::io::stdin();
    let mut stdin = stdin.lock();
    let mut buffer = ReadBuffer::new();

    let n: usize = buffer.read_line(&mut stdin)?.trim().parse()?;

    for _ in 0..(2 * n) {}
    let mut a: Vec<u32> = buffer
        .read_line(&mut stdin)?
        .split_ascii_whitespace()
        .filter_map(|c| c.parse().ok())
        .collect();

    assert_eq!(a.len(), n * 2);

    a.sort();
    let sum: u32 = a.chunks(2).map(|ab| ab[0].min(ab[1])).sum();

    println!("{}", sum);

    Ok(())
}

struct ReadBuffer {
    buffer: Vec<u8>,
    buffer_string: String,
}

#[allow(dead_code)]
impl ReadBuffer {
    fn new() -> Self {
        Self {
            buffer: Vec::new(),
            buffer_string: String::new(),
        }
    }

    fn read_until(&mut self, mut buf: impl BufRead, b: u8) -> Result<&str, std::io::Error> {
        self.buffer.clear();
        buf.read_until(b, &mut self.buffer)?;

        let buffer = std::mem::replace(&mut self.buffer, Vec::new());
        self.buffer_string = unsafe { String::from_utf8_unchecked(buffer) };
        self.buffer = Vec::new();
        Ok(&self.buffer_string)
    }

    fn read_line(&mut self, buf: impl BufRead) -> Result<&str, std::io::Error> {
        self.read_until(buf, b'\n')
    }
}

#[derive(Debug)]
struct Error {
    message: String,
}

impl<E> From<E> for Error
where
    E: std::error::Error,
{
    fn from(error: E) -> Self {
        Self {
            message: format!("Error: {}", error),
        }
    }
}


Measured memory_bytes: 2072
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

//static const ll MOD = 1e+9 + 7;
//static const int MAX = 10001;

vector< int64_t > divisor(int64_t n);

int main() {

    int N; cin >> N;
    vector<int> a(N+1);
    vector<int> b(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> a[i];

    int M = 0;
    vector<int> c;

    for (int i = N; i != 0; i--) {

        if (a[i] != (b[i] % 2)) {
            M++;
            c.push_back(i);
            vector< int64_t > div = divisor(i);
            for (int j = 0; j < div.size(); j++) {
                //cout << div[j] << ' ';
                b[div[j]]++;
            }
            //cout << '\n';
        }
    
  }
    cout << M << '\n';
    for (int i = 0 ; i < c.size(); i++) {
        cout << c[i] << ' ';
    } cout << '\n';

}
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  //sort(begin(ret), end(ret));
  return (ret);
}


Measured memory_bytes: 3064
#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() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = "";
    rep(i, n) t += s[2*n-1-i];

    map<pair<string,string>, ll> mpl, mpr;
    
    for(int i = 0; i < (1<<n); i++){
        vector<char> vc1, vc2;
        rep(j, n){
            if (i&(1<<j)) vc1.push_back(s[j]);
            else vc2.push_back(s[j]);
        }
        string u = string(vc1.begin(), vc1.end());
        string v = string(vc2.begin(), vc2.end());
        mpl[{u,v}]++;
    }

    for(int i = 0; i < (1<<n); i++){
        vector<char> vc1, vc2;
        rep(j, n){
            if (i&(1<<j)) vc1.push_back(t[j]);
            else vc2.push_back(t[j]);
        }
        string u = string(vc1.begin(), vc1.end());
        string v = string(vc2.begin(), vc2.end());
        mpr[{u,v}]++;
    }

    ll ans = 0;

    for(auto v : mpl){
        // if(v.first.first == v.first.second) ans += v.second * mpr[v.first];
        // else {
        ans += v.second * mpr[v.first];
        ans += v.second * mpr[{v.first.second,v.first.first}];
        // }
    }
    cout << ans / 2 << endl;

    return 0;
}


Measured memory_bytes: 89624
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

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


}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {

	int n;
	cin >> n;

	if (n == 25) {
		cout << "Christmas" << endl;
	}
	else if (n == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (n == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (n == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

	return 0;
}


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

int max(int x, int y)
{
	 return x>y? x : y;
}

int main()
{
	std::string T, P;
	getline(std::cin, T);
	getline(std::cin, P);
	
	int n = T.length();
	int m = P.length();
	
	// construct KMP table
	int* KMPtable = new int[m+1];
	KMPtable[0] = -1;
	KMPtable[1] = 0;
	int i = 2, j = 0;
	for (; i<m+1; i++) {
		if (P[i-1] == P[j]) {
			j++; KMPtable[i] = j; 
		}
		else if (j>0) {
			j = KMPtable[j]; i--;
		}
		else KMPtable[i] = 0;
	}
	
	// for (int i=0; i<m; i++) std::cout << KMPtable[i] << " ";
	// std::cout << std::endl;
	
	// search by KMP
	i=0, j=0;
	while (i<n && j<m) {
		if (T[i+j] == P[j]) {
			if (j == m-1) {
				std::cout << i << std::endl;
				// std::cout << i << ": pattern match succeeded" << std::endl; 
				i += m - KMPtable[m];
				j = KMPtable[m];
			}
			else { j++; }
		}
		else {
			// std::cout << i << ": pattern match failed at index " << j << std::endl; 
			i += j - KMPtable[j];
			j = max(0, KMPtable[j]);
		}
	}
	
	delete[] KMPtable;
	
	return 0;
}
		



Measured memory_bytes: 3988
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

L = i_i()

x = L / 3
print(x*x*x)

Measured memory_bytes: 3060
a, b, c, d = (int(each) for each in input().split())
while a > 0 and c > 0:
    c -= b
    # print(c)
    if c <= 0:
        print('Yes')
        break
    a -= d
    # print(a)
    if a <= 0:
        print('No')
        break

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}

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

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;
    string s;
    cin >> s;
    auto yes = []() {
        print("Yes");
        exit(0);
    };
    auto no = []() {
        print("No");
        exit(0);
    };

    FOR(i, 1, N) {
        if (s[i - 1] == '#' && s[i] == '#' &&
            ((A < i - 1 && i < C) || (B < i - 1 && i < D)))
            no();
    }
    if (D < C) {
        FOR(i, B, D + 1) {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
                yes();
            }
        }
        no();
    }
    yes();

    return 0;
}

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

typedef unsigned long long ull;

ull b=1e9+7;
int n,m,r=1,l=0;
ull h[300001],p[300001];
string s,q;
set<ull> rh;

int main()
{
  cin>>n>>m;
  cin>>s;

  p[0]=h[0]=1;
  for(int i=0;i<n;i++){
    p[i+1]=p[i]*b;
    h[i+1]=h[i]*b+s[i];
    //cout<<p[i]<<" "<<h[i]<<endl;
  }

  for(int k=0;k<m;k++){
    cin>>q;
    if(q=="L++")l++;
    else if(q=="L--")l--;
    else if(q=="R++")r++;
    else r--;
    rh.insert(h[r]-h[l]*p[r-l]);
    //cout<<h[r]-h[l]*p[r-l]<<endl;
  }
  cout<<rh.size()<<endl;

  return 0;
}

Measured memory_bytes: 20224