akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define INF 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    getMat(arr, 3, 3, 0);
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> arr[i][j];
        }
    }
    getMat(marked, 3, 3, 0);
    int n; cin >> n;
    while (n--) {
        int x; cin >> x;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (x == arr[i][j]) {
                    marked[i][j] = 1;
                }
            }
        }
    }

    int poss = false;
    for (int i = 0; i < 3; i++) {
        int p = true;
        for (int j = 0; j < 3; j++) {
            if (!marked[i][j]) {
                p = false;
            }
        }
        if (p) {
            poss = true;
            break;
        }
    }

    for (int j = 0; j < 3; j++) {
        int p = true;
        for (int i = 0; i < 3; i++) {
            if (!marked[i][j]) {
                p = false;
            }
        }
        if (p) {
            poss = true;
            break;
        }
    }

    if (marked[1][1] == marked[2][2] and marked[2][2] == marked[0][0] and marked[1][1] == 1) {
        poss = true;
    }

    if (marked[0][2] == marked[1][1] and marked[2][0] == marked[1][1] and marked[1][1] == 1) {
        poss = true;
    }

    if (poss) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

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

const int INF = 1e+8;
// dp[曲][未使用のサイリウム][Lv2のサイリウム][Lv1のサイリウム] := 満足度
int dp[51][51][51][51];

