akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve(int test) {
	
	int n; cin >> n ;
	int a[n+1]; rep(i,1,n+1) cin >> a[i] ;
	int ans=0;
	for(int i = 1; i <= n ; i+=2) {
		if(a[i]&1) ++ans;
	}
	cout << ans ;
}
 
int32_t main() {
 

    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int judge;
    for (int i = 0; i < s.size(); i++) {
        judge += s[i]-'0';
        judge = judge%9;       
    }
    if (judge % 9 == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}




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

int main() {
  string S;
  cin >> S;
  string ans;
  if (S=="Sunny") ans="Cloudy";
  if (S=="Cloudy") ans="Rainy";
  if (S=="Rainy") ans="Sunny";
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<P> v(N);
    REP(i, 0, N) {
        cin >> v[i].first >> v[i].second;
    }
    sort(begin(v), end(v));
    ll ans = 0;
    for (auto &p : v) {
        if (M > p.second) {
            ans += p.second * p.first;
            M -= p.second;
        } else {
            ans += M * p.first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
    long long n, k, ans = 0;
    cin >> n >> k;
    for (long long i = k; i <= n + 1; i++)
        ans = (ans + i * (n - i + 1) + 1) % mod;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3616
n=int(input())

s=[]
for i in range(n):
    s.append(input())

s_dict={}
for word in s:
    if word in s_dict:
        s_dict[word] += 1
    else:
        s_dict[word] = 1

Ms = max(s_dict.values())

keys = [k for k, v in s_dict.items() if v == Ms]


for i in sorted(keys):
    print(i)

Measured memory_bytes: 103028
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
long long N;
    cin >> N;
    //pairの書き換えが煩雑であるので、素数リストと指数連想配列に分ける
   map<ll,ll> prime_count;
   vector<ll> prime_list;
   rep3(j,N){
    //resに素数のペア(素数、その素数の指数）の配列が入る
    const auto  &res = prime_factorize(j);
    
   rep(i,res.size()){
       if(prime_count[res[i].first]==0){
           prime_list.push_back(res[i].first);
       }
       prime_count[res[i].first]+=res[i].second;
   }
   }
   int num_2=0,num_4=0,num_14=0,num_24=0,num_74=0;
   rep(i,prime_list.size()){
       int p=prime_list[i];
       if(prime_count[p]>=2){
           num_2++;
       }
       if(prime_count[p]>=4){
           num_4++;
       }
       if(prime_count[p]>=14){
           num_14++;
       }
       if(prime_count[p]>=24){
           num_24++;
       }
       if(prime_count[p]>=74){
           num_74++;
       }
   }
   ll ans;
   ans=num_74+num_14*(num_4-1)+num_24*(num_2-1)+(num_4*(num_4-1)*(num_2-2))/2;
   cout<<ans<<endl;
   
    
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            string m = "MARCH";
            long[] counter = new long[5];
            long ret = 0;
            for (long i = 0; i < N; i++)
            {
                var firstChar = Console.ReadLine()[0];
                for (int j = 0; j < 5; j++)
                {
                    if (m[j] == firstChar)
                    {
                        counter[j]++;
                    }
                }
            }

            for (int i = 0; i < 5; i++)
            {
                for (int j = i + 1; j < 5; j++)
                {
                    for (int k = j + 1; k < 5; k++)
                    {
                        ret += counter[i] * counter[j] * counter[k];
                    }
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13140
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> s;
  rep(i, Size(s)) {
    rep(j, Size(alph)) {
      if (s[i] == alph[j]) {
        tmp = j;
      }
    }
    tmp += n;
    tmp %= 26;
    cout << alph[tmp];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			StringBuilder out;
			String lb = System.getProperty("line.separator");
			
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(in.readLine());
			String[] line = in.readLine().split("[\\s]+");
			in.close();
			
			int[] seq = new int[n];
			out = new StringBuilder();
			for (int i = 0; i < seq.length; i++) {
				seq[i] = Integer.parseInt(line[i]);
				out.append(String.valueOf(seq[i])).append(i < n-1 ? " " : lb);
			}
			System.out.print(out.toString());
			
			
			for (int i = 1; i < seq.length; i++) {
				final int key = seq[i];
				int j = i-1;
				while (0 <= j && key < seq[j]) {
					seq[j+1] = seq[j];
					j--;
				}
				seq[j+1] = key;
				
				out = new StringBuilder();
				for (int k = 0; k < n; k++) {
					out.append(String.valueOf(seq[k])).append(k < n-1 ? " " : lb);
				}
				System.out.print(out.toString());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21956
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
xp = x
xm = x
for i in range(n+1):
    if not xm in p:
        print(xm)
        exit()
    if not xp in p:
        print(xp)
        exit()
    xp += 1
    xm -= 1

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

void solve (void)
{
  int N;cin>>N;
  cout<<0<<endl;

  string str;
  cin>>str;
  vector<int> vec(N,-1);
  if(str == "Male")
  {
    vec[0] = 0;
  }
  else if(str == "Female")
  {
    vec[0] = 1;
  }
  else
  {
    return;
  }
  int L = 0; int R = N;
  for (int i = 0; i < 19; i++)
  {
    int mid = (L + R)/2;
    cout<<mid<<endl;
    cin >> str;
    int X = -1;
    if (str == "Male")
    {
      X = 0;
    }
    else if (str == "Female")
    {
      X = 1; 
    }
    else
    {
      return;
    }
    
    if(((X == vec[0])&&(mid%2 == 0)) ||( (X != vec[0])&&(mid%2 != 0)))
    {
      L = mid;
    }
    else 
    {
      R = mid;
    }
  }
  
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1620
import sys

def trade(n, a, b):
    a0, a1, a2 = a
    b0, b1, b2 = b
    dp = [0] * (n+1)
    for i in range(1, n+1):
        gold, silver, copper = 0, 0, 0
        if i >= a0:
            gold = dp[i-a0] + b0
        if i >= a1:
            silver = dp[i-a1] + b1
        if i >= a2:
            copper = dp[i-a2] + b2
        dp[i] = max(i, gold, silver, copper)

    return dp[n]


def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    # Trade A -> B
    M = trade(N, A, B)
    # Trade B -> A
    return trade(M, B, A)


if __name__ == '__main__':
    print(main())


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

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}


int main(){
    int n, m, q;
    cin >> n >> m >> q;
    int a[q], b[q], c[q], d[q];
    
    for(int i=0;i<q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    vector<int> v;
    for(int i=1;i<=m;i++){
        for(int j=0;j<n;j++){
            v.push_back(i);
        }
    }

    int ans = 0;
    do{
        int tmp = 0;
        for(int i=0;i<q;i++){
            if(v[b[i]-1]-v[a[i]-1] == c[i]){
                tmp += d[i];
            }
        }
        ans = max(ans, tmp);
    }while(next_combination(v.begin(), v.end(), n));

    cout << ans << endl;

}

Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,j,n,u,k,v,**G;
  scanf("%d",&n);
  G = malloc((n+1) * sizeof(int *));
  for(i=1;i<=n;i++){
    G[i] = malloc((n+1) * sizeof(int));
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      G[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u][v] = 1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",G[i][j]);
    }
    printf("%d",G[i][n]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(s.size()<=k)
    cout<<s;
  else{
    string t="";
    for(int i=0;i<k;i++){
      t=t+s[i];
    }
	t=t+"...";
    cout<<t;
  }
  return 0;
}

Measured memory_bytes: 3620
import math

N=list(input())
ans=0

for i in range(len(N)-1,-1,-1):
    if i!= 0 and int(N[i]) < 9:
        N[i-1]=str(int(N[i-1])-1)
        ans+=int(9)
    else:
        ans+=int(N[i])

print(ans)

Measured memory_bytes: 3060
import Control.Monad
import Control.Applicative
import Data.List



getBysplit = map read . words <$> getLine

main :: IO()
main = do
  lst <- getBysplit :: IO [Int]
  let [a, b] = sort lst
  let ans = if a == b
              then a + b
              else 2 * b -1
  print ans


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main(){
  while(1){
    int a,l; cin >> a >> l;
    if(a == 0 and l == 0) break;
    string s = to_string(a);
    rep(i,l-sz(s)) s.insert(0,"0");
    dump(s);
    vs sq; sq.pb(s);
    string tmp = s;
    bool f = false;
    while(1){
      map<char,int> mp;
      rep(i,sz(tmp)) mp[tmp[i]]++;
      if(sz(tmp) < l) rep(i,l-sz(tmp)) mp['0']++;
      dump(mp);
      string ns;
      for(auto x : mp){
	rep(i,x.snd) ns += x.fst;
      }
      dump(ns);
      int minv = stoi(ns);
      reverse(all(ns));
      int maxv = stoi(ns);
      int ni = maxv - minv;
      tmp = to_string(ni);
      dump(tmp);
      rep(i,sz(sq)) if(sq[i] == tmp){
	cout << i << " " << tmp << " " << sz(sq) - i << endl;
	f = true;
	break;
      }
      if(f) break;
      else sq.pb(tmp);
    }
  }
}


Measured memory_bytes: 3216
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

vector<vector<int>> abl;
vector<int> ans;

void Dfs(int par, int now) {
	for(auto v : abl[now]) {
		if (par == v) continue;
		ans[v] += ans[now];
		Dfs(now ,v);
	}
}

int main()
{
	int n, q;
	cin >> n >> q;
	abl.resize(n + 1);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		abl[a].push_back(b);
		abl[b].push_back(a);
	}
	ans.resize(n + 1);
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		ans[p] += x;
	}
	Dfs(-1, 1);
	rep(i, n + 1) {
		if (i != 0) {
			cout << ans[i] << endl;
		}
	}
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}

Measured memory_bytes: 24292
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <time.h>
#include <vector>

using namespace std;
typedef long long ll;
template <class T = ll>
T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T x) {
    cout << x << "\n";
}
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define reps(x, c) for (auto x : c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a)
#define mp(a, b) make_pair((a), (b))
#define pl pair<ll, ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x "=" << (x) << "\n"
#define dbgv(x) \
    cerr << #x << "\n"; \
    reps(y, x) { cerr << y << " "; } \
    cerr << "\n"

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if ((a < c && c < b) || (a > c && c > b)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  char c;
  cin>>c;
  if(c=='a')
    cout<<"vowel"<<endl;
  else if(c=='e')
    cout<<"vowel"<<endl;
  else if(c=='i')
    cout<<"vowel"<<endl;
  else if(c=='o')
    cout<<"vowel"<<endl;
  else if(c=='u')
    cout<<"vowel"<<endl;
  else
    cout<<"consonant"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B;
    for(int i = 1; i <= 1250; i++){
        int C = i * 0.08;
        int D = i * 0.10;
        if(C == A && B == D){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int MAX = 3e5+3;
const int INF = 1e9;

int main(){

  string str[4] = {"dream","dreamer","erase","eraser"};
  string t,s = "00000000";
  cin >> t;
  int res = t.size();
  s += t;
  int cnt = 0;
  while(cnt != res){
    if(s.substr(s.size()-5) == str[0]){
      cnt += 5; s.erase(s.size()-5,5);
    }
    else if(s.substr(s.size()-7) == str[1]){
      cnt += 7; s.erase(s.size()-7,7);
    }
    else if(s.substr(s.size()-5) == str[2]){
      cnt += 5; s.erase(s.size()-5,5);
    }
    else if(s.substr(s.size()-6) == str[3]){
      cnt += 6; s.erase(s.size()-6,6);
    }
    else {
      cout << "NO" << endl;
      return 0;
    }
    //cout << s << endl;
  }
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N;
	cin>>N;
	
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
		a[i]--;
	}
	
	int ans = 0;
	for(int i=0;i<N;i++){
		if(a[a[i]]==i)ans++;
	}
	
	cout<<ans/2<<endl;

	return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val s= readLine()!!

    var ACGT = listOf('A', 'C', 'G', 'T')

    var ans = 0
    for (i in 0 until s.length) {
        if (!ACGT.contains(s[i])) {
            continue
        }
        var len = 0
        for (j in i until s.length) {
            if (ACGT.contains(s[j])) {
                len++
            } else {
                break
            }
        }
        ans = Math.max(ans, len)
    }
    println(ans)
}

Measured memory_bytes: 35752
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
ll S, T, D;

inline void solve()
{
    cin >> D >> T >> S;
    (T * S < D) ? puts("No") : puts("Yes");
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3604
/*---> 03 December 2019 <--- > 01:28:16 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;
string s;
int n,dp[N][2];
void add(int &a,int b){
	a+=b;
	if(a>=mod)
		a-=mod;
}
int solve(int ind,int lim){
	if(ind==n){
		return 1;
	}
	int &ans=dp[ind][lim];
	if(ans!=-1)
		return ans;
	ans=0;
	int cur=s[ind]-'0';
	if(lim){
		if(!cur)
			add(ans,solve(ind+1,lim));
		else{
			add(ans,solve(ind+1,0));
			add(ans,solve(ind+1,lim));
			add(ans,solve(ind+1,lim));
		}
	}
	else{
		add(ans,solve(ind+1,lim));
		add(ans,solve(ind+1,lim));
		add(ans,solve(ind+1,lim));
	}
	return ans;
}
int32_t main(){__
	cin>>s;
	n=s.length();
	memset(dp,-1,sizeof dp);
	cout<<solve(0,1)<<"\n";
return 0;
}

Measured memory_bytes: 6736
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    string S;
    cin >> S;
    int c = INF, f = 0;
    rep(i, S.size()) {
        if (S[i] == 'C') c = min(c, i);
        if (S[i] == 'F') f = max(f, i);
    }
    if (c < f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;
  ans = N/(A+B)*A;
  N %= (A+B);
  ans += min(N, A);

  cout << ans << endl;

  return 0;
}

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

 
int main() {
    ll a,b,n=1;
    cin>>a>>b;
    while((1+(n-1)*(a-1))<b)
    {
        n++;
    }
    cout<<n-1;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    int n,m,x,y,z,cnt=0;
    cin>>n;
    vector <int> v(n+1);
    for(int i=1;i<=n;i++)cin>>v[i];
    for(int i=1;i<=n;i+=2)cnt+=(v[i]%2!=0);
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3612
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i - 1] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 17860
#include <iostream>
#include <vector>
 
using namespace std;
vector<char> v;
int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'S' || (v.empty() || v.back() == s[i]))
            v.push_back(s[i]);
        else v.pop_back();
    }
    cout << v.size();
    return 0;
}

Measured memory_bytes: 772
from collections import Counter
n = int(input())
A = [Counter(input()) for i in range(n)]

for i in range(n - 1):
    A[i + 1] = A[i] & A[i + 1]

A2 = sorted(A[-1].most_common())
S = ''
for k, v in A2:
    S += k * v
    
print(S)    

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

bool match(string &s, string &t)
{
	for(int i = 0; i < t.length(); i++)
		t[i] = tolower(t[i]);
	return s == t;
}

int main()
{
    string w, t;

	cin >> w;
    int count = 0;
    while(true)
    {
		cin >> t;
        if(t == "END_OF_TEXT")
            break;
        if(match(w, t))
			count++;
    }
	cout << count << endl;

    return 0;
}

Measured memory_bytes: 3048
from collections import Counter

n, p = map(int, input().split())
s = input()

if p == 2 or p == 5:
    ans = 0
    for i, e in enumerate(s, 1):
        if int(e) % p == 0:
            ans += i

    print(ans)

else:
    li = [0]
    for i, e in enumerate(s[::-1], 1):
        li.append((li[-1] + int(e) * pow(10, i, p)) % p)

    c = Counter(li)
    ans = 0
    for v in c.values():
        ans += v * (v - 1) // 2

    print(ans)


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

#define INF (1 << 30)

int main() {
  int N;
  long maxA = -INF;
  long minA = INF;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    long a;
    cin >> a;
    maxA = max(maxA, a);
    minA = min(minA, a);
  }

  cout << maxA - minA << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    while(1){
    int n;
    cin>>n;
    if(n==0)break;
    int a,b,c,d,e,f,g;
    g=1000-n;
    for(a=0;a<2;a++){
        for(b=0;b<5;b++){
            for(c=0;c<2;c++){
                for(d=0;d<5;d++){
                    for(e=0;e<2;e++){
                        for(f=0;f<5;f++){
                            if(a*500+b*100+c*50+d*10+e*5+f==g){
                                cout<<a+b+c+d+e+f<<endl;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
        }
    return 0;
} 


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n%2 == 1) cout << "No";
    else
        if (s.substr(0,n/2) == s.substr(n/2,n/2))
            cout << "Yes";
        else 
            cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t n;
	cin >> n;
	vector<int64_t> a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);

	int ans = 0;
	int want = 1;
	for (int i = 0; i < n; i++) {
		if (a.at(i) == want) want++;
		else {
			ans++;
		}
	}
	if (ans == n) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

// 最大公約数
#if __cplusplus < 201703L
template <typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) { return (b != 0) ? gcd(b, a % b) : abs(a); }
#endif
template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
gcd(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = gcd(res, *first);
    return res;
}
template <typename T>
constexpr T gcd(initializer_list<T> t) { return gcd(t.begin(), t.end()); }

// 最小公倍数
#if __cplusplus < 201703L
template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) { return (a != 0 && b != 0) ? a / gcd(a, b) * b : 0; }
#endif
template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
lcm(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = lcm(res, *first);
    return res;
}
template <typename T>
constexpr T lcm(initializer_list<T> t) { return lcm(t.begin(), t.end()); }

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

    int k; cin >> k;
    ll ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                ans += gcd({a, b, c});
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	char str[1000];
	int se = 0, dig = 1, dignum;

	while (cin >> str){
		for (int i = 0; str[i] != '\0'; i++){
			if (str[i] <= '9' && str[i] >= '0'){
				dignum *= 10;
				dignum += str[i] - '0';
			}	
			if (!(str[i] <= '9' && str[i] >= '0') || (str[i] <= '9' && str[i] >= 0) && str[i + 1] == '\0'){
				se += dignum;
				dignum = 0;
			}
		}
	}
		cout << se << endl;

		return (0);
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define mod (int)(1e9 + 7) 

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n][n];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			 cin >> a[i][j];
		}
	}
	vector<int> dp(1 << n);
	dp[0] = 1;
	for(int mask = 0; mask < (1 << n); mask++){
		int men = __builtin_popcount(mask);
		for(int women = 0; women < n; women++){
			if(a[men][women] && !(mask &(1 << women))){
				int new_mask = mask | (1 << women);
				dp[new_mask] += dp[mask];
				if(dp[new_mask] > mod){
					dp[new_mask] -= mod;
				}
			}
		}
	}
	cout << dp[(1 << n) - 1] << endl;
}


Measured memory_bytes: 11424
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define INF 5000000000000000000LL
#define ll long long
typedef pair<ll,ll>P;
P t[59];

int main(){
  ll n,k;
  ll ny[59];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>t[i].fi>>t[i].se;
    ny[i]=t[i].se;
  }
  sort(ny,ny+n);
  sort(t,t+n);
  ll ans=INF;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      for(int p=0;p<n;p++){
	int cnt=0;
	for(int q=p;q<n;q++){
	  if(ny[i]<=t[q].se&&t[q].se<=ny[j]){
	    cnt++;
	  }
	  if(cnt>=k){
	    ans=min(ans,(ny[j]-ny[i])*(t[q].fi-t[p].fi));
	  }
	}
      }
    }
  }
  cout<<ans<<endl;
  return(0);
}


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

int main() {
    long K, N;
    cin>>K>>N;
    vector<long> arr;
    long tmp;
    for(int i=0;i<N;++i){
        cin>>tmp;
        arr.push_back(tmp);
    }
    sort(arr.begin(), arr.end());
    long sa = 0;
    for(int i=0;i<N-1;++i){
        if(sa<arr[i+1]-arr[i])sa = arr[i+1]-arr[i];
    }
    if(sa<K-(arr[N-1]-arr[0]))sa = K-(arr[N-1]-arr[0]);
    cout<<K-sa<<endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
        using namespace std;
        typedef long long ll;
        typedef long double ld;
        typedef pair<ll, ll> l_l;
        typedef pair<int , int> i_i;
        typedef vector<ll> vl;
        typedef vector<int> vi;
        typedef vector<char> vec;
        typedef vector<bool> veb;
        typedef vector<string> ves;
        typedef vector<vector<ll>> vvl;
        typedef vector<vector<int>> vvi;
        typedef vector<vector<char>> vvec;
        typedef vector<vector<bool>> vveb;
        typedef vector<vector<string>> vves;
        #define rep(i,n) for(int i=0;i<(int)(n);i++)
        #define rep1(i,n) for(int i=1;i<(int)(n);i++)
        #define rep2(i,n) for(int i=2;i<(int)(n);i++)
        #define repk(i,k,n) for(int i=k;i<(int)(n);i++)
        #define fs first
        #define sc second
        #define pb push_back
        #define pp pop_back
        #define all(a) a.begin(),a.end()
        #define rall(a) a.rbegin(),a.rend()
        #define maxel(a) *max_element(all(a))
        #define minel(a) *min_element(all(a))
        #define acc accumulate
        #define EPS (1e-7)
        #define INF (1e9)
        #define PI (acos(-1))
        #define mod (1000000007)
        typedef long long int64;
        //const int64 INF = 1LL << 58;
        #define dame { puts("-1"); return 0;}
        #define YES { cout << "YES" << endl; return 0; }
        #define NO { cout << "NO" << endl; return 0; }
        #define Yes { cout << "Yes" << endl; return 0; }
        #define No { cout << "No" << endl; return 0; }
        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 (a>b) { a=b; return 1; } return 0; }
        int dx[] = {0, 0, -1, 1};
        int dy[] = {1, -1, 0, 0};
         
        int main(){
        	cin.tie(0);
        	ios::sync_with_stdio(false);
         	int a;
          	cin >> a;
          	if(a%2 == 0){
          		cout << a/2 << endl;
            }
          	else{
              	cout << a/2 + 1 << endl;
            }
          	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 REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int A;
    cin >> A;
    
    int cnt;
    while(A>0){
        int n = A%10;
        if (n==2) cnt++;
        A/=10;
    }
    cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B <= C + D) {
    cout << "Right" << endl;
  }
  else if (A + B >= C + D) {
    cout << "Left" << endl;
  }
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin>>n;
    
    vector<int>h(n);
    vector<int>now(n,0);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    
    int ans=0;
    bool loop=true;
    bool need=false;
    int left,right;
    int i=0;
    int tmp=0;
    while(loop){
        if(now[i]<h[i]){
            if(!need){
                tmp=1;
                need=true;
                left=i;
            }
        }
        else{
            if(need){
                right=i;
                for(int j=left;j<right;j++)now[j]++;
                ans++;
                need=false;
            }
        }
        
        i++;
        if(i==n){
            if(!need && tmp==0)break;
            else if(need){
                for(int j=left;j<n;j++)now[j]++;
                ans++;
            }
            i=0;
            tmp=0;
            need=false;
        }
        
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
int main() {
	int n, m; cin >> n >> m;
	int used[200001] = {};
	int a[100001] = {};
	rep1(i, m) {
		cin >> a[i];
	}
	per1(i, m) {
		if (used[a[i]])continue;
		used[a[i]] = 1;
		cout << a[i] << endl;
	}
	rep1(i, n) {
		if (!used[i]) {
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4260
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <ext/pb_ds/assoc_container.hpp>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
//#include "bits/stdc++.h"

using namespace std;

#ifdef LOCAL
#include "../../_library/cc/debug.h"
#define FILE "test"
#else
#define debug(...) 0
#define FILE ""
#endif

vector<vector<int>> adj, adjt, comp;
vector<bool> vis;
vector<int> order;

void topoSort(int u) {
  if (vis[u])
    return;
  vis[u] = true;
  for (int v : adj[u]) {
    topoSort(v);
  }
  order.push_back(u);
}

void dfs(int u) {
  if (vis[u])
    return;
  vis[u] = true;
  comp.back().push_back(u);
  for (int v : adjt[u]) {
    dfs(v);
  }
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  if (fopen(FILE ".in", "r")) {
    freopen(FILE ".in", "r", stdin);
    freopen(FILE ".out", "w", stdout);
  }

  // Textbook implementation of Kosaraju's SCC algorithm
  int n, m;
  cin >> n >> m;

  adj.resize(n);
  adjt.resize(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adjt[v].push_back(u);
  }

  vis.assign(n, false);
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) {
      topoSort(i);
    }
  }
  reverse(order.begin(), order.end());

  vis.assign(n, false);
  for (int x : order) {
    if (!vis[x]) {
      comp.resize(comp.size() + 1);
      dfs(x);
    }
  }

  cout << comp.size() << '\n';
  for (auto& v : comp) {
    cout << v.size() << ' ';
    for (int x : v) {
      cout << x << ' ';
    }
    cout << '\n';
  }
}

Measured memory_bytes: 78144
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll h,w;
    cin>>h>>w;
    vector<string> M(h);
    for(auto &i:M){cin>>i;}
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            if(i+1<h && M[i+1][t]=='.'){dp[i+1][t]+=dp[i][t]; dp[i+1][t]%=MOD;}
            if(t+1<w && M[i][t+1]=='.'){dp[i][t+1]+=dp[i][t]; dp[i][t+1]%=MOD;}
        }
    }
    cout<<dp.back().back()<<endl;
    
    
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>

using namespace std;

int main()
{
    int R;
    
    cin >> R;

    if (R < 1200){
        cout << "ABC" << endl;
    }else if (R >= 1200 && R < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	int n,d,x,y,sum=0;
	double m;
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		m=sqrt(pow(x,2)+pow(y,2));
		if(m<=d)
		sum++;
	}
	cout<<sum;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

bool func(int m, vector<int> &A, int n)
{
    if(n<0){
        return false;
    } else{
        return m-A[n]==0 || func(m-A[n], A, n-1) || func(m, A, n-1);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> A(n);
    for(auto it=A.begin(); it!=A.end(); it++){
        scanf("%d", &(*it));
    }
    sort(A.begin(), A.end());

    int q;
    scanf("%d", &q);
    for(; q; q--){
        int m;
        scanf("%d", &m);
        bool flag=func(m, A, n-1);
        if(flag){
            printf("yes\n");
        } else{
            printf("no\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2684
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M, X1, Y1 = list(map(int, sys.stdin.buffer.readline().split()))
X = list(map(int, sys.stdin.buffer.readline().split()))
Y = list(map(int, sys.stdin.buffer.readline().split()))

X = np.array(X + [X1], dtype=int)
Y = np.array(Y + [Y1], dtype=int)
ok = X.max() < Y.min()
if ok:
    print('No War')
else:
    print('War')



Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
int digit(int a) {
    if (a == 0) return 1;
    int d = 0;
    while (a != 0)
    {
        d++;
        a /= 10;
    }
    return d;
}
int main() {
    int a, b;
    cin >> a >> b;
    if (digit(b) == 1) a = a * 10 + b;
    if (digit(b) == 2) a = a * 100 + b;
    if (b == 100) a = a * 1000 + b;
    int m = sqrt(a);
    if (m * m == a) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main() {
    float d,t,s;
    cin>>d;
    cin>>t;
    cin>>s;
    float time_req = d/s;
    if(time_req<=t)
        cout<<"Yes"<<'\n';
    else
        cout<<"No"<<'\n';
    return 0;
}


Measured memory_bytes: 3720