akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n;
int cnt[maxN + 1];
lli ans;

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    memset(cnt, 0, sizeof(cnt)), ans = 0;
    for (int i = 0; i < n; i++)
    {
      int a; scanf("%d", &a);
      cnt[a]++, ans += a;
    }
    DEBUG printf("\t%lld\n", ans);

    int q; scanf("%d", &q);
    while (q--)
    {
      int b, c; scanf("%d %d", &b, &c);
      ans -= (lli)cnt[b]*b, ans += (lli)cnt[b]*c;
      cnt[c] += cnt[b];
      cnt[b] = 0;
      printf("%lld\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 4144
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


pair<int, int> a[100000];


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	rep(i,n) {
		int x;
		cin >> x;
		a[i] = make_pair(x, i);
	}
	sort(a, a + n);
	long long ans = 0;
	rep(i,n) {
		ans += abs(i - a[i].second) % 2;
	}
	ans = (ans + 1) / 2;
	cout << ans << endl;

	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> l(n,0);
    rep(i,n)cin >> l.at(i);
    sort(l.begin(),l.end());
    ll res=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int k = lower_bound(l.begin(),l.end(),l[i]+l[j]) - l.begin();
            res += max(k-(j+1),0);
        }
    }
    std::cout << res << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N];
ll dp[MAX_N][5];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 1, N + 1) {
		rep(j, 0, 5) {
			dp[i][j] = linf;
		}
	}
	rep(i, 0, N) {
		rep(j, 0, 5) {
			if(j == 0) MIN(dp[i + 1][j], dp[i][j] + A[i]);
			if(j == 1) MIN(dp[i + 1][j], dp[i][j] + (A[i] == 0 ? 2 : A[i] % 2));
			if(j == 2) MIN(dp[i + 1][j], dp[i][j] + (1 - A[i] % 2));
			if(j == 3) MIN(dp[i + 1][j], dp[i][j] + (A[i] == 0 ? 2 : A[i] % 2));
			if(j == 4) MIN(dp[i + 1][j], dp[i][j] + A[i]);
		}
		// debug(vl(dp[i + 1], dp[i + 1] + 5));
		rep(j, 0, 4) {
			MIN(dp[i + 1][j + 1], dp[i + 1][j]);
		}
	}
	cout << dp[N][4] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 11520
// https://atcoder.jp/contests/abc155/tasks/abc155_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<string, int> mp;
    int maxv = 0;
    REP(i, N) {
        string t;
        cin >> t;
        mp[t]++;
        maxv = max(maxv, mp[t]);
    }
    for (auto &x : mp) {
        if (x.second == maxv) {
            cout << x.first << "\n";
        }
    }

    return 0;
}


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

void ans( int i ) {

  if ( i < 10 ) cout << "0";
  cout << i;

  return;

}

int main() {

  int input1,input2,input3;

  while(true) {

    cin >> input1 >> input2 >> input3;
    if ( input1 == -1 ) break;

    int time = 7200 - input1 * 3600 - input2 * 60 - input3;

    for ( int i = 0; i < 2; i++ ) {
      ans( time/3600 );
      cout << ":";
      ans( (time%3600)/60 );
      cout << ":";
      ans( time%60 );
      cout << endl;
      time *= 3;
    }

  }

}

Measured memory_bytes: 1160
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
  
    int n;
    cin>>n;

    vi v(n);
    for(int &x:v) cin>>x;
        sort(all(v));

    int ans = v[n-1]/2;
    for(int i=0;i<n-1;i++) ans += v[i];

    cout<<ans;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

const double eps = 1e-7;
const int MOD = 1000000007;
const int MOD_MAX = 200000;

using ll = long long;
using vi = vector<int>; using vi2 = vector<vi>; using vi3 = vector<vi2>;
using vll = vector<ll>; using vll2 = vector<vll>; using vll3 = vector<vll2>;
using vd = vector<double>; using vd2 = vector<vd>; using vd3 = vector<vd2>;
using pi = pair<int, int>; using pll = pair<ll, ll>;
using vpi = vector<pi>; using vpll = vector<pll>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)
#define rloopi(i, a, b) for(int i = (int)a - 1; i >= (int)b; i--)
#define rloop(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define rloopeq(i, n) for (int i = (int)n - 1; i >= 1; i--)
#define rloopll(i, n) for (int i = (ll)n - 1; i >= 0; i--)
#define rlooplleq(i, n) for (int i = (ll)n - 1; i >= 1; i--)
#define all(a) (a).begin(), (a).end()