int main(){
	int n, m;
	int a[51], b[51], c[51];
	
	cin >> n >> m;
	for(int i=0 ; i < n ; i++ ){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	for(int i=0 ; i < 51 ; i++ ){
		for(int j=0 ; j < 51 ; j++ ){
			for(int k=0 ; k < 51 ; k++ ){
				for(int l=0 ; l < 51 ; l++ ){
					dp[i][j][k][l] = -INF;
				}
			}
		}
	}
	dp[0][m][0][0] = 0;
	for(int i=0 ; i < n ; i++ ){
		for(int j=0 ; j <= m ; j++ ){
			for(int k=0 ; k <= m ; k++ ){
				for(int l=0 ; l <= m ; l++ ){
					if( dp[i][j][k][l] != -INF ){
						// 未使用サイリウムを s 本折る.
						for(int s=0 ; s <= min(8,j) ; s++ ){ 
							// Lv2 サイリウムを x 本, Lv1サイリウムの y 本振る.
							for(int x=0 ; x <= min(8,s) ; x++ ){
								for(int y=0 ; y <= min(8,k) && x+y <= 8 ; y++ ){
									int cost;
									if( x == 0 && y == 0 ){
										cost = c[i];
									}else{
										cost = a[i] * x + b[i] * y ;
									}
									dp[i+1][j-s][s][k] = max( dp[i+1][j-s][s][k], dp[i][j][k][l] + cost );
								}
							}
						}
					}
				}
			}
		}
	}
	int ans = -INF;
	for(int j=0 ; j <= m ; j++ ){
		for(int k=0 ; k <= m ; k++ ){
			for(int l=0 ; l <= m ; l++ ){
				if( dp[n][j][k][l] != -INF ){
					ans = max( ans , dp[n][j][k][l] );
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main(){

    int N;
    cin >> N;

    vector<int> a(N+1);
    for(int i=1; i<=N; i++) cin >> a.at(i);
    vector<bool> used(N+1, false);

    int cnt = 0;
    for(int i=1; i<=N; i++){
        if(used.at(i) == false){
            if(a.at(a.at(i)) == i){
                cnt++;
                used.at(i) = true;
                used.at(a.at(i)) = true;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3788
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let () =
  let ans = ref 0 in
  List.iteri (fun i a ->
    if i mod 2 = 0 && a mod 2 = 1 then incr ans
  ) a;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 3852
import sys
sys.setrecursionlimit(10**7)

N = int(input())
H = list(map(int, input().split()))


def need(L):
    if L == [] or max(L) == 0:
        return 0
    if min(L) > 0:
        l = [L[i]-1 for i in range(len(L))]
        return need(l)+1
    else:
        i = L.index(0)
        l = L[:i]
        m = L[i+1:]
        return need(l)+need(m)


print(need(H))


Measured memory_bytes: 73820
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}


ll h,w;
char arr[1004][1004];
ll dp[1004][1004];



void test_case() {

    cin>>h>>w;

    for(int i=1; i<=h; i++) {
        for(int j=1; j<=w; j++) {
            cin>>arr[i][j];
        }
    }

    ll ans = 0;
    memset(dp,0,sizeof(dp));
    dp[1][1] = 1;
    for(int i=2; i<=h; i++) {
        if(arr[i][1] == '.') {
            dp[i][1] = dp[i-1][1];
        }
    }

    for(int j=2; j<=w; j++) {
        if(arr[1][j] == '.') {
            dp[1][j] = dp[1][j-1];
        }
    }


    for(int i=2; i<=h; i++) {
        for(int j=2; j<=w; j++) {
            if(arr[i][j] == '.') {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
            }
        }
    }

    cout<<dp[h][w]%mod <<endl;






}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


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


Measured memory_bytes: 12368
import sys
S, K = input().split()
Bad = list(map(int, input().split()))
OK = sorted(set(range(10)) - set(Bad))
NotZero = sorted(set(OK) - set([0]))

if any(d > str(OK[-1]) for d in S):
    print(str(NotZero[0]) + str(OK[0]) * len(S))
    sys.exit()

count = [0] * 10
for c in str(S):
    count[ord(c) - ord('0')] += 1
greater = 0
ans = []


def can(i, d):
    c = str(d)
    if i == 0 and d == 0 and len(S) > 1:
        return 0
    if not greater and c < S[i]:
        return 0
    if c > S[i]:
        return 1
    for b in range(10):
        if count[b] > 0 and b > OK[-1]:
            return 0
    return 1

for i in range(len(S)):
    count[ord(S[i]) - ord('0')] -= 1
    for d in OK:
        if can(i, d):
            if str(d) > S[i]:
                greater = 1
            ans.append(d)
            break

print("".join(str(a) for a in ans))


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int a[510],b[510];
int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
       cin>>a[i];
    for (int i=0;i<n;i++)
       cin>>b[i];
    int ans=-1;
    for (int i=0;i<n;i++)
    {
        int sum=0;
        for (int j=0;j<=i;j++)
           sum+=a[j];
        for (int j=i;j<n;j++)
           sum+=b[j];
           ans=max(ans,sum);
        //   cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def bubble_sort(a, n):
    count = 0
    flag = 1
    
    while flag:
        flag = 0
        
        for j in range(n-1, 0, -1):
            if a[j] < a[j-1]:
                a[j-1], a[j] = a[j], a[j-1]
                flag = 1
                count += 1
                
    return a, count
            


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

a, count = bubble_sort(a, n)

print(" ".join(map(str, a)))
print(count)


Measured memory_bytes: 5600
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;
    string st;
    char ch;
    while(cin>>n>>k>>a>>b)
    {
        if(k>=n)s=n*a;
        else s=k*a+(n-k)*b;
        cout<<s<<en;
    }
}



Measured memory_bytes: 3636
using System;

namespace aizu
{
    class OnlineJudge
    {
        const int Max = 1000000;
        static void Main()
        {
            Action<Action<int>> rep = p => { for(int i=3; i < Max; i += 2) p(i); };
            bool[] prime = new bool[Max];
            rep(i => prime[i] = true);
            prime[2] = true;
            rep(i => {
                if(prime[i]) {
                    for(int l = 2; i * l < Max; ++l) {
                        prime[l * i] = false;
                    }
                }
            });
            string num;
            int cnt;
            while((num = Console.ReadLine()) != null) {
                int val = int.Parse(num);
                cnt = val >= 2 ? 1 : 0;
                for(int i=3; i <= val; i += 2) {
                    if(prime[i]) {
                        ++cnt;
                    }
                }
                Console.WriteLine(cnt);
            }
        }
    }
}

Measured memory_bytes: 6592
a=input()
a_l=len(a)
b=input()
b_l=len(b)
c=input()
c_l=len(c)
def check(s1,s2):
    l1=len(s1)
    l2=len(s2)
    ret=[0]*(l1+l2-1)
    for i in range(l1+l2-1):
        flag=True
        if i-l2+1<0 and i<=l1-1:
            for j in range(i+1):
                if s1[j]!="?" and s2[l2-i+j-1]!="?" and s1[j]!=s2[l2-i+j-1]:
                    flag=False
                    break
        elif i-l2+1<0 and i>l1-1:
            for j in range(l1):
                if s1[j]!="?" and s2[l2-i+j-1]!="?" and s1[j]!=s2[l2-i+j-1]:
                    flag=False
                    break
        elif i-l2+1>=0 and i<=l1-1:
            for j in range(l2):
                if s1[i-l2+j+1]!="?" and s2[j]!="?" and s1[i-l2+j+1]!=s2[j]:
                    flag=False
                    break
        else:
            for j in range(l1+l2-i-1):
                if s1[i-l2+j+1]!="?" and s2[j]!="?" and s1[i-l2+j+1]!=s2[j]:
                    flag=False
                    break
        ret[i]=flag
    return ret
ab=check(a,b)
ab_l=len(ab)
ac=check(a,c)
ac_l=len(ac)
bc=check(b,c)
bc_l=len(bc)
ans=a_l+b_l+c_l
for i in range(-2000,ab_l+2000):
    if i<0 or i>=ab_l or ab[i]:
        for j in range(-2000,ac_l+2000):
            if j<0 or j>=ac_l or ac[j]:
                if j-i+b_l-1<0 or j-i+b_l-1>=bc_l or bc[j-i+b_l-1]:
                    l=max(a_l-1,i,j)-min(0,i-b_l+1,j-c_l+1)+1
                    ans=min(ans,l)
print(ans)

Measured memory_bytes: 70748
H,W = (int(x) for x in input().split())

S_arr_arr = [[1]*(W+2)]
for i in range(H):
    S_arr_arr.append([0 if s=="." else 1 for s in "#"+input()+"#"])
S_arr_arr.append([1]*(W+2))

W_arr_arr = [[0]*(W+2) for _ in range(H+2)]
for j in range(H+2):
    i_begin = 0
    for i in range(W+2):
        if S_arr_arr[j][i] == 1:
            for ix in range(i_begin+1, i):
                W_arr_arr[j][ix] += i-i_begin-1
            i_begin = i
for i in range(W+2):
    j_begin = 0
    for j in range(H+2):
        if S_arr_arr[j][i] == 1:
            for jx in range(j_begin+1, j):
                W_arr_arr[jx][i] += j-j_begin-1
            j_begin = j

max_ans = max([max(W_arr) for W_arr in W_arr_arr]) - 1

print(max_ans)


Measured memory_bytes: 114524
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "YES"
#define NO  "NO"

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

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

  if (a == b) cout << "Draw";
  else if (a == 1) cout << "Alice";
  else if (b == 1) cout << "Bob";
  else if (b < a)cout << "Alice";
  else cout << "Bob";
  
  // cout << num << endl;
  // cout << (flag ? "H" : "D") << endl;
  
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	long double r;
	cin >> r;
	cout << fixed << setprecision(20) << r*r*M_PI << " " << 2*r*M_PI << endl;
}


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

int main()
{
    vector<int> n(3);
    cin >> n.at(0) >> n.at(1) >> n.at(2);
    std::sort(n.begin(), n.end(), std::greater<int>());
    cout << 10 * n.at(0) + n.at(1) + n.at(2) << endl;
}

Measured memory_bytes: 256
// 2013/11/05 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int N;
		cin >> N;

		if(N==0)
			break;

		int c0 = 0;
		int c1 = 0;
		for(int i=0; i<N; i++){
			int k;
			cin >> k;

			if(k==0){
				c0++;
			}
			else if(k==1){
				c1++;
			}
		}

		if(c0+c1==N){
			cout << "NA" << endl;
		}
		else{
			cout << N-c0+1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1164
import sys
input = sys.stdin.readline

def main():
    a,b,c=map(int,input().split())
    if (a==b and a!=c) or (a==c and a!=b) or (c==b and c!=a):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

int n, m;
vector<int> gr[maxn];

int p[maxn];
bool vis[maxn];

void read_input()
{
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int u, v;
        cin >> u >> v;
        gr[u].push_back(v);
        gr[v].push_back(u);
    }
}

void solve()
{
    fill(vis + 1, vis + n + 1, false);
    queue<int> q;
    q.push(1);
    vis[1] = true;
    while(!q.empty())
    {
        int u = q.front(); q.pop();
        for(auto&to: gr[u])
            if(!vis[to])
            {
                vis[to] = true;
                p[to] = u;
                q.push(to);
            }
    }
    for(int i = 1; i <= n; ++i)
        if(!vis[i])
        {
            cout << "No\n";
            return;
        }
    cout << "Yes\n";
    for(int i = 2; i <= n; ++i)
        cout << p[i] << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 13056
package main

import (
        "bufio"
        "fmt"
        "os"
        "reflect"
)

func solution(n, k int, a []int) []int {
        for k > 0 {
                memo := make([]int, n+1)
                for i := 0; i < n; i++ {
                        l := max(0, i-a[i])
                        r := min(n, i+a[i]+1)
                        memo[l]++
                        memo[r]--

                }

                for i := 0; i < n; i++ {
                        memo[i+1] += memo[i]
                }
                memo = memo[:n]
                if reflect.DeepEqual(a, memo) {
                        break
                }
                a = memo
                k--
        }
        return a
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var n, k int
        fmt.Fscan(r, &n, &k)
        a := make([]int, n)
        for i := range a {
                fmt.Fscan(r, &a[i])
        }
        nums := solution(n, k, a)
        for i, num := range nums {
                if i == len(nums)-1 {
                        fmt.Println(num)
                } else {
                        fmt.Printf("%v ", num)
                }
        }
}

Measured memory_bytes: 16876
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

ctr = Counter(s)

print(f"AC x {0 if ctr.get('AC') is None else ctr.get('AC')}")
print(f"WA x {0 if ctr.get('WA') is None else ctr.get('WA')}")
print(f"TLE x {0 if ctr.get('TLE') is None else ctr.get('TLE')}")
print(f"RE x { 0 if ctr.get('RE') is None else ctr.get('RE')}")


Measured memory_bytes: 82952
y,m,d = input().split('/')

if y > '2019':
  print("TBD")
elif y == '2019':
  if m > '04':
    print("TBD")
  elif m == '04':
    if d > '30':
      print("TBD")
    else:
      print("Heisei")
  else:
    print("Heisei")
else:
  print("Heisei")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

vector<string> vec[12], tem[12], ans;
ll N;
char C[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'};

void solve() {
	vec[1].pb("a");
	cin >> N;
	rep(_, N - 1) {
		rep(i, 11) tem[i].clear();
		for (ll i = 1; i <= 10; i++) {
			for (string s: vec[i]) {
				for (ll j = 1; j <= i; j++) {
					tem[i].pb(s + C[j - 1]);
				}
				tem[i + 1].pb(s + C[i]);
			}
		}
		rep(i, 11) {
			vec[i].clear();
			for (string s: tem[i]) vec[i].pb(s);
		}
	}
	rep(i, 11) for (string s: vec[i]) ans.pb(s);
	sort(ans.begin(), ans.end());
	for (string s: ans) cout << s << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


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


int mod(int x){
    return (x >= 0 ? x : -x);  
}

int main(){
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int d[n];
	d[0] = 0;
	d[1] = mod(a[0]-a[1]);
	for (int i = 2; i < n; ++i)
	{
		d[i] = min(d[i-2] + mod(a[i]-a[i-2]), d[i-1] + mod(a[i]-a[i-1]));
	}
	cout << d[n-1];
}

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

using namespace std;

int main(){
    int N, x, tmp;
    vector<int> A;
    cin >> N >> x;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        A.push_back(tmp);
    }
    sort(A.begin(), A.end());
    int count = 0;
    for(int i = 0; i < N; i++){
        count += A[i];
        if(count > x){
            cout << i << endl;
            return 0;
        }
    }
    if(count != x){
        cout << N-1 << endl;
    }else{
        cout << N << endl;
    }


    return 0;
}

Measured memory_bytes: 256
'use strict'
// n <= 10e5 なのでこれで十分
function main(input) {
  const n = ~~input.trim()
  let count = 0
  for (let i = 1; i <= n; i++) {
    if ((i + '').length % 2) count++
  }
  console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main(){

    int N, M;
    cin >> N >> M;
    int A_sum = 0;
    rep (i, M){
        int temp = 0;
        cin >> temp;
        A_sum += temp;
    }
    int ans = N-A_sum;
    if (0 <= ans) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back

int bexp(int a, int b, int mod)
{
    int res = 1;
    if (mod <= 0)
        return 0;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

#define N 200010
#define MOD 1000000007

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

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int k;

    cin >> k;

    if (k % 7 == 0)
        k /= 7;

    int no = 1 % k;

    for (int i = 0; i < 1000100; ++i)
    {
        if (no == 0)
        {
            cout << i + 1;
            return 0;
        }
        no = (no + bexp(10, i + 1, k)) % k;
    }

    cout << -1;
    return 0;
}


Measured memory_bytes: 3540
// $%U%$
// $%D%$/$%M%$/$%Y%$
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const ll mod = 998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}

int main(){
    int n = nxt(), k = nxt();
    VII a(k);
    REP(i, k){
        cin >> a[i].first >> a[i].second;
    }
    vector<ll> dp(n+1, 0);
    dp[1] = 1;
    REP(i, n){
        if(i == 0) continue;
        if(i) dp[i] += dp[i-1];
        dp[i] %= mod;
        REP(j, k){
            if(i + a[j].first <= n) {
                dp[i+a[j].first] += dp[i];
                dp[i+a[j].first] %= mod;
            }
            if(i + a[j].second + 1 <= n) {
                dp[i+a[j].second+1] += mod - dp[i];
                /* while(dp[i+a[j].second+1] < 0) dp[i+a[j].second+1] += mod; */
                dp[i+a[j].second+1] %= mod;
            }
        }
    }
    /* REP(i, n) printf("%lld\n", dp[i]); */
    printf("%lld\n", dp[n]);
    return 0;
}




Measured memory_bytes: 4876
import java.io.PrintWriter
import java.util.StringTokenizer

fun main() {

    fun PrintWriter.solve() {
        var (n,m,k) = List(3){nextInt()}

        var link = IntArray(n){it}
        var size = IntArray(n){1}

        fun find(x : Int) : Int{
            if (x != link[x])
                link[x] = find(link[x])

            return link[x]
        }

        fun unite(a : Int, b:Int):Unit{
            var a  = find(a)
            var b = find(b)

            if (a != b){
                if (size[b] > size[a])a = b.also { b = a }
                size[a] += size[b]
                link[b] = a
            }
        }

        var graph = Array<Edge>(n){Edge(mutableListOf(), mutableListOf())}
        repeat(m){
            var (a,b) = List(2){nextInt()}
            a--
            b--

            graph[a].friends.add(b)
            graph[b].friends.add(a)

            unite(a,b)
        }

        repeat(k){
            var (c,d) = List(2){nextInt()}
            c--
            d--

            graph[c].blocks.add(d)
            graph[d].blocks.add(c)


        }

        for (i in 0..n-1){
            var ans = size[find(i)]
            for (j in graph[i].friends){
                if (find(i) == find(j)) ans--
            }

            for (j in graph[i].blocks){
                if (find(j) == find(i))ans--
            }

            print("${ans - 1} ")
        }




    }

    writer.solve()
    writer.flush()


}

data class Edge(val friends : MutableList<Int> , val blocks : MutableList<Int>)




private val reader = System.`in`.bufferedReader()
private val writer = PrintWriter(System.out, false)

private var tokenizer: StringTokenizer = StringTokenizer("")

private fun next(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
    return tokenizer.nextToken()
}

private fun nextInt() = next().toInt()

private fun nextLong() = next().toLong()
private fun nextDouble() = next().toDouble()
private fun nextLine() = reader.readLine()



Measured memory_bytes: 86608
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  rep(i, h) rep(j, w) {
    if (s[i][j] == '.') continue;
    if (i > 0 && s[i-1][j] == '#') continue;
    if (i < h-1 && s[i+1][j] == '#') continue;
    if (j > 0 && s[i][j-1] == '#') continue;
    if (j < w-1 && s[i][j+1] == '#') continue;
    puts("No");
    return 0;
  }

  puts("Yes");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n;
        scanf("%d", &n);

        int ans = 1e9;
        while (n--) {
                int a;
                scanf("%d", &a);
                if (a % 2 == 0) {
                        int cnt = 0;
                        do {
                                a >>= 1;
                                cnt++;
                        } while (a % 2 == 0);

                        if (ans > cnt)
                                ans = cnt;
                } else {
                        ans = 0;
                        break;
                }
        }

        printf("%d\n", ans);
        return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a != c) cout << "Yes\n";
  else if (b == c && b != a) cout << "Yes\n";
  else if (a == c && a != b) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
int n,m,d;
char h[1000]="RYGB";
int main()
{
//	freopen("data.in","r",stdin);
	
	int n=read(),m=read(),d=read();
	For(x,n) {
		For(y,m) {
			int px=x+y,py=x-y;
			px+=10000,py+=10000;
			px/=d,py/=d;
			px&=1,py&=1;
			putchar(h[px*2+py]);
		}puts("");
	}
	
	
	
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include<queue>
#include<iomanip>
#include<array>
#include<cmath>
#include<utility>
using namespace std;
#define MAX 100001
#define ll long long

queue<int> next_pos;	//first どこにいくか　second どこからきたか
vector<int> root[MAX];
int dist[MAX];
int ans[MAX];


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

	int N, M;
	cin >> N>> M;
	for (int i = 0; i < M ; ++i)
	{
		int A, B;
		cin >> A >> B;
		root[A-1].push_back(B-1);
		root[B-1].push_back(A-1);
	}

	int pos = 0;
	next_pos.push(pos);
	for (int i = 0; i < MAX; ++i)
	{
		ans[i] = -1;
	}
	while (!next_pos.empty())
	{
		pos = next_pos.front(); next_pos.pop();
		for (auto itr = root[pos].begin(); itr != root[pos].end(); ++itr)
		{
			if (ans[*itr] == -1)
			{
				ans[*itr] = pos;
				next_pos.push(*itr);
			}
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < N; ++i)
	{
		cout << ans[i]+1 << endl;
	}
	
	

	return 0;
}

Measured memory_bytes: 10568
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using namespace std;
bool strategy = 0;

void judge_strategy( int A, int B) {

	if (B - A - 2 <=  0) {
		strategy = 0;
	}
	else {
		strategy = 1;
	}
}


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

	cin >> K >> A >> B;

	unsigned long long biscuits = 0;

	judge_strategy(A, B);

	if (strategy == 0) {
		biscuits = K + 1;
	}
	else {
		long long N;

		if ((K - A) % 2 == 1) {
			N = (K - A + 1) / 2;
			biscuits = N * (B - A) + A;
 		}
		else if ((K - A) % 2 == 0) {
			N = (K - A) / 2;
			biscuits = N * (B - A) + A + 1;
		}
	}

	cout << biscuits << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(long i=0; i<(long)(n);i++)
#define REP(i,s,t) for(long i=s; i<t; i++)
#define RNG(i,s,t,u) for(long i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
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; }


int N;
vector<long> value;
vector<long> delay;
long MONO = 0;

void update(int i, long x){
  i += N-1;
  value.at(i) = x;
  while(i > 0){
    i = (i-1)/2;
    long c1 = value.at(i*2 + 1);
    long c2 = value.at(i*2 + 2);
    value.at(i) = max(c1, c2); //min max 切り替え可能
  }
}

void eval(int k, int l, int r){
  if(delay.at(k) != 0){
    value.at(k) += delay.at(k);
    if(r - l > 1){
      delay.at(2*k+1) = delay.at(k)/2;
      delay.at(2*k+2) = delay.at(k)/2;
    }
    delay.at(k) = 0;
  }
}

void add_range(int a, int b, int k, int l, int r, long x){
  eval(k, l, r);
  if(r <= a || b <= l) return;
  if(a <= l && r <= b){
    delay.at(k) += (r - l) * x;
    eval(k, l, r);
  }else{
    add_range(a, b, 2*k+1, l, (l+r)/2, x);
    add_range(a, b, 2*k+1, (l+r)/2, r, x);
    value.at(k) = value.at(2*k+1) + value.at(2*k+2);
  }
}

long query(int a, int b, int k, int l, int r){ //[a,b)が知りたい区間 [l,r)は初め0,N代入 k=0 現ノード
  if(r <= a || b <= l) return MONO;
  eval(k, l, r);
  if(a <= l && r <= b) return value.at(k);
  else{
    long c1 = query(a, b, 2*k+1, l, (l+r)/2);
    long c2 = query(a, b, 2*k+2, (l+r)/2, r);
    return max(c1, c2); //min max 切り替え可能
  }
}

int main(){
  int n,k;
  cin >> n >> k;
  N = 1;
  while (N < 310000) N *= 2; // 葉の数を計算（n以上の最小の2冪数）
  value = vector<long>(2 * N - 1, MONO);
  delay = vector<long>(2 * N - 1, 0);
  rep(i,n){
    int a;
    cin >> a;
    int l = max(0,a-k);
    int r = min(310000,a+k+1);
    long q = query(a-k,a+k+1,0,0,N);
    //cout << a << " " << q << endl;
    update(a,q+1);
  }
  //rep(i,n) cout << value.at(i+N-1) << endl;
  cout << query(0,N,0,0,N) << endl;
}


Measured memory_bytes: 19604
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(){
int n;
cin>>n;
int ton[n];
for (int i=0; i<n;i++)
    cin >>ton[i];
int ttim=0;
for (int i=0; i<n;i++)
ttim+=ton[i];
int m;
cin>>m;
int p ,x;
int a[m];
for(int i=0;i<m;i++){
    cin>>p>>x;
    a[i]=(ttim-ton[p-1])+x;


}
for (int i=0; i<m;i++)
    cout<<a[i]<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
typedef pair<int,int> pa;
priority_queue<pa,vector<pa>,greater<pa> > q1;
priority_queue<pa> q2;
ll Sum=0,res=0;int n;int used[1000100];
int main()
{
	n=read();
	for(rint i=1;i<=n;++i)
	{
		int x=read(),y=read();
		q1.push(mk(x,i));q2.push(mk(y,i));
		Sum+=y,res+=x;
	}res=min(res,Sum);
	ll Sum1=0,Sum2=0,tot=0;
	for(rint i=1;i<n;++i)
	{
		pa tmp1=q1.top();q1.pop();
		if(!used[tmp1.second]) used[tmp1.second]=1,tot++;
		pa tmp2=q2.top();q2.pop();
		if(!used[tmp2.second]) used[tmp2.second]=1,tot++;
		Sum1+=tmp1.first;Sum2+=tmp2.first;
		if(tot>i)
		{
			res=min(Sum-Sum2+Sum1,res);
		}
		else 
		{
			if(!q1.empty()) res=min(res,Sum-Sum2+Sum1+q1.top().first-tmp1.first);
			if(!q2.empty()) res=min(res,Sum-Sum2+Sum1-q2.top().first+tmp2.first);
		}
	}cout<<res;
	return 0;
}




Measured memory_bytes: 2412
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
 
  public struct City{
    public long num;
    public City(long n){
      num = n;
    }
  }
 
  public static void Main (string[] args) {
    var N = int.Parse(Console.ReadLine());
    var list = new List<long>();

    for(var i = 0; i < N; i++){
      list.Add(long.Parse(Console.ReadLine()));
    }
    
	var ans = list.OrderByDescending(x => x).Skip(1).Take(N).Sum() + list.Max() / 2;
 
    Console.WriteLine(ans);
  }
  
}

Measured memory_bytes: 13396
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

string lcs(const string& a, const string& b) {
  const int n = a.size(), m = b.size();
  vector<vector<int>> X(n + 1, vector<int>(m + 1));
  vector<vector<int>> Y(n + 1, vector<int>(m + 1));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i] == b[j]) {
        X[i + 1][j + 1] = X[i][j] + 1;
        Y[i + 1][j + 1] = 0;
      } else if (X[i + 1][j] < X[i][j + 1]) {
        X[i + 1][j + 1] = X[i][j + 1];
        Y[i + 1][j + 1] = +1;
      } else {
        X[i + 1][j + 1] = X[i + 1][j];
        Y[i + 1][j + 1] = -1;
      }
    }
  }
  string c;
  for (int i = n, j = m; i > 0 && j > 0;) {
    if (Y[i][j] > 0)
      --i;
    else if (Y[i][j] < 0)
      --j;
    else {
      c.push_back(a[i - 1]);
      --i;
      --j;
    }
  }
  reverse(c.begin(), c.end());
  return c;
}

int main() {
  string s, t;
  while (cin >> s >> t) {
    string res = lcs(s, t);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//---------------------------------------------------------------------------------------------------
ll MOD = 1000000007;
ll f[201010], rf[201010];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < 201010; i++) f[i] = (f[i - 1] * i) % MOD;
    for(int i = 0; i < 201010; i++) rf[i] = inv(f[i]);
}
ll C(int n, int k) {
    if(n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}
//---------------------------------------------------------------------------------------------------

int main()
{
    init();
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll> c(26);
    for(int i = 0; i < n; i++)
    {
        c[s[i]-'a']++;
    }
    ll ans = n * (n-1) / 2 + 1;
    for(int i = 0; i < 26; i++)
    {
        if(c[i] > 1) ans -= c[i] * (c[i]-1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3716
# group list
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]

# input
x, y = [int(i) for i in input().split()]

# check group
def check(z):
    if z in C:
        return 'C'
    elif z in B:
        return 'B'
    else:
        return 'A'

group_x = check(x)
group_y = check(y)

if group_x == group_y:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


typedef struct {
    char* title;
    int length;
} music;
#define MAX_TITLE 110

void printPlaylist(music*, int);
int main(void){
    int N;
    music* playlist;

    scanf("%d", &N);
    playlist = (music*)malloc(sizeof(music)*N);
    for(int i=0;i<N;i++){
        int length;

        scanf("%*c%s %d", playlist[i].title = (char*)malloc(sizeof(char) * MAX_TITLE), &length);
        playlist[i].length = length;
    }    

    char* slept;
    scanf("%*c%s", slept = (char*)malloc(sizeof(char)*MAX_TITLE));


    int allsong=0;
    int sleeptime = 0;
    int sleeping = 0;
    for(int j=0; j<N; j++){
        allsong += playlist[j].length;
        if(sleeping==1) sleeptime += playlist[j].length;
        if(strcmp(playlist[j].title, slept)==0) sleeping = 1;
    }
    printf("%d\n", sleeptime);
    
    return 0;
}


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

using LL = long long;
using LD = long double;
 
LL mod = 10e9+7;

int main()
{
	LL n, k;
	cin >> n >> k;

	cout << min(n%k, k - n%k) << "\n";



}

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

bool query(int64_t x){
    char r[2];
    printf("? %" PRId64 "\n", x);
    fflush(stdout);
    scanf("%s", r);
    return r[0] == 'Y';
}
void answer(int64_t x){
    printf("! %" PRId64 "\n", x);
    fflush(stdout);
    exit(0);
}

int main(){
    static int64_t pow10[] = { 1, 10, 100, 1'000, 10'000, 100'000, 1'000'000, 10'000'000, 100'000'000, 1'000'000'000, 10'000'000'000 };
    if(query(pow10[9])){
        for(int i=0;i<9;++i) if(query(pow10[i+1]-1)) answer(pow10[i]);
        answer(pow10[9]);
    }else{
        int l = 0, r = 9;
        while(r - l > 1){
            int m = (l+r) / 2;
            if(query(pow10[m])) l = m;
            else r = m;
        }
        int64_t cand = -1, test = 0;
        for(int d=1;d<=r;++d){
            int dl = -1, dr = 10;
            if(d == 1) ++dl;
            while(dr - dl > 1){
                int m = (dl + dr) / 2;
                if(query(test+m*pow10[r+1-d])) dr = m;
                else dl = m;
            }
            if(dr == 0){
                answer(test/10);
            }else if(dl == 9){
                test += 9*pow10[r+1-d];
            }else{
                cand = test + dr*pow10[r+1-d];
                test += dl*pow10[r+1-d];
            }
        }
        answer(cand/10);
    }

    return 0;
}

Measured memory_bytes: 596
def C():
    n = int(input())
    ret = [None]*12
    q = n
    for i in range(12):
        q,mod = divmod(q,26)
        if mod == 0:
            ret[i] = "z"
            q -= 1
        else:
            ret[i] = chr(mod+96)
        if q == 0:
            break
    ret = ret[:i+1]
    ret.reverse()
    print("".join(map(str,ret)))
C()

Measured memory_bytes: 9196
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code,
  unused_macros
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
//use std::collections::HashSet;
use petgraph::unionfind::UnionFind;
use std::cmp::*;
use std::collections::*;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
const MOD: i64 = 1000_000_007;
fn main() {
  input! {
     S:i64
  }
  println!("{}", solve(S));
}
fn solve(S: i64) -> i64 {
  if S < 3 {
    return 0;
  }
  if S == 3 {
    return 1;
  }
  let mut fact = vec![1; 4001];
  let mut inv = vec![1; 4001];
  let mut ifact = vec![1; 4001];
  for i in 2..=2000 {
    fact[i] = fact[i - 1] * (i as i64) % MOD;
    inv[i] = MOD - inv[(MOD as usize) % i] * (MOD / (i as i64)) % MOD;
    ifact[i] = ifact[i - 1] * inv[i] % MOD;
  }
  let mut choose =
    |n, k| fact[n as usize] * (ifact[k as usize] * ifact[(n - k) as usize] % MOD) % MOD;
  // 分割数nは、最大でも、S/3。あまりが0か1か2。
  // 分割数nのあまりの個数rを、分割したどれかに配置する組み合わせを数えると、rのn分割なので、choose(r+n,n-1)
  let mut ans = 0;
  for n in 1..=(S / 3) {
    let r = S - (n * 3);
    let mut t = 1;
    t = choose(r + n-1, n - 1);
    debug!(S, n, r, t);
    ans = (ans + t) % MOD;
  }
  ans
}


Measured memory_bytes: 2284
#include "iostream"
using namespace std;
 
int main(){
  
 int N;
  int H0,H1;
  int move=0;
 int max=0;
  
   cin >> N;
  
  cin >> H0;
  
  for(int i=1; i<N; i++){
 	 
     cin >> H1;
    
    if(H0>=H1){
      move++;
    }else{
      if(move>max)max=move;
      move=0;
	}
    
    H0=H1;

  }
 
    if(move>max)max=move;

    cout << max;

  
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,aa,bb,tmp;
vector<int> a,b,c;
int main(){
	cin>>n>>aa>>bb;
  	for(int i=1;i<=n;i++){
      cin>>tmp;
      if(tmp<=aa){
      	a.push_back(tmp);
      }
      else if(tmp<=bb){
      	b.push_back(tmp);
      }
      else {
      	c.push_back(tmp);
      }
    }
  	cout<<min({a.size(),b.size(),c.size()});
}

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 <limits>

using namespace std;

long long f(long long b, long long n){
	if(n < b) return n;
	else return f(b, n/b) + (n % b);
}

int main(){
	long long n,s;
	cin>>n>>s;

	if(n < s){
		cout<<"-1"<<endl;
		return 0;
	}

	if(n == s){
		cout<<(n+1)<<endl;
		return 0;
	}

	for(int i=2;i<=sqrt(n);i++){
		if(s == f(i,n)){
			cout<<i<<endl;
			return 0;
		}
	}

	long long b = 10000000000000;
	for(int i=sqrt(n-s);i>=1;i--){
		if(((n-s) % i) == 0){
			long long tmp = ((n-s)/i+1);
			if(s == f(tmp,n)){
				b = min(b,tmp);
			}
		}
	}

	if(b != 10000000000000){
		cout<<b<<endl;
		return 0;
	}

	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 256