akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n, f[100001], r[100001], l[100001];
string s;
int main () {
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  cin >> s;
  n = s.size ();
  s = '@' + s;
  r[0] = 0;
  for (int i = 1; i <= n; ++ i) {
    if (s[i] == 'R') {
      r[i] = i;
    }
    else {
      r[i] = r[i - 1];
    }
  }
  l[n + 1] = n + 1;
  for (int i = n; i >= 1; -- i) {
    if (s[i] == 'L') {
      l[i] = i;
    }
    else {
      l[i] = l[i + 1];
    }
  }
  for (int i = 1; i <= n; ++ i) {
    if (s[i] == 'L') {
      if (r[i - 1] == 0) {
        ++ f[1];
      }
      else {
        if ((i - r[i - 1] - 1) % 2 == 0) {
          ++ f[r[i - 1] + 1];
        }
        else {
          ++ f[r[i - 1]];
        }
      }
    }
    else {
      if (l[i + 1] == n + 1) {
        ++ f[n];
      }
      else {
        if ((l[i + 1] - i - 1) % 2 == 1) {
          ++ f[l[i + 1]];
        }
        else {
          ++ f[l[i + 1] - 1];
        }
      }
    }
  }
  for (int i = 1; i <= n; ++ i) {
    cout << f[i] << " ";
  }
}


Measured memory_bytes: 1772
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i <= n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll ans=0;
//ll a[300005];
ll b[70];
ll f[70];