bool feq(float x, float y) { return abs(x-y) <= eps; }
bool deq(double x, double y) { return abs(x-y) <= eps; }
int ceillog2(ll x) { return int (ceil(log2(x))); }
int floorlog2(ll x) { return int (floor(log2(x))); }
template<class T> T reversed (T container) { reverse(container.begin(), container.end()); return container; }
template<class T> T sort (T container) { sort(container.begin(), container.end()); return container; }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

int main() {
  int a, b, c; cin >> a >> b >> c;
  swap(a, b); swap(a, c);
  cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b<c+d){
		cout<<"Right";
	}
	if(c+d<a+b){
		cout<<"Left";
	}
	if(a+b==c+d){
		cout<<"Balanced";
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,x,y;
	for(i=1; ;i++)
		{scanf("%d %d",&x,&y);
			if(x==0 && y==0)break;
				if(x>y){printf("%d %d\n",y,x);}
				else{printf("%d %d\n",x,y);}}
return 0;
}


Measured memory_bytes: 2024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    private static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final String s = fs.next();
        System.out.println(dfs(s.toCharArray(), 0, 0, new Long[s.length()][4]));
    }

    private static long dfs(char[] s, int i, int j, Long[][] dp) {
        if (i == s.length) {
            return j == 3 ? 1 : 0;
        }
        if (dp[i][j] != null) {
            return dp[i][j];
        }
        long res = dfs(s, i + 1, j, dp);
        if (s[i] == '?') {
            res = (res + 2 * dfs(s, i + 1, j, dp)) % MOD;
        }
        if (j < 3 && (s[i] == '?' || s[i] == "ABC".charAt(j))) {
            res = (res + dfs(s, i + 1, j + 1, dp)) % MOD;
        }
        return dp[i][j] = res;
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 110920
#include <iostream>
using namespace std;
int main()
{
  unsigned long long a, b, x;
  cin >> a >> b >> x;
  unsigned long long mod = a%x;
  unsigned long long ans = 0;
  unsigned long long base;
  if (mod==0) {
    ans++;
    base = a;
  } else {
    base = a - mod;
  }
  ans += (b-base)/x;
  cout << ans << endl;
  return 0;
}

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

const string POSSIBLE = "Possible";
const string IMPOSSIBLE = "Impossible";

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

    int n;
    cin >> n;

    multiset<int> a;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.insert(x);
    }

    int maxValue = *(a.rbegin());
    a.erase(a.find(maxValue));

    if (a.find(maxValue) == a.end()) {
        cout << IMPOSSIBLE << endl;
        return 0;
    }
    a.erase(a.find(maxValue));

    int minValue = maxValue;
    for (int d1 = 1; d1 <= maxValue - 1; ++d1) {
        const int d2 = maxValue - d1;
        int d = max(d1, d2);

        if (a.find(d) == a.end()) {
            cout << IMPOSSIBLE << endl;
            return 0;
        }
        a.erase(a.find(d));

        minValue = min(minValue, d);
    }

    for (int x : a) {
        if (x <= minValue) {
            cout << IMPOSSIBLE << endl;
            return 0;
        }
    }

    cout << POSSIBLE << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin >> a >> b;
    c=a+a-1;
    d=b+b-1;
    e=a+b;
    cout << max(max(c,d),e) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int son[400010],go[400010],f1[400010],f2[400010];
