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

int main(){
  int N, a[3], i, j;

  scanf("%d",&N);
  for(j = 0 ; j < N ; j++){
    for(i = 0 ; i < 3 ; i++){
      scanf("%d",&a[i]);
    }
    if(a[0]*a[0] == a[1]*a[1] + a[2]*a[2])
      printf("YES\n");
    else if(a[1]*a[1] == a[0]*a[0] + a[2]*a[2])
      printf("YES\n");
    else if(a[2]*a[2] == a[0]*a[0] + a[1]*a[1])
      printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<a*b<<'\n';
    return 0;
}


Measured memory_bytes: 3652
let n = read_int ()
let g = Array.make n []
let ds = Array.make n 0
let rec f v p d = ds.(v) <- d; List.iter (fun (u, c) -> if u <> p then f u v (d + c)) g.(v)

let l = 17
let ps = Array.make_matrix l n 0
let dps = Array.make n 0
let rec dfs v p d = ps.(0).(v) <- p; dps.(v) <- d; List.iter (fun (u, _) -> if u <> p then dfs u v (d + 1)) g.(v)
let lca a b = let u, v = ref a, ref b in if dps.(a) > dps.(b) then (u := b; v := a); for k = 0 to l - 1 do if ((dps.(!v) - dps.(!u)) lsr k) land 1 = 1 then v := ps.(k).(!v) done; if !u = !v then !u else (for k = l - 1 downto 0 do if ps.(k).(!u) <> ps.(k).(!v) then (u := ps.(k).(!u); v := ps.(k).(!v)) done; ps.(0).(!u))
let init n = dfs 0 ~-1 0; for k = 0 to l - 2 do for v = 0 to n - 1 do ps.(k + 1).(v) <- if ps.(k).(v) < 0 then -1 else ps.(k).(ps.(k).(v)) done done

let h u v = ds.(u) + ds.(v) - 2 * ds.(lca u v)
let _ = for _ = 1 to n - 1 do Scanf.scanf " %d %d %d" @@ fun a b c -> g.(a - 1) <- (b - 1, c) :: g.(a - 1); g.(b - 1) <- (a - 1, c) :: g.(b - 1) done; f 0 ~-1 0
let q, k = Scanf.scanf " %d %d" @@ fun a b -> a, b - 1
let _ = init n; for _ = 1 to q do Scanf.scanf " %d %d" @@ fun x y -> Printf.printf "%d\n" @@ h (x - 1) k + h (y - 1) k done

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	string s; cin >> s;

	bool a = false;
	bool b = false;

	REP(i, 3) if(s[i] == 'A') a = true;
	REP(i, 3) if(s[i] == 'B') b = true;

	if(a and b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int next(int now,int n){
	if(now+1<n)return now+1;
	return 0;
}
int main(){
	int n,q;
	while(cin>>n>>q&&n&&q){
		int data[50];
		int wan=q;
		fill(data,data+50,0);
		int now=0;
		bool end=false;
		while(!end){
			if(wan>0){
				data[now]++;
				wan--;
			}
			else {
				wan=data[now];
				data[now]=0;
			}
			if(data[now]==q){
				end=true;
				cout<<now<<endl;
			}
			now=next(now,n);
		}
	}
	
	
}

Measured memory_bytes: 1160
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, m;
  cin >> n >> m;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  ll sum = 0;
  priority_queue< int > pq;
  for(int i = 0; i < n; i++){
    sum += a[i];
    pq.push(a[i]);
  }

  for(int i = 0; i < m; i++){
    int v = pq.top();
    pq.pop();
    sum -= v - (v / 2);
    pq.push(v / 2);
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;
 
 
void test_case(){
 
}
int main() {
    fastio
    int n;
    cin>>n;
    int a[n];
    rng(i,0,n){
        cin>>a[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    rng(i,2,n){
        dp[i] = min(dp[i-2]+abs(a[i-2]-a[i]), dp[i-1]+abs(a[i]-a[i-1]));
        // cout<<dp[i]<<endl;
    }
    cout<<(int)dp[n-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = [int(h) for h in input().split()]
dp = [N*10**4]*N
dp[0] = 0
for i in range(1,N):
    if i == 1:
        dp[i] = dp[0] + abs(H[i]-H[i-1])
    dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2]))
print(dp[N-1])

Measured memory_bytes: 13924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 5e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll add(ll x, ll y) {
  x += y;
  while(x >= MOD)
    x -= MOD;
  while(x < 0)
    x += MOD;
  return x;
}

ll mul(ll x, ll y) {
  return (x * y) % MOD;
}

ll Left[N], Right[N], cnt[N], dp[102][N], pre[102][N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int len, n;
  cin >> n >> len;
  int x = 1, idx = 0;
  while(x <= n) {
    int a = n / x;
    int b = n / a;
    ++idx;
    Left[idx] = x, Right[idx] = b;
    x = b + 1;
  }
  for (ll i = 1; i <= idx; ++i) {
    cnt[i] = Right[i] - Left[i] + 1;
    dp[1][i] = cnt[i];
  }
  for (int i = 2; i <= len; ++i) {
    for (int last = 1; last <= idx; ++last) {
      int L = 1, R = idx - last + 1;
      pre[i][L] = add(pre[i][L], dp[i-1][last]);
      pre[i][R + 1] = add(pre[i][R+1], -dp[i-1][last]);
    }
    for (ll last = 1; last <= idx; ++last) {
      pre[i][last] = add(pre[i][last], pre[i][last - 1]);
      dp[i][last] = add(dp[i][last], mul(cnt[last], pre[i][last]));
    }
  }
  ll answer = 0;
  for (int i = 1; i <= idx; ++i) {
    answer = add(answer, dp[len][i]);
  }
  cout << answer;
}


Measured memory_bytes: 514304
#include <iostream>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int max_a = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    max_a = max(a[i], max_a);
  }
  
  vector<int> d(max_a + 1, -1);
  for (int i = 2; i <= max_a; ++i) {
    if (d[i] > 0) continue;
    for (int k = i; k <= max_a; k += i) {
      if (d[k] == -1) {
        d[k] = i;
      }
    }
  }
  
  set<int> primes;
  bool pairwise = true;
  for (int i = 0; i < n && pairwise; ++i) {
    int tmp = a[i];
    int divisor = d[tmp];
    while (tmp != 1) {
      while (tmp % divisor == 0) {
        tmp /= divisor;
      }
      if (primes.find(divisor) == primes.end()) {
        primes.insert(divisor);
        divisor = d[tmp];
      } else {
        pairwise = false;
        break;
      }
    }
  }
  
  int g = a[0];
  for (int i = 1; i < n; ++i) {
    g = gcd(g, a[i]);
  }
  
  if (pairwise) {
    cout << "pairwise coprime" << endl;
  } else if (g == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}

Measured memory_bytes: 11168
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
	int n, m;
	ll ans = 0;
	cin >> n >> m;
	priority_queue<ll> q;
	rep(i, 0, n) {
		int a;
		cin >> a;
		q.push(a);
	}
	rep(i, 0, m) {
		int b = q.top();
		q.pop();
		q.push(b / 2);
	}
	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long ll;

ll a[111111];

int main(void)
{
	ll ans = 1;
	ll n, i;

	scanf("%lld" ,&n);
	for (i = 1; i <= n; i++)
		scanf("%lld" ,&a[i]);

	sort(a + 1, a + n + 1);

	if (a[1] == 0)
	{
		puts("0");
		return 0;
	}

	for (i = 1; i <= n; i++)
	{
		if (a[i] > 1000000000000000000 / ans)
		{
			puts("-1");
			return 0;
		}
		ans *= a[i];
	}
	
  	printf("%lld" ,ans);
	return 0;
}

Measured memory_bytes: 2500
N, K = map(int, input().split())
mod = 10**9+7

# すべての要素がiの倍数であるような数列の数
# 後ろから確定して引いていく。前からだと重複が入ってあとから引きづらくなる
m = [0] * (K+1)
for i in range(K, 0, -1):
    m[i] = pow(K//i, N, mod)
    j = 2
    while True:
        if i * j > K:
            break
        m[i] -= m[i*j]
        j += 1

ans = 0
for i in range(1, K+1):
    ans = (ans + i * m[i]) % mod
print(ans)


Measured memory_bytes: 69084
#include <iostream>
#include <algorithm>

using namespace std;

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

typedef long long ll;

const ll MOD = 1000000007;
const int NUM_ = 400001;
ll fact[NUM_+1], fact_inv[NUM_+1], inv[NUM_+1];

ll n, k;
ll A[NUM_];

void comb_init() {
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < NUM_; i++) {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;
    }
}

ll comb(ll n_, ll k_) {
    if (n_ < k_) return 0;
    if (n_ < 0 || k_ < 0) return 0;
    return fact[n_] * (fact_inv[k_] * fact_inv[n_ - k_] % MOD) % MOD;
}

int main() {
    cin >> n >> k;
    REP(i, n) cin >> A[i];
    sort(A, A+n);
    ll sum_max = 0, sum_min = 0, ans = 0;
    comb_init();
    REP(i, n) {
        sum_max += A[i] * comb(i, k-1)%MOD;
        sum_min += A[i] * comb(n-i-1, k-1)%MOD;
    }
    ans  = (sum_max - sum_min + MOD) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 11520
//you never give up.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define v32 vector<int>
#define v64 vector<ll>

using namespace std;

void solve()
{
    ll n;
    cin >> n;
    v64 v;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        v.pb(a);
    }
    sort(v.begin(), v.end());
    ll * comfort= new ll[n];
    ll sum = 0;
    if(n>0)
    {
        comfort[n-1]=0;
    }
    if(n>1)
    {
        comfort[n-2]=v[n-1];
        sum +=comfort[n-2];
    }
    ll j=n-2;
    int value=0;
    for (ll i = n - 3; i >= 0; i--)
    {    if(value<2)
         {
        comfort[i]= v[j];
        value++;
        sum=sum+comfort[i];
         }
         else
         {
             value=0;
             j--;
             comfort[i]=v[j];
             value++;
               sum=sum+comfort[i];
         }
        
    }
    cout << sum << endl;
}
int main()
{
    int t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

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

int main(void){
	string s1, s2;
	vector<int> a(27,0);
	vector<int> b(27,0);
	cin >> s1 >> s2;
	for(int i = 0; i < s1.size(); ++i){
		a[s1[i] - 'a']++;
	}
	for(int i = 0; i < s1.size(); ++i){
		b[s2[i] - 'a']++;
	}
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	for(int i = 0; i < 27; ++i){
		if(a[i] != b[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll inf  = 1e7+5;

bool visited [inf];
int dist[inf];
int main() {
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >>k;
  cout << vec[k-1];
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 int main() {
	 string c[3];
	 for (int i = 0; i < 3; i++) cin >> c[i];
	 for (int i = 0; i < 3; i++) cout << c[i][i];
	 cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ld long double
 
using namespace std;
 
 
const int N = 2e5 + 123;
const int MAXN = 1e5 + 12;
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
 

ll n, m, d[N];
bool vis[N], is[N];
vector <pll> g[N];
 
 
void djk() {
    priority_queue <pair<ll, ll> > q;
    q.push({0, 1});
    pair<ll, ll> tmp;
    ll u, w;
    while (!q.empty()) {
        tmp = q.top();
        q.pop();
        u = tmp.se;
        w = -tmp.f;
        if (vis[u])
            continue;
        vis[u] = 1;
        d[u] = w;
        if (u != 1 && !vis[u - 1])
            q.push({-w, u - 1});
        for (int i = 0; i < g[u].size(); i++)
            if (!vis[g[u][i].f])
                q.push({-w - g[u][i].se, g[u][i].f});
    }
} 
 
 
int main() {
    cin >> n >> m;
    ll x, y, z;
    memset(is, 1, sizeof(is));
    for (int i = 1; i <= m; i++) {
        cin >> x >> y >> z;
        g[x].pb({y, z});
    }
    memset(d, -1, sizeof(d));
    djk();
    cout << d[n];
    return 0;
}

Measured memory_bytes: 11512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n, ans = 0;
    cin>>n;

    int tans = 0;
    int h, preh = -INF;
    REP(i,n) {
        cin>>h;
        if (preh >= h)
            tans++;
        else
            tans = 0;

        preh = h;
        ans = max(ans, tans);
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

int N;
vector<int> v;
long long dp[200005];
long long cache[200005];
long long MOD = 1e9+7;

int main(){
    cin >> N;
    v.push_back(0);
    for(int i = 1; i<=N; i++){
        int n;
        cin >> n;
        v.push_back(n);
    }
    v.erase(unique(v.begin(), v.end()), v.end());
    N = v.size();
    N--;
    dp[0] = 1;
    for(int i = 1; i<=N; i++){
        cache[v[i]] += dp[i-1];
        cache[v[i]] %= MOD;
        dp[i] = cache[v[i]];
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 4340
#include <iostream>
using namespace std;
int main(void){
    
    int l,i=0,a[3],all=0,anser=0;
    
    while(cin>>l){
        a[i]=l;
        i++;
    }
    
    all=a[0]*a[1];
    anser = all - a[1]*a[2] - (a[0]-a[2])*a[3];
    cout << anser;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(N)]
sorted_lst = sorted(lst, key=lambda x: x[0])
cnt = 0
for i in sorted_lst:
  cnt += i[1]
  if (cnt >= K):
    print(i[0])
    break

Measured memory_bytes: 65240
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int n; cin >> n;
    int maxi = max(h, w);
    cout << (n + maxi - 1) / maxi << '\n';
}


Measured memory_bytes: 888
//package atcoder.beginner_172;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main (String[] args) throws Exception {

        String s = "cupofcoffee\n" +
                "cupofhottea";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); char[] S=nca();
        rl(); char[] T=nca();
        int c=0;
        for (int i=0; i<S.length; ++i) if (S[i]!=T[i]) ++c;

        bw.write(Integer.toString(c));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

Measured memory_bytes: 37796
using System;
using System.Linq;
using static System.Console;

namespace A
{
    public class IO
    {
        public static string ReadStr() => Console.ReadLine();
        public static string[] ReadStrArr() => ReadStr().Split(' ');

        public static int ReadInt() => int.Parse(ReadStr());
        public static int[] ReadIntArr() => Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        public static double ReadDouble() => double.Parse(ReadStr());
        public static double[] ReadDoubleArr() => Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);

        public static long ReadLong() => long.Parse(ReadStr());
        public static long[] ReadLongArr() => Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
    }

    class Frog1
    {
        const long INF = long.MaxValue;
        const int SIZE = 100000;

        static void Main(string[] args)
        {            
            int N = IO.ReadInt();
            long[] h = IO.ReadLongArr();
            long[] dp = Enumerable.Repeat(INF, SIZE + 1).ToArray();

            dp[0] = 0;
            for (var i = 1; i < N; i++)
            {
                dp[i] = Math.Min(dp[i], dp[i - 1] + Math.Abs(h[i] - h[i - 1]));

                if (i >= 2)
                {
                    dp[i] = Math.Min(dp[i], dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
                }
            }

            WriteLine(dp[N - 1]);
        }
    }
}


Measured memory_bytes: 19552
#include <bits/stdc++.h>
using namespace std;
 
 
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
 
ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;
vector<char> c = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
vector<vector<pair<string,int>>> s(13); 
int main(){
    int n; cin >> n;
    s.at(1).emplace_back("a", 1);
    rp(i, 2, n+1){
        for(auto x: s.at(i-1)){
            rp(j, 0, x.second+1){
                s.at(i).emplace_back(x.first+c.at(j), max(x.second, j+1));
            }
        }
    }
    for(auto x: s.at(n)) cout << x.first << "\n";
    return 0;
}


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

int main() {
  uint32_t n = 0;
  std::cin >> n;
  std::vector<uint32_t> mat(n + 1);
  for (uint32_t i = 0; i < n; i++) {
    std::cin >> mat[i] >> mat[i + 1];
  }

  std::vector<std::vector<uint32_t>> dp(n + 1,
                                        std::vector<uint32_t>(n + 1, -1));
  for (size_t i = 0; i < dp.size(); i++) dp[i][i] = 0;

  for (size_t d = 1; d < n; d++) {
    for (size_t i = 1; i < dp.size() - d; i++) {
      for (size_t j = 0; j < d; j++) {
        dp[i][i + d] =
            std::min(dp[i][i + d], mat[i - 1] * mat[i + j] * mat[i + d] +
                                       dp[i][i + j] + dp[i + j + 1][i + d]);
      }
    }
  }

  std::cout << dp[1][n] << std::endl;

  return 0;
}


Measured memory_bytes: 3204
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long K;
	cin >> K;
	long long N = 50;
	vector<long long>A(N, N - 1);
	for (int i = 0; i < N; ++i) {
		A[i] += (K / N);
	}
	K %= N;
	if (K != 0) {
		for (long long i = 0; i < N; ++i) {
			if (i < N - K) {
				A[i] -= K;
			}
			else {
				A[i] += N + 1 - K;
			}
		}
	}
	cout << 50 << endl;
	for (int i = 0; i < N; ++i) {
		if (0 != i) {
			cout << " ";
		}
		cout << A[i];
	}
	return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;

    string ai;
    vector<string> A(H);
    rep(i, H) cin >> A[i];

    vector<int> white_c;
    rep(w, W) {
        bool all_white = true;
        rep(h, H) {
            if (A[h][w] == '#') all_white = false;
        }
        if (all_white) white_c.push_back(w);
    }

    for (int i=white_c.size()-1; i>=0; i--) {
        rep(h, H) A[h].erase(white_c[i], 1);
    }

    vector<int> white_r;
    rep(h, H) {
        if (A[h].find("#") == string::npos) white_r.push_back(h);
    }

    rep(h, H) {
        if (find(white_r.begin(), white_r.end(), h) == white_r.end()) cout << A[h] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int MOD = 1e9+7;

ll modpow(ll b, int e) {
  if (b == 0) return 0;
  if (e == 0) return 1;
  ll ans = 1;
  while (e) {
    if (e&1) {
      ans = (ans * b) % MOD;
    }
    e >>= 1;
    b = (b*b)%MOD;
  }
  return ans;
}

ll modinv(int v) {
  return modpow(v, MOD-2);
}

const int N = 2e5+10;
ll fact[N];
ll choose(int n, int c) {
  ll den = fact[c] * fact[n-c] % MOD;
  return (fact[n] * modinv(den)) % MOD;
}

ll hach(int x, int y) {
  return choose(x+y-1, x-1);
}


int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n, k;
  assert(modpow(2, 5) == 32);
  {
    ll t1 = 123012;
    ll t2 = modinv(t1);
    assert(t1*t2 % MOD == 1);
  }
  fact[0] = 1;
  for (ll i = 1; i < N; ++i) {
    fact[i] = (fact[i-1] * i) % MOD;
  }
  cin >> n >> k;
  k = min(n-1, k);
  ll ans = 0;
  for (int h = 0; h <= k; ++h) {
    // h holes, h people have n-h choices each
    ll cur = choose(n,h) * hach(n-h, h) % MOD;
    ans = (ans + cur) % MOD;
  }
  cout << ans << nl;
  return 0;
}



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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
struct Edge {
	int a, b, c;
};
struct LCA {
	int n;
	vvi parent;//parent[i][k]:2^k-th parent of i-th node
	vi depth;//depth[i]:depth of i-th node

	LCA(const vvi &graph, const int  N, int root)
		:n(N), depth(N), parent(n, vi(log2(n) + 1, -1)) {
		dfs(graph, root, -1, 0);
		REP(k, int(log2(n))) {
			REP(i, n) {
				if (parent[i][k] != -1) {
					parent[i][k + 1] = parent[parent[i][k]][k];
				}
			}
		}
	}

	void dfs(const vvi &graph, int v, int p, int d) {//graph,current node,previous node,depth
		depth[v] = d;
		parent[v][0] = p;
		REP(i, graph[v].size()) {
			if (graph[v][i] != p)dfs(graph, graph[v][i], v, d + 1);
		}
	}

	int get(int v, int w) {//lca of v and w
		if (depth[v] < depth[w])swap(v, w);
		int dif = depth[v] - depth[w];
		REP(i, log2(n) + 1) {
			if (1 << i&dif)v = parent[v][i];
		}
		if (v == w)return v;
		RREP(i, log2(n)) {
			if (parent[v][i] != parent[w][i] && parent[v][i] != -1) {
				v = parent[v][i];
				w = parent[w][i];
			}
		}
		return parent[v][0];
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<Edge>> g(n);
	vl d(n, INF*INF);
	d[0] = 0;
	vvi v(n);
	REP(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g[a].push_back({ a,b,c });
		g[b].push_back({ b,a,c });
		v[a].push_back(b);
		v[b].push_back(a);
	}
	queue<int> qu;
	qu.push(0);
	while (!qu.empty()) {
		int p = qu.front(); qu.pop();
		REP(i, g[p].size()) {
			if (d[g[p][i].b] == INF*INF) {
				d[g[p][i].b] = d[p] + g[p][i].c;
				qu.push(g[p][i].b);
			}
		}
	}
	LCA lca(v, n, 0);
	int q, k;
	cin >> q>> k;
	k--;
	REP(i, q) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if (d[x] + d[y] - 2 * d[lca.get(x, y)] == d[k] + d[x] - 2 * d[lca.get(k, x)] + d[k] + d[y] - 2 * d[lca.get(k, y)]) {
			cout << d[x] + d[y] - 2 * d[lca.get(x, y)] << endl;
		}
		else {
			cout << d[k] + d[x] - 2 * d[lca.get(k, x)] + d[k] + d[y] - 2 * d[lca.get(k, y)] << endl;
		}
	}
}


Measured memory_bytes: 27008
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class370
    {
        static void Main()
        {
            var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = HW[0], W = HW[1];
            var map = new char[H, W];
            for(int i = 0; i < H; i++)
            {
                var s = Console.ReadLine();
                for (int j = 0; j < W; j++)
                {
                    map[i, j] = s[j];
                }
            }
            var lr = new int[H, W];
            var ud = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (map[i,j]=='#')
                    {
                        lr[i, j] = -1;
                        continue;
                    }
                    if (j - 1 >= 0)
                    {
                        if (lr[i, j - 1] > 0)
                        {
                            lr[i, j] = lr[i, j - 1];
                            continue;
                        }
                    }
                    int count = 0;
                    for (int k = j; k < W; k++)
                    {
                        if (map[i,k]!='#')
                        {
                            count++;
                        }
                        else
                        {
                            break;
                        }
                    }
                    lr[i, j] = count;

                }
            }
            for (int j = 0; j < W; j++)
            {
                for (int i = 0; i < H; i++)
                {
                    if (map[i, j] == '#')
                    {
                        ud[i, j] = -1;
                        continue;
                    }
                    if (i - 1 >= 0)
                    {
                        if (ud[i-1,j] > 0)
                        {
                            ud[i, j] = ud[i-1,j];
                            continue;
                        }
                    }
                    int count = 0;
                    for (int k = i; k < H; k++)
                    {
                        if (map[k,j] != '#')
                        {
                            count++;
                        }
                        else
                        {
                            break;
                        }
                    }
                    ud[i, j] = count;
                }
            }
            int maxcount = 0;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    maxcount = Math.Max(maxcount, lr[i, j] + ud[i, j]);
                }
            }
            Console.WriteLine(maxcount-1);
        }
    }
}


Measured memory_bytes: 56264
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int k,t;
    cin>>k>>t;
    int ans=0;
    multiset<int> ms;
    rep(i,t){
        int a;
        cin>>a;
        ms.insert(a);
    }
    int p=-1;
    while(true){
        if(p==-1){
            p=*rbegin(ms);
            ms.erase(ms.find(p));
            p--;
        }else{
            if(ms.empty()){
                ans++;
                //ms.insert(p);
                p--;
            }else{
                ll q=*rbegin(ms);
                ms.erase(ms.find(q));
                q--;
                if(p>0) ms.insert(p);
                p=q;
            }

        }
        if(ms.empty()&&p==0) break;
    }
    out(ans);
}

Measured memory_bytes: 3576
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
	ll n;
	cin>>n;
	ll c1 = 1;
	ll c2 = 1;
	rep(i,0,n){
		ll a;
		cin>>a;
		c1 *= 3;
		if(a%2==0){
			c2 *= 2;
		}
	}
	cout << c1-c2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int n,A[25],B[25],i,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	for(i=0;i<n;i++) scanf("%d",&B[i]);
	for(i=0;i<n;i++)
	  if(A[i]>B[i]) ans+=A[i]-B[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
def main():
    import math
    s = int(input())
    mod = 10**9+7
    c = s//3
    ans = 0
    for c_ in range(1,c+1):
        l = s - c_*3
        ans += (math.factorial(l+c_-1)//math.factorial(l)//math.factorial(c_-1))%mod
    print(ans%mod)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9080
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
typedef pair<ll,int>pli;
typedef pair<int,int>pii;
#define mp make_pair
const int N=100010;
ll d[N];int n,siz[N];vector<pii>ans;pli p[N];
int main()
{
	n=gi();
	for(int i=1;i<=n;i++)scanf("%lld",&d[i]),p[i].first=d[i],p[i].second=i,siz[i]=1;
	sort(p+1,p+n+1);ll dis=0;
	for(int i=n;i>1;i--)
	{
		ll nd=p[i].first-n+(siz[p[i].second]<<1);
		int pos=lower_bound(p+1,p+n+1,mp(nd,0))-p;
		if(p[pos].first!=nd)return puts("-1"),0;
		int u=p[i].second,v=p[pos].second;
		ans.push_back(mp(u,v));siz[v]+=siz[u];
		dis+=siz[u];
	}
	if(dis!=p[1].first)return puts("-1"),0;
	for(pii now:ans)printf("%d %d\n",now.first,now.second);
	return 0;
}


Measured memory_bytes: 4980
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <tuple>
using namespace std;

typedef pair<int,int> P;//駅id,会社id(0は改札外)
map<long long int,map<long long int,int>> G;//エッジリスト(キモい)
map<long long int,int> memo;
const int INF = 1000000000;
typedef tuple<int,long long int> T;//cost,駅id,会社id
priority_queue<T,vector<T>,greater<T>> que;
#define mygc(c) (c)=getchar_unlocked()
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;} }for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}

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

    int N,M;
    //cin>>N>>M;
    reader(&N); reader(&M);
    for(int i=1;i<=N;i++) memo[(long long int)i<<32|0]=INF;
    for(int i=0;i<M;i++){
        int p,q,c;
        //cin>>p>>q>>c;
        reader(&p); reader(&q); reader(&c);
        G[(long long int)p<<32|c][(long long int)q<<32|c]=0;
        G[(long long int)p<<32|c][(long long int)p<<32|0]=0;
        G[(long long int)p<<32|0][(long long int)p<<32|c]=1;
        G[(long long int)q<<32|c][(long long int)p<<32|c]=0;
        G[(long long int)q<<32|c][(long long int)q<<32|0]=0;
        G[(long long int)q<<32|0][(long long int)q<<32|c]=1;
        memo[(long long int)p<<32|c]=memo[(long long int)q<<32|c]=INF;
    }
    memo[(long long int)1<<32|0]=0;
    que.emplace(0,1LL<<32|0);
    while(!que.empty()){
        T t = que.top(); que.pop();
        int cost=get<0>(t);
        long long int id=get<1>(t);
        if((id&((1LL<<32)-1)<<32)==(long long int)N<<32){
            cout<<cost<<endl;
            return 0;
        }
        if(cost>memo[id]) continue;
        for(auto &g:G[id]){
            auto &p = g.first; int fee=g.second;
            if(cost+fee<memo[p]){
                memo[p]=cost+fee;
                que.emplace(cost+fee,p);
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 148468
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)

for i in range(N):
  t[i + 1] = t[i] + S[i:i + 2].count('AC')

for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
    
    void solve() throws IOException {
        int n=ni(),m=ni();
        String s=next();
        int[]A=new int[n+1];
        for (int x=0;x<=n;x++) {
            if (s.charAt(x)=='1') A[x]=1;
        }
        
        int c=0;
        int[] B=new int[n+10];
        int p=n;
        boolean f=false;
        
        outer:
        while (true) {
            int newp=p-m;
            if (newp<=0) { B[c]=p; break; }
            while (A[newp]==1) {
                newp++;
                if (newp==p) { f=true; break outer; }
            }
            B[c]=p-newp;
            c++;
            p=newp;
        }
        
        if (f) out.println("-1");
        else {
            for (int x=c;x>=0;x--) out.print(B[x]+" ");
            out.println();
        }
        out.flush();
    }
    
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 34616
n,k,q = map(int,input().split())
parti = range(n)
res = [0 for i in parti]
data = [0 for i in parti]

for i in range(q):
  answer = int(input()) - 1
  data[answer] += 1

for key,val in enumerate(data):
  if val + k - q > 0:
    index = int(key)
    res[index] = 1
for i in res:
  print('Yes' if i else 'No')

Measured memory_bytes: 5476
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
B = [A[0]]
for i in range(N-1):
  B.append(A[i+1])
  B.append(A[i+1])
#print(B)
ans = 0
for i in range(N-1):
  ans += B[i]
print(ans)

Measured memory_bytes: 31524
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::string str[100010];
    int n;
    std::cin >> n;

    int m;
    std::multiset<long long int> seti;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> str[i];
        std::sort(str[i].begin(), str[i].end());
//        m = str[i].length();
//        long long int hashi = 0, curpow = 1;
//        for (int j = 0; j < m; ++j)
//        {
//            hashi += (str[i][j] - 'a') * curpow;
//            hashi %= mod;
//            curpow *= 26;
//            curpow %= mod;
//        }
//
//        ans += seti.count(hashi);
//        seti.insert(hashi);
    }

    std::sort(str, str + n);
    long long int ans = 0, cur = 1;
    for (int i = 1; i < n; ++i)
    {
        if (str[i] == str[i - 1])
        {
            ++cur;
        }
        else
        {
            ans += (cur * (cur - 1)) / 2;
            cur = 1;
        }
    }

    ans += (cur * (cur - 1)) / 2;

    std::cout << ans;
    //std::cout << ans;
}


Measured memory_bytes: 5760
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes";
    }
    else cout << "No";
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://abc061.contest.atcoder.jp/tasks/abc061_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		
		String ans = A<=C && C<=B ? "Yes" : "No";
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int N;

void dfs(string s, char now) {
  if (s.size() == N) {
    cout << s << endl;
    return;
  }
  for (char i = 'a'; i < now; i++) {
    dfs(s + i, now);
  }
  dfs(s + now, now + 1);
}

int main() {
  cin >> N;
  dfs("", 'a');
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main()
{
    int n, m;
    cin >> n >> m;
    set<ll> a;
    for(int i = 0; i < n; i++)
    {
        ll aa;
        cin >> aa;
        a.insert(aa);
    }
    int count = 0;
    ll tmp = *a.begin();
    while(tmp % 2 == 0)
    {
        tmp /= 2;
        count++;
    }
    for(ll tt : a)
    {
        int tc = 0;
        while(tt % 2 == 0)
        {
            tt /= 2;
            tc++;
        }
        if(tc != count)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    ll lcm = 1;
    for(ll tt : a)
    {
        ll g = gcd(lcm, tt/2);
        lcm = lcm * tt/2 / g;
    }
    ll c = m / lcm;
    cout << (c+1)/2 << endl;
}



Measured memory_bytes: 384
import std.stdio, std.string, std.array, std.conv;

void main() {
    int[] tmp = readln.chomp.split.to!(int[]);
    int w = tmp[0], h = tmp[1], x = tmp[2], y = tmp[3], r = tmp[4];
    writeln(0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h ? "Yes" : "No");
}


Measured memory_bytes: 2496
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

int n, c, k;
int t[N];

int main() {
	read(n), read(c), read(k);
	for (int i = 1; i <= n; i++) read(t[i]);
	sort(t + 1, t + n + 1);
	int ans = 0;
	for (int i = 1, j = 1; i <= n; i = j + 1) {
		ans++;
		while (j + 1 <= n && t[j + 1] <= t[i] + k && j + 1 - i + 1 <= c) j++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>

int A[20];
int M[200];
	int N;
	int Q;

/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int solve(int i, int m)
{
	int res;
	if (m == 0) {
		return 1;
	}
	if (i >= N) {
		return 0;
	}
	res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void)
{
	int i;
	char *pMsg;
//
	scanf("%d", &N);
	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &A[i] );
	}
	scanf("%d", &Q);
	for ( i = 0 ; i < Q ; i++ ) {
		scanf("%d", &M[i] );
	}

	for ( i = 0 ; i < Q ; i++ ) {
		if (solve(0, M[i])) {
			pMsg = "yes";
		} else {
			pMsg = "no";
		}
		printf("%s\n", pMsg);
	}

	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int m,f,r,wa;

	while(1){
		cin >> m >> f >> r;
		wa=0;
		wa=m+f;

		if (m==-1 && f==-1 && r==-1) break;
		
		if (m==-1 || f==-1) cout << "F" << endl;
		
		else if (wa >= 80) cout << "A" << endl;
		
		else if (wa >= 65 ) cout << "B" << endl;
		
		else if (wa >= 50  ) cout << "C" << endl;
		
		else if (wa >= 30  ) {
		
			if (r>=50)
				cout << "C" << endl;
			else
				cout << "D" << endl;
			}
		else if (wa < 30) cout << "F" << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> p;

int atooi(char s){
  string n="0123456789";
  for(int i=0;i<=10;i++){
    if(s==n[i]){
      return i;
    }
  }
  return 0;
}

int timetime(string s){
  int hh,mm,ss,st,ft,h1,h2,m1,m2,s1,s2;
  h1= atooi(s[0]);
  h2= atooi(s[1]);
  m1= atooi(s[3]);
  m2= atooi(s[4]);
  s1= atooi(s[6]);
  s2= atooi(s[7]);
  hh=h1*10+h2;
  mm=m1*10+m2;
  ss=s1*10+s2;
  st=hh*3600+mm*60+ss;
  return st;
}

int main(){
  while(true){
  int n,st,ft;
  cin>>n;
  if(n==0) return 0;
  int  tm[100000]={};
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    st =timetime(s);
    tm[st]+=1;
   cin>>s;
   ft=timetime(s);
    tm[ft]-=1;
  }

  int val=0,ans=0;
  for(int i=0;i<=89899;i++){
    tm[i]+=val;
    val=tm[i];
    ans=max(ans,tm[i]);
  }
  cout<<ans<<endl;
}
}

Measured memory_bytes: 3560
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import Text.Printf

readInt = ( readLn :: IO Int )
getInts = map ( read :: String -> Int ) . words <$> getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	s <- getLine
	putStrLn $ which "Yes" "No" $ s == reverse s


Measured memory_bytes: 380
#include<iostream>
#include<cmath>
using namespace std;
typedef long long int ll;
static const int MOD = 1000000007;
int main(){
	int N, M;
	cin >> N >> M;
	if(abs(N - M) >= 2) cout << 0 << endl;
	else if(abs(N - M) == 1){
		ll ans = 1;
		for(int i = 1; i <= N; i++){
			ans *= i;
			ans %= MOD;
		}
		for(int i = 1; i <= M; i++){
			ans *= i;
			ans %= MOD;
		}
		cout << ans << endl;
	}else if(abs(N - M) == 0){
		ll ans = 1;
		for(int i = 1; i <= N; i++){
			ans *= i;
			ans %= MOD;
		}
		for(int i = 1; i <= M; i++){
			ans *= i;
			ans %= MOD;
		}
		cout << (ans * 2) % MOD << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define endl '\n'
#define ll long long

using namespace std;

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

	int r;
	cin >> r;
	
	cout << 2 * M_PI * r << endl;

	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
long long f(long long x)
{
	if(x%4==0)
		return x;
	if(x%4==1)
		return 1;
	if(x%4==2)
		return x+1;
	return 0;
}
int main()
{
	long long a,b;
	cin>>a>>b;
	cout<<(f(b)^((a==0)?0:f(a-1)))<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(void)
{
    ll N;
		cin >> N;
    vector<ll> h(N);
    vector<ll> dp(N);
		rep(i, N) cin >> h.at(i);
		rep(i, N) dp.at(i) = INF;
		dp.at(0) = 0;

		rep(i, N-1)
		{
			chmin(dp.at(i+1), dp.at(i) + abs(h.at(i) - h.at(i+1)));
			if(i<N-2) chmin(dp.at(i+2), dp.at(i) + abs(h.at(i) - h.at(i+2)));
		}
		cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792