int main(){
    f[0]=1;
    rep2(i,65){
        f[i]=f[i-1]*2;
        f[i]%=mod;
    }
    ll n;
    cin >> n;
    rep(i,n){
        ll a;
        cin >> a;
        ll k=0;
        while(a>0){
            if(a%2==1){
                b[k]++;
            }
            a/=2;
            k++;
        }
    }
    //cerr<<'i'<<endl;
    rep(i,65){
        ll temp=(((f[i]*b[i])%mod)*(n-b[i]))%mod;
        //cerr<<b[i]<<n-b[i]<<endl;
        ans+=temp;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
s[999999];char*p,*q=s;
c,a;
main()
{
	gets(p=s);
	q+=strlen(s);
	for(;p<q;p++)
	{
		if(*p=='x')
		{
			c++;
		}
		else
		{
			for(;*--q!=*p;)
			{
				c--;
				if(*q!='x')
				{
					puts("-1");
					return 0;
				}
			}
			a+=fabs(c);c=0;
		}
	}
	printf("%d",a);
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(n)]
choose = 1
cost_min = 10000000 * n
for i in range(2 ** n - 1):
    a_list = [0] * (m + 1)
    c = bin(choose)[2:].zfill(n)

    for j in range(n):
        if c[n - j - 1] == '1':
            a_list = [a + b for (a, b) in zip(a_list, book[j])]
    choose += 1
    
    for k in a_list[1:]:
        if k < x:
            break
    else:
        cost_min = min(cost_min, a_list[0])

if cost_min != 10000000 * n:
    print(cost_min)
else:
    print(-1)

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N;
char S[5050];

ll ln[5050];
ll i, j, k, ans;

ll calc(ll b){
    ll i = 1;
    ll j = 0;
    ll ret = 0;
    ll k = 0;
    while(i+b<N){
        //printf("%lld%lld\n", b,i);
        if(i+ln[i-j]<j+ln[j]){
            ln[i] = ln[i - j];
        }else{
            k = j + ln[j] - i > 0 ? j + ln[j] - i : 0;
            while(i+k+b<N&&S[k+b]==S[i+k+b])
                k++;
            ln[i] = k;
            j = i;
        }
        ll a = min(i, ln[i]);
        if(ret<a){
            ret = a;
        }
        i++;
    }
    return ret;
}
int main(){
    scanf("%lld%s", &N, S);
    fornum(i,0,N){
        ll a = calc(i);
        //printf("%lld:%lld\n", i, a);
        if(ans<a)
            ans = a;
            /*
        fornum(j,0,N){
            ln[j] = 0;
        }*/
    }
    printf("%lld", ans);
    return 0;
}

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

int main() {
  long long N, cnt = 0; cin >> N;
  while (N >= 10) {
    if (N%10 < 9)
      N -= 10;
    N /= 10;
    cnt += 9;
  }
  cnt += N;
  cout << cnt << endl;
  return 0;
}
    

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

using namespace std;
typedef double D;
typedef long long ll;
const ll mod=1e9+7;
const int MX=103;
int n=100,m=100,x,y,coma,comb;
char grid[MX][MX];
int main(){
    scanf("%d%d",&x,&y);
    for(int i=0;i<n/2;i++){
        for(int j=0;j<m;j++){
            grid[i][j]='.';
        }
    }
    x--;y--;
    for(int i=n/2;i<n;i++){
        for(int j=0;j<m;j++){
            grid[i][j]='#';
        }
    }
    for(int i=0;i<n/2;i+=2){
        for(int j=0;j<m;j+=2){
            if(y)grid[i][j]='#',y--;
        }
    }

    for(int i=n/2+1;i+1<n;i+=2){
        for(int j=0;j<m;j+=2){
            if(x)grid[i][j]='.',x--;
        }
    }
    cout<<n<<" "<<m<<endl;
    for(int i=0;i<n;i++)cout<<grid[i]<<endl;
}


Measured memory_bytes: 256
//Sample 1 may be wrong:(
#include <iostream>
using namespace std;

int num[9];
bool used[10] = {false};

bool check() {
	int ssum = 0;
	
	ssum += num[0] + num[2] + num[5] - num[8];
	ssum += (num[1] + num[4] - num[7]) * 10;
	ssum += (num[3] - num[6]) * 100;
	return (ssum == 0);
}

int dfs(int id) {
	if (id == 9) { return check(); }
	if (num[id] != -1) { return dfs(id + 1); }
	
	int i;
	int ret = 0;
	for (i = 1; i <= 9; i++) {
		if (used[i]) { continue; }
		num[id] = i;  used[i] = true;
		ret += dfs(id + 1);
		num[id] = -1; used[i] = false;
	}
	return ret;
}

int main() {
	int i;
	
	for (i = 0; i < 9; i++) {
		cin >> num[i];
		if (num[i] != -1) {
			used[num[i]] = true;
		}
	}
	
	cout << dfs(0) << endl;
	return 0;
}

Measured memory_bytes: 3096
require 'bigdecimal'

N, K = gets.chomp.split(' ').map(&:to_i)

def win_rate_at(i)
  return 0.upto(100) { |m| break BigDecimal(1) / BigDecimal(2**m) if i * 2**m >= K }
end

puts begin
  1.upto(N).map do |i|
    win_rate_at(i)
  end.inject(0, &:+) / N
end.to_s("F")


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

using namespace std;

int main()
{
	string o, e;
	cin >> o >> e;

	if (o.size() == e.size())
	{
		for (int i = 0; i < o.size(); i++)
		{
			cout << o.at(i) << e.at(i);
		}
		cout << endl;
	}
	else
	{
		for (int i = 0; i < e.size(); i++)
		{
			cout << o.at(i) << e.at(i);
		}
		cout << o.at(o.size() - 1) << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    string s;
    cin>>s;
    int q;
    cin>>q;
    vector<int>v;
    vector<pair<pair<int,char>,int> >all;
    for(int i=1; i<=q; i++)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            v.push_back(i);
        }
        else
        {
            int f;
            char c;
            cin>>f>>c;
            all.push_back({{f,c},i});
        }
    }
    string samne;
    string pise;
    for(auto u:all)
    {
        int f=u.first.first;
        char c=u.first.second;
        int i=u.second;
        int pore=v.size()-(lower_bound(v.begin(),v.end(),i)-v.begin());
        if(f==1&&(pore%2==0))
        {
            samne+=c;
        }
        else if(f==2&&(pore%2==1))
        {
            samne+=c;
        }
        else if(f==1&&(pore%2==1))
        {
            pise+=c;
        }
        else
            pise+=c;
    }
    reverse(samne.begin(),samne.end());
    if(v.size()%2==1)
        reverse(s.begin(),s.end());
    cout<<samne+s+pise;
}



Measured memory_bytes: 4788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N],B[N];
    rep(i,N){
        if(!i){A[i]=1; B[N-i-1]=1;}
        else {
            A[i]=A[i-1]+20002;
            B[N-i-1]=B[N-i]+20002;
        }
    }
    rep(i,N){
        int a; cin >> a;
        a--;
        A[a]+=i;
    }
    rep(i,N) cout << A[i] << " ";
    cout << endl;
    rep(i,N) cout << B[i] << " ";
    cout << endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  string red, green, south;
  while (cin >> red) {
    if (red == "-")
      break;
    cin >> green >> south;
    string east = string("");
    int r = 0, g = 0, s = 0;
    enum Push {right = 0, down};
    enum Push bef = right;
    while (g < green.size() || r < red.size()) {
      if (bef == right)
        if (green[g] == south[s]) {
          s++;
          g++;
          bef = down;
        } else {
          east += green[g];
          g++;
        }
      else
        if (red[r] == south[s]) {
          s++;
          r++;
        } else {
          east += red[r];
          r++;
          bef = right;
        }
    }
    cout << east << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
// editorial
#include<iostream>
#include<vector>
#include<set>
using namespace std;

// 簡易UF
struct UF{
    vector<int> p, m;
    int n;

    UF(int siz){
        n = siz;
        p.resize(n, 0);
        m.resize(n, 1);
        for(int i = 0; i < n; i++)  p[i] = i;
    }

    int parent(int x){
        if(p[x] != x)   p[x] = parent(p[x]);
        return p[x];
    }

    bool same(int x, int y){
        return parent(x) == parent(y);
    }
    
    void unite(int x, int y){
        x = parent(x), y = parent(y);
        if(x == y)  return;
        m[y] += m[x];
        p[x] = y;
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n), xrev(n), yrev(n);
    for(int i = 0; i < n; i++)  cin >> x[i] >> y[i], xrev[--x[i]] = i, yrev[--y[i]] = i;
    set<int> s; // y-axis
    UF uf(n);
    for(int i = 0; i < n; i++){
        int ind = xrev[i];
        if(!s.empty() && *s.begin() < y[ind]){
            uf.unite(yrev[*s.begin()], ind);
            auto it = s.begin();
            it++;
            while(it != s.end() && *it < y[ind]){
                uf.unite(yrev[*it], ind);
                it = s.erase(it);
            }
        }else{
            s.insert(y[ind]);
        }
    }
    for(int i = 0; i < n; i++)  cout << uf.m[uf.parent(i)] << endl;
    return 0;
}

Measured memory_bytes: 12392
using System;
using System.Collections;
using System.Collections.Generic;

class Program {

    static void Main (string[] args) {
        long N = long.Parse (Console.ReadLine ());
        var factor = new Factorization (N);
        var dic = new Dictionary<long, long> ();
        foreach (var value in factor.Calc ()) {
            if (dic.ContainsKey (value)) {
                dic[value]++;
            } else {
                dic.Add (value, 1);
            }
        }
        long ans = 0;
        foreach ((long key, long value) in dic) {
            ans += (long) Math.Floor ((-1 + Math.Sqrt (1 + 8 * (double) value)) / 2);
        }
        Console.WriteLine (ans);
    }

    //1000000007
}

public class Factorization {
    private static long N;

    public Factorization (long n) { N = n; }

    public static long GCD (long a, long b) {
        if (a < b) return GCD (b, a);
        long r;
        while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    public static bool IsPrime (long n) {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        double root = Math.Sqrt (n);
        for (int i = 3; i <= root; i += 2) {
            if (n % i == 0) return false;
        }
        return true;
    }

    private static int[] TryPrimes = new int[] { 2, 3, 5, 7, 11 };
    public long TryAllocation (long p) {
        long count = 0;
        while (N % p == 0) {
            count++;
            N /= p;
        }
        return count;
    }

    private int[] xi = new int[] { 13, 17, 19, 23, 29 };
    private long f (long x, int suffix) {
        return (xi[suffix % xi.Length] * x + suffix) % N;
    }

    public long PollardsRho (long n, int suffix = 0) {
        if (IsPrime (n)) return n;
        long x = 2, y = 2, d = 1;
        while (d == 1) {
            x = f (x, suffix);
            y = f (f (y, suffix), suffix);
            d = GCD (Math.Abs (x - y), n);
        }
        if (d == n) {
            return PollardsRho (n, suffix + 1);
        }
        return d;
    }

    public IEnumerable<long> Calc () {
        foreach (var prime in TryPrimes) {
            var box = TryAllocation (prime);
            for (int i = 0; i < box; i++) yield return prime;
        }

        while (true) {
            if (N == 1) break;
            var ret = PollardsRho (N);
            yield return ret;
            N /= ret;
        }
    }
}
//dotnet run --project test

Measured memory_bytes: 27876
// input macro start
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        n: usize,
        t:i64,
        a:i64,
        h:[i64;n]
    }
    let t = t * 1000;
    let a = a * 1000;
    let mut now = t - (h[0] * 6);
    let mut ans = 1;
    for i in 1..n {
        if ((t - h[i] * 6) - a).abs() < (now - a).abs() {
            now = t - h[i] * 6;
            ans = i + 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String []args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int animals=Integer.parseInt(st.nextToken());
        int legs=Integer.parseInt(st.nextToken());
        int A=0;
        int B=0;
        A=((4*animals)-legs)/2;
        B=(legs-(2*animals))/2;
        if(A+B==animals && 2*A+4*B==legs && A>=0 && B>=0)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}


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

int main(){
    int n,ans;
    string s;
    cin >> n >> s;
    
    for(int i = 0; i < 1000; i++){
        int c[3] = {i/100, (i/10)%10, i%10};
        int f = 0;
        for(int j=0; j<n; j++){
            if(s[j] == ('0' + c[f])) f++;
            if(f == 3) break;
            
        }
    if(f == 3) ans++;    
    } 
    cout << ans << endl;
    
   /*
   for(int i=0; i<n; i++){
       cout << s[i] << endl;
   }
   */
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
a = [0]*n
count=m=0;

s.sort()

for i in list(range(1,n)):
    if(s[i]==s[i-1]):
        count+=1
    else:
        count=0
    a[i]=count
    if(m<count):m=count

for i in range(n):
    if(a[i]==m):
        print(s[i])

Measured memory_bytes: 32868
object Main extends App {
  var get = readLine
  var a = get.split(" ")(0).toInt
  var b = get.split(" ")(1).toInt
  var c = get.split(" ")(2).toInt
  var sum = 0
  var loop = Math.max(a,b)
  var d = 0
  while(loop > 0) {
    if(a % loop == 0 && b % loop == 0){
      sum += 1
      if(sum == c)
		  d = loop
    }
    loop -= 1
  }
  println(d)
}

Measured memory_bytes: 25508
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    if S == "keyence":
        print "YES"
        return
    for i in range(len(S)):
        for j in range(len(S)):
            new_S = S[:i] + S[j:]
            if new_S == "keyence":
                print "YES"
                return

    print "NO"

if __name__ == '__main__':
    main()

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

using namespace std;

int S[10000],top;

typedef struct pp
{
    char name[100];
    int t;
} P;

P Q[100005];
int head,tail,n;

void enqueue(P x)
{
    Q[tail]=x;
    tail=(tail+1)%100005;
}

P dequeue()
{
    P x=Q[head];
    head=(head+1)%100005;
    return x;
}

int main()
{
    int elap=0,c;
    P u;
    int i,q;

    cin>>n>>q;

    for(int i=1;i<=n;++i)
    {
        cin>>Q[i].name>>Q[i].t;
    }

    head=1;tail=n+1;

    while(head!=tail)
    {
        u=dequeue();
        c=min(u.t,q);
        u.t-=c;
        elap+=c;
        if(u.t>0)
        {
            enqueue(u);
        }
        else
        {
            cout<<u.name<<" "<<elap<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 13244
import * as fs from 'fs';

const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n');

const N = +input[0];
const S = input[1];

const ans = {
  x: 0,
  y: 0,
  index: -1,
};
let maxCnt = 0;
for (let i = 0; i < N; i++) {
  const set = new Set();
  let cnt = 0;
  const x = S.substr(0, i);
  const y = S.substr(i);
  for (const c of x) {
    set.add(c);
  }
  for (const c of y) {
    if (set.has(c)) {
      set.delete(c);
      cnt += 1;
    }
  }
  maxCnt = Math.max(maxCnt, cnt);
}
console.log(maxCnt);


Measured memory_bytes: 8072
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

N = int(input())

children = [[] * N for i in range(N)]
for i in range(N)[1:]:
    a = int(input()) - 1
    children[a].append(i)

def dfs(n):
    if children[n] == []:
        return 0
    dp = [dfs(child) for child in children[n]]
    dp.sort(reverse=True)
    return max(dp[i] + (i + 1) for i in range(len(dp)))

print(dfs(0))


Measured memory_bytes: 251440
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define INF 9999999
#define LINF 99999999999
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}

bool cmp(pair<ll,ll> l, pair<ll,ll> r){
	return l.first<r.first;
}

int func(int keta, vector<int> n, int i, bool three, bool five, bool seven, bool ok){
	int ans = 0;
	if(keta == i){
		if(three && five && seven){
			return 1;
		}else{
			return 0;
		}
	}
	if(ok){
		if(!three&&!five&&!seven){
			ans += func(keta, n, i+1, three, five, seven, true);
		}
		ans += func(keta, n, i+1, true, five, seven, ok);
		ans += func(keta, n, i+1, three, true, seven, ok);
		ans += func(keta, n, i+1, three, five, true, ok);
		//ans += func(keta, n, i+1, three, five, seven, ok) * 7;
		return ans;
	}
	
	int memo = 0;
	bool mada = true;

	if(n[i] >= 0 && !three&&!five&&!seven){

		ans += func(keta, n, i+1, three, five, seven, true);

		
		if(i == 0){
			//cout<<ans<<" ";
		}
		memo++;
	}	
	if(n[i] >= 3){
		if(n[i] == 3){
			ans += func(keta, n, i+1, true, five, seven, ok);
			mada = false;
		}else{
			ans += func(keta, n, i+1, true, five, seven, true);
		}
		
		if(i == 0){
			//cout<<ans<<" ";
		}
		memo++;
	}
	if(n[i] >= 5){
		if(n[i] == 5){
			ans += func(keta, n, i+1, three, true, seven, ok);
			mada = false;
		}else{
			ans += func(keta, n, i+1, three, true, seven, true);
		}
		if(i == 0){
			//cout<<ans<<" ";
		}
		memo++;
	}
	if(n[i] >= 7){
		if(n[i] == 7){
			ans += func(keta, n, i+1, three, five, true, ok);
			mada = false;
		}else{
			ans += func(keta, n, i+1, three, five, true, true);
		}
		if(i == 0){
			//cout<<n[i]<<" ";
		}
		memo++;
	}

	
	return ans;
}
 
int main(void){
	string s;
	cin>>s;
	int keta = s.length();
	vector<int> n;
	rep(i,keta){
		n.push_back(s[i] - '0');
	}
	cout<<func(keta,n,0,false,false,false,false)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
 
int main(void) {
	int a, b, c;
	int k;
	int p;
	int q;
	
	cin >> a >> b >> c;
	cin >> k;
	p = max(a, max(b, c));
	q = p;
	FOR(i, 1, k) {
		p *= 2;
	}
	p += a + b + c-q ;
	cout << p << endl;
 
 
	return 0;
}

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



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

	int h, w, a, b; cin >> h >> w >> a >> b;
	int cnt = 0;
	for (int i = 0; i < b; i++) {
		for (int j = 0; j < a; j++) {
			cout << 1;
		}
		for (int j = a; j < w; j++) {
			cout << 0;
		}
		cout << endl;
	}
	for (int i = b; i < h; i++) {
		for (int j = 0; j < a; j++) {
			cout << 0;
		}
		for (int j = a; j < w; j++) {
			cout << 1;
		}
		cout << endl;
	}
}

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

bool solve(){
    int H,W;
    cin>>H>>W;
    vector<string> a(H);
    rep(y,H) cin>>a[y];
    int alpha[26]={};
    rep(y,H)rep(x,W) {
        alpha[a[y][x]-'a']++;
    }
    int set4=0,set2=0;
    rep(c,26){
        set4 += alpha[c]/4;
        set2 += ((alpha[c]%4)>=2);
    }
    set4 -= (H/2)*(W/2);
    if(set4<0) return false;
    return set2+set4*2 == (W%2)*(H/2)+(H%2)*(W/2);
}

int main(void){
    cout<<(solve() ? "Yes" : "No")<<endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::marker::Bytes;
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut w: [i32; 3],
        s: [Bytes; n],
    }

    for i in 0..3 {
        w[i] = w[i].min(2);
    }
    let w = [w[0], w[1], w[2]];
    let mut dp: Vec<HashMap<[i32; 3], i32>> = Vec::new();
    let mut h: HashMap<[i32; 3], i32> = HashMap::new();
    h.insert(w, -1);
    dp.push(h);

    let mut x: HashMap<Vec<u8>, Vec<usize>> = HashMap::new();
    x.insert("AB".as_bytes().to_vec(), vec![0, 1]);
    x.insert("AC".as_bytes().to_vec(), vec![0, 2]);
    x.insert("BC".as_bytes().to_vec(), vec![1, 2]);
    for i in 0..n {
        let mut h: HashMap<[i32; 3], i32> = HashMap::new();
        let y = &x[&s[i]];
        for (v, _) in &dp[i] {
            let mut v_ = *v;
            v_[y[0]] += 1;
            v_[y[1]] -= 1;
            if v_[y[1]] >= 0 {
                h.insert(v_, 0);
            }
            let mut v_ = *v;
            v_[y[0]] -= 1;
            v_[y[1]] += 1;
            if v_[y[0]] >= 0 {
                h.insert(v_, 1);
            }
        }

        dp.push(h);
    }

    if dp[n].is_empty() {
        println!("No");
        return;
    }
    for (k, _) in &dp[n] {
        let mut ans: Vec<usize> = Vec::new();
        let mut k = *k;
        for i in 0..n {
            let j = n - 1 - i;
            let p = dp[j + 1].get(&k).unwrap();
            let p = *p as usize;
            ans.push(p);
            let y = &x[&s[j]];
            k[y[p]] -= 1;
            k[y[p ^ 1]] += 1;
        }

        println!("Yes");
        ans.reverse();
        for i in 0..n {
            println!("{}", s[i][ans[i]] as char);
        }
        break;
    }
}


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

// int max: 2 x 10^9, long long max: 9 x 10^18

using namespace std;

int main()
{
  long long r, d, x;
  cin >> r >> d >> x;
  
  vector<long long> result(10);
  result[0] = r * x - d;
  cout << result[0] << endl;
  for(int i=1; i<10; i++){
    result[i] = r * result[i-1] - d;
    cout << result[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3156
//#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
//#include <cmath>

using namespace std;

#define _DBG_


int main(void) {
	int A, B, C, K;

	cin >> A >> B >> C >> K;

	int res = 0;
	if (A >= K) {
		res = K;
	}
	else if ((A + B) >= K) {
		res = A;
	}
	else{
		res = A - ( K - A - B );
	}
	
	
	cout << res << endl;

#ifdef _DBG_
	cin >> A;
#endif

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define LL long long
#define PII pair<long long,long long>
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int maxn = 2e5+10;
int n;
LL a,d;
PII b[maxn];
LL cnt[maxn];
int main(){
  	cin>>n>>d>>a;
  	d<<=1;
  	for (int i=1;i<=n;i++){
    	cin>>b[i].fi>>b[i].se;
    }
  	sort(b+1,b+1+n);
  	int tail = 1;
  	LL sum = 0;
  	for (int i=1;i<=n;i++){
      	cnt[i] += cnt[i-1];
    	if (cnt[i] * a >= b[i].se) continue;
      	b[i].se -= cnt[i] * a;
      	LL t = (b[i].se + a - 1) / a;
      	sum += t;
      	cnt[i] += t;
      	while (tail <= n && b[tail].fi <= b[i].fi + d) tail++;
      	cnt[tail] -= t;
    }
  	cout<<sum<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int t[n];
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        sum += tmp;
        t[i] = tmp;
    }
    int m;
    cin >> m;
    int p[m], x[m];
    for (int i = 0; i < m; i++)
        cin >> p[i] >> x[i];

    for (int i = 0; i < m; i++) {
        cout << sum - t[p[i] - 1] + x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def dfs(i, j):
    global ans
    if i == n:
        ans = min(ans, j)
    else:
        dfs(i + 1, 2 * j)
        dfs(i + 1, j + k)

n = int(input())
k = int(input())

ans = float('inf')
dfs(0, 1)
print(ans)



Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const int MOD = 1e9 + 7;

string S;
ll N,ans=0,Q;
ll an[100000];
ll cnt[100000];

int main(void) {
	
	cin >> N >> Q;
	cin >> S;
	FOR(i, 1, N) {
		if (S[i] == 'C'&&S[i - 1] == 'A')cnt[i] += 1;
		cnt[i] += cnt[i - 1];
	}
	FOR(i, 0, Q) {
		ll l = 0, r = 0;
		cin >> l >> r;
		an[i] = cnt[r-1] - cnt[l-1];


	}
	FOR(i, 0, Q)ct(an[i]);

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#define EPS (1e-10)
#define equals(a,b) (fabs(a)-fabs(b)<EPS)

using namespace std;

class Point{
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p) { return Point(x+p.x,y+p.y); }
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double a) { return Point(x*a,y*a); }
    Point operator / (double a) { return Point(x/a,y/a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x+y*y; }

    bool operator < (const Point &p) const {
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;

///Program 16.3 表示线段的结构体
struct Segment{
    Point p1,p2;
};

///Program 16.4 表示直线的结构体
typedef Segment Line;

///Program 16.6 多边形
typedef vector<Point> Polygon;

///内积
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
///外积
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double norm(Point p) { return p.x*p.x+p.y*p.y; }
double abs(Point p) { return sqrt(norm(p)); }


int contains(Polygon g,Point p){
    int n=g.size();
    bool x=false;
    for(int i=0;i<n;i++){
        Point a=g[i]-p,b=g[(i+1)%n]-p;
        if(abs(cross(a,b))<EPS&&dot(a,b)<EPS)   return 1;
        ///如果a和b的外积大小为0且内积小于等于0，则点p位于gigi+1上
        if(a.y>b.y) swap(a,b);
        if(a.y<EPS&&EPS<b.y&&cross(a,b)>EPS)    x=!x;
    }
    return (x?2:0);
}

int main()
{
    Point tmp;
    Polygon pgn;
    int g,p;
    scanf("%d",&g);
    for(int i=0;i<g;i++){
        scanf("%lf%lf",&tmp.x,&tmp.y);
        pgn.push_back(tmp);
    }
    scanf("%d",&p);
    for(int i=0;i<p;i++){
        scanf("%lf%lf",&tmp.x,&tmp.y);
        printf("%d\n",contains(pgn,tmp));
    }
    return 0;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

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

	vector<string> dic;
	
  string s;
    cin >> s;
 
    bool ans = true;
    int i = s.size() - 1;
    while (i >= 0 && ans)
    {
        if (i >= 6 && s.substr(i - 6, 7) == "dreamer")       i -= 7;
        else if (i >= 5 && s.substr(i - 5, 6) ==  "eraser")  i -= 6;
        else if (i >= 4 && s.substr(i - 4, 5) == "dream")    i -= 5;
        else if (i >= 4 && s.substr(i - 4, 5) == "erase")    i -= 5;
        else                                                 ans = false;
    }
 
    cout << (ans ? "YES\n" : "NO\n");

	return 0;
}



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

int N, M;
vector<vector<int>> switches(11);
vector<int> kiguu(11);
vector<bool> switchs(11);
int counter = 0;

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

  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      a--;
      switches.at(i).push_back(a);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> kiguu.at(i);
  }

  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<11> s(tmp);
    for (int i = 0; i < M; i++) {
      bitset<11> b;
      for (int j = 0; j < switches.at(i).size(); j++) {
        b.set(switches.at(i).at(j), 1);
      }
      b &= s;
      if (b.count() % 2 != kiguu.at(i)) {
        break;
      }
      if (i == M - 1) {
        counter++;
      }
    }
  }
  cout << counter << endl;
}


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

const int SIZE = 1000000000;

int main() {
    int A, B, K;

    cin >> A >> B >> K;

    for (int i = 0; i < K; i++) {
        if (i % 2 == 0) {
            if (A % 2 == 1) {
                A -= 1;
            }
            B += A/2;
            A /= 2;
        } else {
            if (B % 2 == 1) {
                B -= 1;
            }
            A += B/2;
            B /= 2;
        }
    }

    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

const int N = 50;

ll f(ll x){
    x++;
    ll ret = 0;
    for(int i=0;i<N;i++){
        ll a = 1LL << i;
        ll b = 1LL << (i+1);
        ll r = x % b;
        ll z = max(0LL, r - a);
        ll cnt = z + (a * (x/b));
        if(cnt%2==1){
            ret |= (1LL << i);
        }
    }
    return ret;
}

int main(){
    ll a,b; cin >> a >> b;
    if(a==0){
        cout << f(b) << endl;
        return 0;
    }

    ll x = f(a-1);
    ll y = f(b);
    cout << (x^y) << endl;
}


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

int main()
{
	int l;
	cin >> l;
	double ans;
	if (l % 3 == 0) {
		ans = pow(l / 3.0, 3);
	} else {
		double x, y;
		x = l / 3.0;
		y = l - (x * 2);
		ans = x * x * y;
	}
	printf("%.12lf\n", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int X;
    cin >> X;
    map<int, string> m;
    m[0] = "thu";
    m[1] = "fri";
    m[2] = "sat";
    m[3] = "sun";
    m[4] = "mon";
    m[5] = "tue";
    m[6] = "wed";
    cout << m[X  % 7] << "\n";
    return 0;
}


Measured memory_bytes: 3208
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1e9+7

typedef long long ll;
 
int main()
{
	string s;
    ll ans = 0;

	cin >> s;
	int n = s.size();

	for (int i = 0; i < (1 << (n - 1)); ++i) {
		ll sum = 0, cur = 0;

		for(int j = 0; j < n; ++j){

			cur = cur*10 + (s[j]-'0');
			
			if( i >> j & 1 || j == n - 1){
				sum += cur;
				cur = 0;
			}
		}
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def solve(h, w):
    res = float('inf')
    for hh in range(h + 1):
        s1 = hh * w
        ww = w // 2
        s2 = (h - hh) * ww
        s3 = (h - hh) * (w - ww)
        res = min(res, max(s1, s2, s3) - min(s1, s2, s3))
    return res


H, W = map(int, input().split())

ans = H * W
if H % 3 == 0 or W % 3 == 0:
    ans = 0
else:
    ans = min(H, W)

ans = min(ans, solve(H, W))
ans = min(ans, solve(W, H))
print(ans)


Measured memory_bytes: 3064
b=('2','4','5','7','9')

c=('0','1' ,'6','8')

d=('3')

a=input()

y=a[::-1]

if y[0] in b:

  print("hon")

elif y[0] in c:

  print("pon")

elif y[0] in d:

  print("bon")

  

  

Measured memory_bytes: 9068
#include<bits/stdc++.h>
//#include<unordered_map>
using namespace std;
map<int,vector<int> >  nei[100005];
map<int,int> dp[100005];
vector<pair<int,int> >alnei[100005];
struct Node
{
	int cost,color,v;
	Node (int cos,int col,int u)
	{
		cost=cos;
		color=col;
		v=u;
	}
	bool operator <(Node a) const
	{
		return cost>a.cost;
	}
};
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		nei[x][z].push_back(y);
		nei[y][z].push_back(x);
		alnei[x].push_back(make_pair(y,z));
		alnei[y].push_back(make_pair(x,z));
	}
	priority_queue<Node> q;
	q.push(Node(0,0,0));
	while(!q.empty())
	{
		Node tmp=q.top();
		q.pop();
		int v=tmp.v,cost=tmp.cost,col=tmp.color;
		if(dp[v][col]!=cost) continue;
		if(dp[v].find(0)==dp[v].end()||dp[v][0]>cost)
		{
			dp[v][0]=cost;
			q.push(Node(cost,0,v));
		}
		if(col==0)
		{
			for(int i=0;i<alnei[v].size();i++)
			{
				int u=alnei[v][i].first,colu=alnei[v][i].second;
				if(dp[u].find(colu)==dp[u].end()||dp[u][colu]>cost+1)
				{
					dp[u][colu]=cost+1;
					q.push(Node(cost+1,colu,u));
				}
			}
			continue;
		}
		for(int i=0;i<nei[v][col].size();i++)
		{
			int u=nei[v][col][i],colu=col;
			if(dp[u].find(colu)==dp[u].end()||dp[u][colu]>cost)
			{
				dp[u][colu]=cost;
				q.push(Node(cost,colu,u));
			}
		}
	}
	int mi=1e9;
	for(map<int,int>::iterator it=dp[n-1].begin();it!=dp[n-1].end();it++)
	{
		mi=min(it->second,mi);
	}
	if(mi==1e9) cout<<-1; else cout<<mi;
}

Measured memory_bytes: 86196
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> N;
    vector<vector<string>> mem(10 + 1);
    mem[1].push_back("a");
    mem[2].push_back("aa");
    mem[2].push_back("ab");
    dump("hoge");
    for (int i = 3; i <= N; i++) {
        REP(j, mem[i - 1].size()) {
            string tmp = mem[i - 1][j];
            sort(ALL(tmp));
            UNIQUE(tmp);
            REP(k, tmp.size()) {
                mem[i].push_back(mem[i - 1][j] + tmp[k]);
            }
            mem[i].push_back(mem[i - 1][j] + char(tmp[tmp.size() - 1] + 1));
        }
    }
    REP(i, mem[N].size()) {
        cout << mem[N][i] << endl;
    }
}


Measured memory_bytes: 9588
#
# abc042 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3
dxx
axx
cxx"""
        output = """axxcxxdxx"""
        self.assertIO(input, output)


def resolve():
    N, L = map(int, input().split())
    S = []
    for _ in range(N):
        S.append(input())
    S.sort()
    ans = ""
    for i in range(len(S)):
        ans += S.pop(0)
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16176
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.math.*;

import static java.util.Comparator.*;


public class Main {
    public static void main(String[] args) throws IOException {
        FastReader s = new FastReader();
        int k=s.nextInt();
        HashMap<Integer,List<String>> map=new HashMap<>();
        List<String> list=new ArrayList<>(Arrays.asList("1","2","3","4","5","6","7","8","9"));
        map.put(1,new ArrayList<>(Arrays.asList("1","2","3","4","5","6","7","8","9")));
        int val=2;
        while(list.size()<k)
        {
            List<String> mid=new ArrayList<>();
            List<String> l=map.get(val-1);
            for(String str:l)
            {
                StringBuilder b=new StringBuilder(str);
                int v=Character.getNumericValue(str.charAt(str.length()-1));
                if(v==0)
                {
                    b.append('0');
                    mid.add(b.toString());
                    b=new StringBuilder(str);
                    b.append('1');
                    mid.add(b.toString());
                }
                else if(v==9)
                {
                    b.append('8');
                    mid.add(b.toString());
                    b=new StringBuilder(str);
                    b.append('9');
                    mid.add(b.toString());
                }
                else {
                    for(int i=v-1;i<=v+1;i++)
                    {
                        b.append(i);
                        mid.add(b.toString());
                        b=new StringBuilder(str);
                    }
                }
            }
            map.put(val,new ArrayList<>(mid));
            list.addAll(new ArrayList<>(mid));
            val++;
        }
//        for(String str:list)
//        {
//            System.out.println(str);
//
//        }
        System.out.println(list.get(k-1));

    }

}


class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 53204
#include <stdio.h>

int main(){
  int i, j, temp, N, A[100], num=0, mini;
  
  // input
  scanf("%d",&N);
  for(i = 0; i <= N-1; i++)
    scanf("%d",&A[i]);
  
  
  // sort
  for(i = 0; i <= (N-1); i++){
    mini = i;
    for(j = i; j <= (N-1); j++){
      if(A[j] < A[mini]){
	mini = j;
      }
    }
    if(A[i] == A[mini]){
      num--;
    }
  temp = A[i];
  A[i] = A[mini];
  A[mini] = temp;
	num++;
	
  }  

  
  // output
  for(i = 0; i <= N-1; i++){
    if(i == N-1)
      printf("%d",A[i]);
    else
      printf("%d ",A[i]);
    
  }
  printf("\n");
  printf("%d\n",num);
  return 0;
  
} 

Measured memory_bytes: 604
from math import atan, degrees

a, b, x = map(int, input().split())


if x <= pow(a, 2) * b / 2:
    print(90 - degrees(atan((2 * x) / (a * pow(b, 2)))))
else:
    print(degrees(atan((2 * b - 2 * x / pow(a, 2)) / a)))



Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll A,B,C,D; cin>>A>>B>>C>>D;
    ll gcd=C/__gcd(C,D)*D;
    ll cok=B/C-A/C;
    if(A%C==0)cok++;
    ll dok=B/D-A/D;
    if(A%D==0)dok++;
    ll cdok=B/(gcd)-A/(gcd);
    if(A%(gcd)==0)cdok++;
    ll ans =B-A+1-(cok+dok-cdok);
    cout<<ans<<endl;
}


Measured memory_bytes: 256