set<int> des[400010],mp[400010]; 
void adde(int u,int v)
{
	des[u].insert(v);des[v].insert(u);
	go[u]++;go[v]++;
}
int main()
{
	int n,r1,r2;scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&f1[i]);
		if (f1[i]==-1) {r1=i;adde(2*n+1,r1);}
		else {adde(f1[i],i);son[f1[i]]^=1;}
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&f2[i]);
		if (f2[i]==-1) {r2=i;adde(2*n+1,r2+n);}
		else {adde(f2[i]+n,i+n);son[f2[i]+n]^=1;}
	}
	for (int i=1;i<=n;i++)
	{
		if (son[i]!=son[i+n]) {puts("IMPOSSIBLE");return 0;}
		if (!son[i]) adde(i,i+n);
	}
	for (int i=1;i<=n;i++) if (go[i]&1) assert(0);
	for (int s=1;s<=2*n+1;s++)
	while (des[s].size())
	{
		int now=s;
		while (1)
		{
			if (des[now].size()==0) assert(0);
			int d=*des[now].begin();des[now].erase(d);des[d].erase(now);
			mp[now].insert(d);
			now=d;if (d==s) break;
		}
	}
	puts("POSSIBLE");
	for (int i=1;i<=n;i++)
	{
		if (son[i]) printf("0 ");
		else if (mp[i].count(i+n)) printf("1 ");
		else printf("-1 ");
	}
}
	
	

Measured memory_bytes: 71552
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int c[13];
bool use[24];
int main() {
  int n;
  cin >> n;
  c[0]++;
  for(int i = 0; i < n; i++) {
    int d;
    cin >> d;
    c[d]++;
  }

  int ans = 0;
  for(int i = 0; i < (1 << 11); i++) {
    //    cout <<" aaa" << endl;
    fill(use,use+24,false);
    int tmp = 30;
    for(int j = 0; j <= 12; j++) {
      if(c[j]) {
	if(j == 0 || j == 12) {
	  if(c[j] >= 2) tmp = 0;
	  use[j] = true;
	}
	else {
	  if(c[j] >= 3) tmp = 0;
	  else if(c[j] == 2) {
	    use[j] = use[24- j] = true;
	  }
	  else if(c[j] == 1) {
	    use[i & (1 << (j - 1)) ? j : 24 - j] = true;
	  }
	}
      }
    }
    for(int j = 0; j < 24; j++) {
      if(use[j]) {
	for(int k = 0; k < j; k++) {
	  if(use[k]) {
	    tmp = min(tmp,min(24 - (j - k),j - k));
	  }
	}
      }
    }
    //    cout << ans << endl;
    ans = max(ans,tmp);
  }
  cout << ans << endl;
}
	  
	


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
from collections import deque

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

for i in range(n):
    if i % 2 == 0:
        que.append(a[i])
    else:
        que.appendleft(a[i])
        
if len(que) % 2 != 0:
    for j in range(n):
        print(que.pop(), end = " ")
else:
    for k in range(n):
        print(que.popleft(), end = " ")

Measured memory_bytes: 100692
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main(){
    ll x ;
    cin >> x ; 
    ll ans = 0 ;
    ll p = x / 11 ;
    ll f = x - p * 11 ;
    if(f > 0){
        f -= 6 ;
        ans++ ;  
    }
    if(f > 0){
        ans++ ; 
    }
    ans += p * 2 ;
    cout << ans << endl ; 
}


Measured memory_bytes: 3608
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


V,E = map(int,input().split())

boss = [i for i in range(V)]
height = [0 for i in range(V)]

def get_boss(index):
    if index == boss[index]:
        return index
    else:
        boss[index] = get_boss(boss[index])
        return boss[index]


def is_same_group(a,b):
    return get_boss(a) == get_boss(b)

def unite(x,y):
    boss_x = get_boss(x)
    boss_y = get_boss(y)

    if boss_x == boss_y:
        return

    if height[x] > height[y]:

        boss[boss_y] = boss_x

    elif height[x] < height[y]:

        boss[boss_x] = boss_y

    else:
        boss[boss_y] = boss_x
        height[x] += 1


for loop in range(E):
    A,B = map(int,input().split())
    unite(A,B)

num_query = int(input())

for loop in range(num_query):
    A,B = map(int,input().split())
    if is_same_group(A,B) == True:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 11184
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct UF
{
  vector<int> par;
  vector<int> sz;
  vector<int> rank;
  UF(int n):par(n),sz(n),rank(n){
    for(int i = 0; i < n; i++){
      par[i] = i;sz[i] = 1;rank[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void merge(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int n){return sz[find(n)];}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  UF uni(n);
  vi A(n);
  for(int i=0;i<n;i++){
    cin>>A[i];
    A[i]--;
  }
  for(int i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    a--;b--;
    uni.merge(a,b);
  }
  ll ans = 0;
  for(int i=0;i<n;i++){
    ans += (uni.same(i,A[i]));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> r;
    rep(i,n){
        int x,l;
        cin>>x>>l;
        r.push_back({x+l,x-l});
    }
    int t=-1e9-1;
    int ans=0;
    sort(all(r));
    rep(i,n){
        //cout<<r[i].second<<" "<<r[i].first<<endl;
        if(t<=(r[i].second)){
            ans++;
            t=r[i].first;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>

int64_t sum[3000];
int cnt;
int insert(int64_t x){
	int i=cnt;
	for(;i > 0 && sum[i-1] < x; i--){
		sum[i] = sum[i-1];
	}
	if(i < 3000){
		sum[i] = x;
		if(cnt < 3000)cnt++;
	}
	return i;
}
int main(void){
	cnt = 0;
	int x, y, z, k;
	std::cin >> x >> y >> z >> k;
	std::vector<int64_t> a(x), b(y), c(z);

	for(int i=0;i<x;i++)std::cin >> a[i];
	for(int i=0;i<y;i++)std::cin >> b[i];
	for(int i=0;i<z;i++)std::cin >> c[i];
	std::sort(a.begin(), a.end(), std::greater<int64_t>());
	std::sort(b.begin(), b.end(), std::greater<int64_t>());
	std::sort(c.begin(), c.end(), std::greater<int64_t>());

	for(int A=0;A<x;A++){
		for(int B=0;B<y;B++){
			for(int C=0;C<z;C++){
				int64_t x = a[A] + b[B] + c[C];
				int r = insert(x);
				if(r >= k)break;
			}
		}

	}
	for(int i=0;i<k;i++)std::cout << sum[i] << std::endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,m;
 cin>>n>>m;
 ans=(n*(n-1))/2+(m*(m-1))/2;
 pr(ans);
 return 0;}



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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n, m, l;
		n = in.nextInt();
		m = in.nextInt();
		l = in.nextInt();
		long A[][] = new long[n][m];
		long B[][] = new long[m][l];

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				A[i][j] = in.nextInt();
			}
		}
		for(int i=0;i<m;i++) {
			for(int j=0;j<l;j++) {
				B[i][j] = in.nextInt();
			}
		}

		long c[][] = new long[n][l];
		for(int i=0;i<n;i++) {
			for(int j=0;j<l;j++) {
				for(int k=0;k<m;k++) {
					c[i][j] += A[i][k] * B[k][j];
				}
			}
		}
		for(int i=0;i<n;i++) {
			String s = "";
			for(int j=0;j<l;j++) {
				s += c[i][j] + " ";
			}
			System.out.println(s.substring(0, s.length()-1));
		}
	}
}

Measured memory_bytes: 67428
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
	int n,f=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		if(!(a[i]&1)){
			if(a[i]%5==0||a[i]%3==0){
			}
			else{
				f=1;
				//cout << a[i] << endl;
			}
		}
	}
	if(f==1) cout << "DENIED" << endl;
	else cout << "APPROVED" << endl;
	return 0;
 } 

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

constexpr long long mod = 1e9 + 7;

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

  vector<int> a(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i];
    a[i]--;
  }

  int idx = 0;

  vector<long long> ways(N, 0LL);
  if (find(a.begin(), a.end(), 0) == a.end()) ways[0] = 1;
  else idx = distance(a.begin(), find(a.begin(), a.end(), 0));
  if (find(a.begin() + idx, a.end(), 1) == a.end()) ways[1] = 1;
  else idx = distance(a.begin(), find(a.begin(), a.end(), 1));

  for (int i = 1; i < N; i++) {
    if (find(a.begin() + idx, a.end(), i) != a.end()) {
      idx = distance(a.begin(), find(a.begin() + idx, a.end(), i));
      ways[i] = 0;
      continue;
    }

    if (i >= 1) ways[i] += ways[i-1];
    if (i >= 2) ways[i] += ways[i-2];

    ways[i] %= mod;
  }

  cout << ways[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
typedef long long int ll;
int n,x,y;
int flagX,flagY,curX,curY;
ll k,positive,negative;
int main(){
	cin>>k>>x>>y;
	flagX=(x<0)?-1:1;
	flagY=(y<0)?-1:1;
	x*=flagX;
	y*=flagY;
	if(k%2==0&&(x+y)&1){
		cout<<"-1"<<endl;
	}else{
		if(k==x+y){
			n=1;
		}else{
			n=2;
			while(n*k<x+y||(n*k-x-y)&1){
				n++;
			}
		}
		positive=(n*k+x+y)>>1;
		negative=(n*k-x-y)>>1;
		cout<<n<<endl;
		while(n--){
			if(negative){
				if(negative>=k){
					if(x-curX<=y-curY){
						curX-=k;
					}else{
						curY-=k;
					}
					negative-=k;
				}else{
					if(x-curX<=y-curY){
						curX-=negative;
						curY+=(k-negative);
					}else{
						curY-=negative;
						curX+=(k-negative);
					}
					negative=0;
				}
			}else{
				if(curX<x){
					if(x-curX>=k){
						curX+=k;
					}else{
						curY+=(k-(x-curX));
						curX=x;
					}
				}else{
					if(y-curY*flagY>=k){
						curY+=k;
					}else{
						curY=y;
					}
				}
			}
			cout<<(curX*flagX)<<" "<<(curY*flagY)<<endl;
		}
	}
	
	return 0;
} 

Measured memory_bytes: 2304
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
def lcm_n(nums):
    return functools.reduce(lcm, nums)

n = ni()
a = na()
a_lcm = lcm_n(a)
ans = 0
for ai in a:
    ans += a_lcm // ai
ans %= mod
print(ans)


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

const int p = 8000;

//x=-8000 flist={8000}
bool dp(vector<int> flist, int x){
  if(flist.size()==0)return x == 0;

  vector<vector<int>> dp(flist.size(), vector<int>(p*2+2,0));

  dp[0][flist[0]+p]=1;
  FOR(i,1,flist.size()){
    REP(j,dp[i].size()){
      if(dp[i-1][j]){
        dp[i][j+flist[i]]=1;
        dp[i][j-flist[i]]=1;
      }
    }
  }

  return dp[flist.size()-1][p+x] == 1;
}

int main(){
  string s;
  cin >> s;
  int x,y;
  cin >> x >> y;

  vector<int> a,b;
  int flag=1;
  int cnt=0;
  s+='T';
  if(s[0]=='T'){
    a.push_back(0);
  }
  b.push_back(0);
  REP(i,s.size()){
    if(s[i]=='T'){
      if(flag){
        if(cnt)a.push_back(cnt);
      }else{
        if(cnt)b.push_back(cnt);
      }
      flag ^= 1;
      cnt=0;
    }else{
      cnt++;
    }
  }

  // REP(i,a.size()){
  //   cout << a[i] << " ";
  // }
  // cout << endl;
  // REP(i,b.size()){
  //   cout << b[i] << " ";
  // }
  // cout << endl;

  cout << (dp(a,x) && dp(b,y) ? "Yes" : "No") << endl;
}



Measured memory_bytes: 167168
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;
int check[200010];
int main() {
  int N,K; cin >> N >> K;
  int A[200010];

  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
    check[A[i]]++;
  }
  int cnt = 0;
  for ( int i = 1; i < 200001; i++ ) {
    if ( check[i] > 0 ) cnt++;
  }
  
  sort(check,check+200001);
  //  cout << cnt << endl;

  if ( cnt <= K ) {
    cout << 0 << endl;
    return 0;
  }
  
  int ans = 0;
  for ( int i = 1; i < 200001; i++ ) {
    if ( check[i] > 0 ) {
      ans += check[i];
      cnt--;
      if ( cnt <= K ) break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N,x,y;
  cin >> N;
  cout << 800*N-200*(N/15) << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N, _, W = LI()
    a = LI()

    # 初手でラストまで取るとき
    res = abs(a[-1] - W)
    if N == 1:
        print(res)
        return
    res2 = abs(a[-1] - a[-2])

    # 最後から n 枚目を取るときの max, min
    max_li = [0, res, res2] + [0 for _ in range(N)]
    min_li = [INF, res, res2] + [INF for _ in range(N)]
    for i in range(3, N+1):
        take_all = abs(a[-i] - a[-1])
        max_li[i] = min([min_li[j] for j in range(2, i)]+[take_all])
        min_li[i] = max([max_li[j] for j in range(2, i)]+[take_all])

    print(max(max_li))


main()

Measured memory_bytes: 3316
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i > 0; --i)
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int a = 0, z;
	char s[200000];
	bool flag = false;
	scanf("%s", s);
	z = strlen(s);
	while (s[a] != 'A')++a;
	while (s[z] != 'Z')--z;
	printf("%d\n", z - a + 1);

	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
while pro <= n:
  pro *= k
  count += 1
print(count)
  

Measured memory_bytes: 38256
n,c,k=map(lambda x: int(x), input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
ans=1
sta=t[0]
man=1
for i in range(1,n):
    if t[i]<=sta+k and man<c:
        man+=1
    else:
        sta=t[i]
        man=1
        ans+=1
print(ans)

Measured memory_bytes: 7472
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using iii = pair<int, ii>;

using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvvi = vector<vi>;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	int sol = 0;

	if (n >= 10) {
		sol += 9;
	}
	else {
		cout << n << '\n';
		return true;
	}

	if (n > 99) {}
	else {
		cout << 9 << '\n';
		return true;
	}

	if (n > 999) {
		sol += (999 - 99);
	}
	else {
		sol += (n - 99);
		cout << sol << '\n';
		return true;
	}

	if (n > 9999) {}
	else {
		cout << sol << '\n';
		return true;
	}

	sol += (n - 9999);
	if (n == 100000) --sol;
	cout << sol << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())

p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

answer = 0
_ids = [0,0,0]

while sum(_ids) < x+y:
    _answer = []
    _x, _y, _k = _ids
    if _x != x:
        _answer += [p[_x]]
    else:
        _answer += [0]
    if _y != y:
        _answer += [q[_y]]
    else:
        _answer += [0]
    if _k != c:
        _answer += [r[_k]]
    else:
        _answer += [0]
    tmp = 0
    for i, _a in enumerate(_answer):
        if tmp < _a:
            tmp = _a
            _id = i
    answer += tmp
    _ids[_id] += 1
    
print(answer)

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

signed main() {
  int64_t m,n;
  cin >> n >> m;
  
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
N,K,Q = map(int, input().split())


S = []
for _ in range(Q):
    S.append(input())

#score_l = [K] * N
seikai_num = [K-Q] * N

for j in S:
        seikai_num[int(j)-1] += 1



for num in seikai_num:
        if num > 0:
                print("Yes")
        else:
                print("No")



Measured memory_bytes: 12872
n = int(input())
c = input()
_trigger = False
ans = [0 for i in range(2)]
_count = c.count('R')
for i in range(len(c)):
  if c[i] == 'W':
    _trigger = True
    if _count >= i + 1:
      ans[1] += 1
  else:
    if _trigger == True and i + 1 >= _count:
      ans[0] += 1
print (min(ans))

Measured memory_bytes: 9488
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
int n, m, sum; string s, t;
const ll MOD= 1000000007;
int main() {
    cin >> n >> s;
    if (n >= s.size()) {
        cout << s << endl;
    }
    else {
        cout << s.substr(0, n) << "..." << endl;
    }
}

Measured memory_bytes: 3628
i1 = input()
i2 = input()

# i1 = "4 1"
# i2 = "5 4 2 1"
list1 = [int(s) for s in i1.split()]
list2 = [int(s) for s in i2.split()]

n = list1[0]
m = list1[1]


total = sum(list2)

# 選べる
count = 0

for a in range(n):
    if (list2[a]/total >= 1/(4*m)):
        count += 1 

if count >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    char c;
    cin >> c;
    if(abs(c-'A')<=26)puts("A");
    else puts("a");
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define MAXN 100005
#define inf 1000000000001
using namespace std;

int main (){
	
	//freopen("t.txt","r",stdin);
	string s,t; cin>>s>>t;
	int d=0;
	for (int i=0;i<3;i++){
		if (s[i]==t[i]) d++;
	}
	cout<<d;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

void solve(long long A, long long B, long long C){
    auto tmp = min(C, A-B);
    cout << C-tmp << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct node{
    int key;
    struct node *next;
    struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
/*
NodePointer listSearch(int key){
    NodePointer t;
    for(t = nil -> next;t != nil;t = t -> next){
        if(t -> key == key){
            return t;
        }
    }
}*/
 
void init(){
    nil = (struct node*)malloc(sizeof(struct node));
    nil -> next = nil;
    nil -> prev = nil;
}
 
void printList(){
    struct node *p;
    for(p = nil -> next; p != nil;p = p -> next){
        if(p != nil -> prev){
            printf("%d ", p -> key);
        }else if(p == nil -> prev){
            printf("%d\n", p -> key);
        }
    }
    /*
    NodePointer cur = nil -> next;
    int isf = 1;
    while(1){
        if(cur == nil) break;
        if(isf == 0) printf(" ");
        printf("%d\n", cur -> key);
        cur = cur -> next;
        isf = 0;
    }
    printf("\n");
    */
}
 
void deleteNode(NodePointer t){
    if(t -> prev == nil){//deleteFirst
        nil -> next = t -> next;
        t -> next -> prev = nil;
        free(t);
    }else if(t -> next == nil){//deleteLast
        nil -> prev = t -> prev;
        t -> prev -> next = nil;
        free(t);
    }else{
        t -> prev -> next = t -> next;
        t -> next -> prev = t -> prev;
        free(t);
    }
}
 
void deleteFirst(){
    NodePointer t = nil -> next;
    if(t == nil) return;
    deleteNode(t);
}
 
void deleteLast(){
    NodePointer t = nil -> prev;
    if(t == nil) return;
    deleteNode(t);
}
 
void del(int key){
    //NodePointer t;
    struct node *p;
 
    if(nil -> key == key){
        deleteFirst();
        return;
    }
    for(p = nil -> next;p != nil;p = p -> next){
        if(p -> key == key){
            deleteNode(p);
            return;
        }
    }
 
    //t = listSearch(t);
 
}
 
void insert(int key){
    NodePointer x;
    x = (struct node*)malloc(sizeof(struct node));
    x -> key = key;
 
    if(nil -> next == nil){
        nil -> prev = x;
    }
 
    x -> next = nil -> next;
    x -> prev = nil;
    nil -> next -> prev = x;
    nil -> next = x;
}
 
int main(void){
    int key,n,i;
    char com[200];
    scanf("%d", &n);
 
    init();
 
    for(i = 0;i < n;i++){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d", &key);
            insert(key);
        }else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F') deleteFirst();
                else if(com[6] == 'L') deleteLast();
            }else{
                scanf("%d", &key);
                del(key);
            }
        }
    }
 
    printList();
    return 0;
}

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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shwv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dbg(x) cerr << #x << ": " << (x) << endl;
#define dbgv(v) cerr << #v << ": "; _shwv(v);
#define dbgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shwv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void prt(T x) { cout << x << endl; }
template<typename T> inline void getv(T& v) { for (auto& t : v) cin >> t; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    int k;
    string s;
    cin >> k >> s;
    if (siz(s) <= k)
        prt(s);
    else {
        prt(s.substr(0, k) + "...");
    }

    return 0;
}


Measured memory_bytes: 3600
/*{{{*/
#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
template<class T, class U> void _R(pair<T, U> &x) {_R(x.F); _R(x.S);}
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

template<class T, class... U> void DB(const T &head, const U &... tail) {
#ifdef HOME
    _W('#'); W(head, tail...);
#endif
}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)

#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef int64_t ll;
/*}}}*/

int n;
vi a;

int main(){
    R(n);
    FOR(i,n){ int x; R(x); a.EB(x); }
    UNIQUE(a);
    W(SZ(a));

    return 0;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; 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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n;
	cin>>n;
	vector<pair<string,int>> dp[10];
	dp[0].push_back(make_pair("a",0));
	rep(i,1,n){
		rep(j,dp[i-1].size()){
			rep(k,dp[i-1][j].second+2){
				char ch = (char)('a'+k);
				std::string s{ch};
				//cout<<s<<endl;
				if(k==dp[i-1][j].second+1)dp[i].push_back(make_pair(dp[i-1][j].first+s,dp[i-1][j].second+1));
				else dp[i].push_back(make_pair(dp[i-1][j].first+s,dp[i-1][j].second));
			}
		}
	}
	sort(dp[n-1].begin(),dp[n-1].end());
	rep(i,dp[n-1].size()){
		cout<<dp[n-1][i].first<<endl;
	}
}


Measured memory_bytes: 10736