akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }

int memo[5001];
bool used[5001];
vector<int> vs;
vector<vector<int> > es;

void dfs(int v) {
	used[v] = true;
	for(int i = 0; i < es[v].size(); ++i)
		if(!used[es[v][i]])
			dfs(es[v][i]);

	vs.push_back(v);
}

int length(int v) {
	if(memo[v] != -1)
		return memo[v];

	used[v] = true;
	int res = 0;
	for(int i = 0; i < es[v].size(); ++i)
		if(!used[es[v][i]])
			chmax(res, length(es[v][i]));

	used[v] = false;
	return memo[v] = res + 1;
}

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

	int n, m;
	cin >> n >> m;

	es.resize(n + 1);
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		es[a].push_back(b);
	}

	for(int i = 1; i <= n; ++i)
		if(!used[i])
			dfs(i);

	for(int i = 1; i <= n; ++i)
		cout << vs[n - i] << endl;

	memset(memo, -1, sizeof(memo));
	memset(used, false, sizeof(used));
	cout << (length(vs[n - 1]) == n ? 0 : 1) << endl;

	return EXIT_SUCCESS;
}

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

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long 
#define mod 1000000007
#define llt int test;cin>>test;while(test--)
#define pb push_back
#define setto(n) cout << fixed<< setprecision(n)
#define fi first
#define se second
#define sz(i) int(i.size())
#define all(v) v.begin(),v.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define len(s) s.length()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define INF LONG_MAX
#define random() ((ll)rand() << 32 | rand())

using namespace std; 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int MAX = 100010;

int used[26];
int main(){
	boost;
	string s;
	cin>>s;
	/*if(s.compare("zyxwvutsrqponmlkjihgfedcba") == 0){
		cout<<-1;
		return 0;
	}*/
	for (auto c: s)
		used[c-'a'] = 1;

	if(sz(s) != 26){
		cout<<s;
		for (int i = 0; i <26 ; ++i)
			if(!used[i]){
				cout<<(char)('a' + i);
				return 0;
			}
	}

	int ls = len(s), pos = 0;
	char c;
	for (int i = ls-2; i >=0 ; --i)
	{	
		used[s[i+1]-'a'] = 0;
		if(s[i] == 'z')continue;
		for (int j = 1;  ; ++j)
		{
			char c_ = (char)(s[i]+j);
			// trace(i, j, s[i], c_);
			if(!used[c_-'a']){
				cout<<s.substr(0,i)<<c_;
				return 0;
			}
			if(c_ == 'z')break;
		}
	}
	cout<<-1;
	return 0;
}

// abcdefghijklmnopqrstuvwzyx
// abcdefghijklmnopqrstuvx

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

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String in[] = new String[2];
		int k = 0, x = 0;
		try {
			line = br.readLine();
			in = line.split(" ");
			k = Integer.parseInt(in[0]);
			x = Integer.parseInt(in[1]);
		} catch (IOException e) {
			e.getStackTrace();
		}
		
		int s = x - k + 1;
		if (s < -1000000) s = -1000000;
		
		int f = x + k - 1;
		if (f > 1000000) f = 1000000;
		
		for (int i = s; i < f; i++) {
			System.out.print(i + " ");
		}
		
		System.out.println(f);
	}
}

Measured memory_bytes: 21204
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int k,n,sum=0;
	scanf("%d%d",&k,&n);
	int a[n],b[n];
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(int i=0;i<n-1;i++)
	b[i]=a[i+1]-a[i];
	b[n-1]=k-a[n-1]+a[0];
	sort(b,b+n);
	for(int i=0;i<n-1;i++)
	sum=sum+b[i];
	printf("%d\n",sum);
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, a, b) for(int i = a; i <= b; i++) 
#define ford(i, a, b) for(int i = a; i >= b; i--) 
#define endl "\n"
#define scv(a, b, c) #a#b#c
#define com(a,b) a ## b

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;

typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;
const int BASE = 10000;

void solve() {
	string s;
	cin >> s;
	int n = sz(s);
	vi l(n), r(n);
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'L') {
			r[i] = i;
		} else {
			r[i] = r[i+1];
		}
	}
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			l[i] = i;
		} else {
			l[i] = l[i-1];
		}
	}
	vi res(n, 1);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			res[i]--;
			int dis = r[i] - i;
			if (dis % 2) {
				res[r[i]-1]++;
			} else {
				res[r[i]]++;
			}
		} else {
			res[i]--;
			int dis = i - l[i];
			if (dis % 2) {
				res[l[i]+1]++;
			} else {
				res[l[i]]++;
			}
		}
	}
	for (int x : res) {
		cout << x << " ";
	}
}

int main() {
    #ifdef DEBUG
        com(fre, open) (scv(solve, ., inp), "r", stdin);
        com(fre, open) (scv(solve, ., out), "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 1872
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W,i,j;
    cin>>H>>W;
    vector<string> M(H);
    for(i=0;i<H;i++) cin>>M.at(i);
    for(i=0;i<W;i++){
        for(j=0;j<H;j++)
            if(M.at(j).at(i)=='#') goto loop_1;
        for(j=0;j<H;j++)
            M.at(j).erase(i,1);
        W--;
        i--;
        loop_1:;
    }
    for(i=0;i<H;i++){
        for(j=0;j<W;j++)
            if(M.at(i).at(j)=='#') goto out;
        goto noout;
        out: cout<<M.at(i)<<endl;
        noout:;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a=0,b=0,ab=0,o=0,num;
    char blood[3];
    while(scanf("%d,%s ",&num,blood)!=EOF){
        if(blood[0]=='A' && blood[1]=='B'){
            ab++;
        }else if(blood[0]=='A'){
            a++;
        }else if(blood[0]=='B'){
            b++;
        }else if(blood[0]=='O'){
            o++;
        }
    }
    printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
    return 0;
}

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin >> n >> m;
    if(n == 1 and m == 1){
        cout << 1 << endl;
    } else if(n == 1 or m == 1){
        cout << n * m - 2 << endl;
    } else if(n == 2 or m == 2){
        cout << 0 << endl;
    } else {
        cout << (n - 2) * (m - 2) << endl;
    }
    
}


Measured memory_bytes: 256
s=input().split()
n=int(s[0]);m=int(s[1]);a=[]
for i in range(n) :
  s=input().split()
  a.append((int(s[0]),int(s[1])))
a.sort();now=0;ans=0
while m :
  if a[now][1]>=m :
    ans+=a[now][0]*m
    m=0
  else :
    ans+=a[now][0]*a[now][1]
    m-=a[now][1]
  now+=1
print(ans)

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

using namespace std;

using int64 = long long;
template<typename T> using fn = function<T>;

struct WeightedEdge {
  int from, to;
  int64 weight;
};

vector<vector<WeightedEdge>> ReadUndirectedWeightedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<WeightedEdge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    int64 weight;
    cin >> v1 >> v2 >> weight;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(WeightedEdge({v1, v2, weight}));
    graph[v2].push_back(WeightedEdge({v2, v1, weight}));
  }
  return graph;
}

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

  int n;
  cin >> n;
  auto graph = ReadUndirectedWeightedGraph(n, n - 1, true);
  
  vector<int> visited(n);
  vector<int> colors(n, -1);
  fn<void(int, int)> dfs = fn<void(int, int)>([&] (int v, int color) {
    visited[v] = true;
    colors[v] = color;
    for (const auto& e : graph[v]) {
      if (visited[e.to]) continue;
      int next_color = (color + e.weight) % 2;
      dfs(e.to, next_color);
    }
  });
  dfs(0, 0);

  for (int c : colors) {
    cout << c << endl;
  }
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int a, b;
  cin >> a >> b;

  vector<int> v(1005);
  v[0] = 0;
  REP(i,1,1000){
    v[i] = i + v[i-1];
  }

  rep(i,1000-1){
    if(v[i] - a == v[i+1] - b){
      cout << v[i] - a << endl;
      break;
    }
  }
  
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  string ans = "No";
  for(int i = 1; i < 10; i++){
    if(n % i == 0 && n / i < 10) ans = "Yes";
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c,d,e;
  scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
  if(a==0)
    printf("%d",1);
  else if(b==0)
    printf("%d",2);
  else if(c==0)
    printf("%d",3);
  else if(d==0)
    printf("%d",4);
  else if(e==0)
    printf("%d",5);
  
  return 0;
}

Measured memory_bytes: 2124
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n, m, x;
  std::cin >> n >> m >> x;
  std::vector<int> cost(n);
  std::vector<std::vector<int>> a(n);

  for (int i = 0; i < n; ++i) {
    std::cin >> cost.at(i);
    std::vector<int> ai(m);
    for (int j = 0; j < m; ++j)
      std::cin >> ai.at(j);
    a.at(i) = ai;
  }

  int ans = INT_MAX;

  for (int bit = 0; bit < (1 << n); ++bit) {
    std::vector<int> rikai(m, 0);
    int sum = 0;
    for (int i = 0; i < n; ++i) {

      if (bit & (1 << i)) {
        for (int j = 0; j < m; ++j) {
          rikai.at(j) += a.at(i).at(j);
        }
        sum += cost.at(i);
      }

    }

    bool ok = true;
    for (int j = 0; j < m; ++j) {
      if (rikai.at(j) < x) {
        ok = false;
        break;
      }
    }

    if (!ok)
      continue;

    ans = std::min(ans, sum);
  }

  std::cout << (ans == INT_MAX ? -1 : ans) << std::endl;
}


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

bool searchNum(int n, int S[]){
    int i = 0;
    while(S[i] != S[n]) i++;
    if(i == n) return false;
    return true;
}

int main(){
    int n, S[10001], q, T, ans;
    cin >> n;
    
    for(int i = 0; i < n; i++) cin >> S[i];
    
    ans = 0;
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> T;
        S[n] = T;
        ans += searchNum(n, S);
    }
    
    cout << ans << endl;
    
    return 0;
}



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

int main() {
    string s,t;
    cin >> s >> t;
    int ans=0;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main()
{
	auto pow_mod = [](int64_t a, int64_t n, int64_t mod) {
		int64_t r = 1;
		for (; n; n >>= 1)
		{
			if (n & 1)
			{
				(r *= a) %= mod;
			}
			(a *= a) %= mod;
		}
		return r;
	};

	string s;
	cin >> s;

	int64_t n = s.size(), mod = 1000000007;

	int64_t ans = 0, p = 0;

	for (int64_t i = 0; i < n; i++)
	{
		if (s[i] == '1')
		{
			(ans += pow_mod(2, p, mod) * pow_mod(3, n - i - 1, mod) % mod) %= mod;
			p++;
		}
	}

	(ans += pow_mod(2, p, mod)) %= mod;

	cout << ans << endl;

	return 0;
}

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

int main()
{
  int Time;
  int h,m,s;

  cin >> Time;

  h = Time / 3600;
  m = (Time % 3600) / 60;
  s = (Time % 3600) % 60;

  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

Measured memory_bytes: 1164
#
import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    inside = 0

    top_B = 0
    tail_A = 0
    both = 0
    for _ in range(N):
        s = input()
        inside += s.count('AB')
        if s[0] == 'B' and s[-1] == 'A':
            both += 1
        else:
            if s[0] == 'B':
                top_B += 1
            elif s[-1] == 'A':
                tail_A += 1
    # print('inside = {}, top b = {}, tail a = {}, both = {}'.format(inside, top_B, tail_A, both))
    ans = inside

    if both > 1:
        ans += (both - 1)
        both = 1

    if both > 0:
        if tail_A == 0:
            tail_A += 1
            both -= 1
        if top_B == 0 and both > 0:
            top_B += 1
            both -= 1

    while both > 0 and top_B > 0 and tail_A > 0:
        ans += 2
        both -= 1
        tail_A -= 1
        top_B -= 1

        if both > 0:
            if tail_A == 0:
                tail_A += 1
                both -= 1
        if both > 0:
            if top_B == 0:
                top_B += 1
                both -= 1

    ans += min(top_B, tail_A)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

int main(void) {

	int h, w;
	cin >> h >> w;
	string c[100];
	REP(i, h) {
		cin >> c[i];
	}

	REP(i, h) {
		cout << c[i] << endl << c[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut ans = 0;
    for i in 0..n {
        if i % 2 == 0 && a[i] % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2196
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  cout << (s == t ? "H" : "D") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int l, n; cin >> l >> n;
  vector<int> x(n+1, 0), rev_x(n+1, 0); // 1-index
  FOR(i, 1, n+1) cin >> x[i];
  FOR(i, 1, n+1) rev_x[i] = l - x[n+1-i];
  vector<long long> anticlockwise(n+1, 0), clockwise(n+1, 0);
  REP(i, n) {
    anticlockwise[i+1] = anticlockwise[i] + x[i+1];
    clockwise[i+1] = clockwise[i] + rev_x[i+1];
  }
  long long ans = 0;
  REP(i, n-1) {
    long long tmp = -anticlockwise[i] * 2;
    if ((n-i) % 2 == 1) tmp += (anticlockwise[i+(n-i)/2] + clockwise[(n-i)/2]) * 2 + x[i+(n-i)/2+1];
    else tmp += (anticlockwise[i+(n-i)/2] + clockwise[(n-i)/2-1]) * 2 + rev_x[(n-i)/2];
    ans = max(ans, tmp);
  }
  ans = max(ans, (long long)x[n]);
  REP(i, n) {
    anticlockwise[i+1] = anticlockwise[i] + rev_x[i+1];
    clockwise[i+1] = clockwise[i] + x[i+1];
  }
  REP(i, n-1) {
    long long tmp = -anticlockwise[i] * 2;
    if ((n-i) % 2 == 1) tmp += (anticlockwise[i+(n-i)/2] + clockwise[(n-i)/2]) * 2 + rev_x[i+(n-i)/2+1];
    else tmp += (anticlockwise[i+(n-i)/2] + clockwise[(n-i)/2-1]) * 2 + x[(n-i)/2];
    ans = max(ans, tmp);
  }
  ans = max(ans, (long long)rev_x[n]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

typedef struct _card {
	int number;
	char suit;
} CARD;

CARD A[100000], I[100000];
char inputs[1000000];
char *ptr = inputs;

void exchange(CARD *a, CARD *b);
int Partition(CARD A[], int p, int r);
void Quicksort(CARD A[], int p, int r);

int nextInt(void) {
	int v = 0;
	while (*ptr < '0' || *ptr > '9') ++ptr;
	while (*ptr >= '0' && *ptr <= '9') {
		v = v * 10 + (int)(*ptr - '0');
		++ptr;
	}
	return v;
}

char nextSuit(void) {
	while (*ptr < 'A' || *ptr > 'Z') ++ptr;
	return *ptr;
}

int main(void) {
	int n;
	int stable = 1;
	int i, j, c, d;
	
	fread(inputs, sizeof(char), 1000000, stdin);
	
	n = nextInt();
	
	for (i = 0; i < n; ++i) {
		A[i].suit = nextSuit();
		A[i].number = nextInt();
		I[i] = A[i];
	}
	
	Quicksort(A, 0, n - 1);
	
	for (i = 0; i < n; ++i) {
		if (i == 0) {
			c = 0;
		} else if (A[i].number != A[i - 1].number) {
			c = 0;
		} else {
			++c;
		}
		d = 0;
		for (j = 0; j < n; ++j) {
			if (I[j].number == A[i].number) {
				if (c == d) {
					if (I[j].suit != A[i].suit) {
						stable = 0;
					}
					break;
				}
				++d;
			}
		}
		if (stable == 0) {
			break;
		}
	}
	
	if (stable == 1) {
		puts("Stable");
	} else {
		puts("Not stable");
	}
	
	for (i = 0; i < n; ++i) {
		printf("%c %d\n", A[i].suit, A[i].number);
	}
	
	return 0;
}

void exchange(CARD *a, CARD *b) {
	CARD t = *a;
	*a = *b;
	*b = t;
}

int Partition(CARD A[], int p, int r) {
	CARD x = A[r];
	int i = p - 1;
	int j;
	for (j = p; j < r; ++j) {
		if (A[j].number <= x.number) {
			++i;
			exchange(&A[i], &A[j]);
		}
	}
	exchange(&A[i + 1], &A[r]);
	return i + 1;
}

void Quicksort(CARD A[], int p, int r) {
	int q;
	if (p < r) {
		q = Partition(A, p, r);
		Quicksort(A, p, q - 1);
		Quicksort(A, q + 1, r);
	}
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

ll GCD(ll a,ll b){
  if(a < b){
    return GCD(b,a);
  }
  ll r = INF;
  while(r){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main(){
 ll N;cin >> N;
 vector<ll> A(N);
 for(int i = 0;i < N;i++){
   cin >> A[i];
 }
 ll ans = 0; 
 vector<bool> frag(200010,0);
 frag[0] = 1;
 for(int i = 0;i < N;i++){
   if(frag[A[i]-1] && !frag[A[i]]){
     frag[A[i]] = 1;
     ans++;
   }
 }
 if(ans == 0){
   cout << -1 << endl;
   return 0;
 }
 cout << N-ans << endl;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"

	rbt "github.com/emirpasic/gods/trees/redblacktree"
	"github.com/emirpasic/gods/utils"
)

func main() {
	var N int
	fmt.Scan(&N)
	t := rbt.NewWith(PairComparator)
	for i := 0; i < N; i++ {
		var p Pair
		fmt.Scan(&p.First, &p.Second)
		t.Put(p, i)
	}
	it := t.Iterator()
	for it.Next() {
		fmt.Println(it.Value().(int) + 1)
	}
}

type Pair struct {
	First  string
	Second int
}

func PairComparator(a_, b_ interface{}) int {
	a, b := a_.(Pair), b_.(Pair)
	aDiff := utils.StringComparator(a.First, b.First)
	if aDiff != 0 {
		return aDiff
	}
	bDiff := utils.IntComparator(a.Second, b.Second)
	return -bDiff
}


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

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

P Q[MAX+1];
ll head;
ll tail;

void initialize(){
    head=0;
    tail=0;
}

bool isEmpty(){
    return head==tail;
}

bool isFull(){
    return head==(tail+1)%MAX;
}

void enqueue(P x){
    if(isFull()){
        cout<<"queue data overflow"<<endl;
    }else{
        Q[tail]=x;
        if(tail+1==MAX){
            tail=0;
        }else{
            tail++;
        }
    }
}

P dequeue(){
    P x;
    if(isEmpty()){
        x.name[0]='\0';;
        x.t=0;
    }else{
        x=Q[head];
        if(head+1==MAX){
            head=0;
        }else{
            head++;
        }
    }
    return x;
}
int main(){
    ll n;
    int q;
    cin>>n>>q;
    initialize();
    P temp;
    rep(i,n){
        cin>>temp.name>>temp.t;
        enqueue(temp);
    }
    ll endtime=0;
    while(1){
        P target=dequeue();
        if(target.t==0)break;
        if(target.t>q){
            target.t-=q;
            enqueue(target);
            endtime+=q;
        }else{
            endtime+=target.t;
            cout<<target.name<<" "<<endtime<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;

int main(){
   char str[500];
   int i;
   fgets(str,499,stdin);
   
   for(i=0;i<500;i++){
      if(str[i]>=97&&str[i]<=122)
         str[i]-=32;
   }
   printf("%s",str);
   return 0;
}

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

typedef struct cc {
    char egara;
    int val;
} card;

bool is_stable(vector<card> in, vector<card> out) {
    int n = in.size();
    rep(i, n) {
        for (int j = i+1; j < n; j++) {
            rep(a, n) {
                for (int b = a+1; b< n; b++) {
                    if (in[i].val == in[j].val) {
                        if (in[i].val == out[b].val && in[i].egara == out[b].egara &&
                            in[j].val == out[a].val && in[j].egara == out[a].egara) {
                                return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}

vector<card> bubble_sort(vector<card> c, int n) {
    rep(i, n) {
        for (int j = n-1; i+1<= j; j--){
            if (c[j].val < c[j-1].val) swap(c[j], c[j-1]);
        }
    }
    return c;
}

vector<card>  selection_sort(vector<card> c, int n) {
    int minj;
    rep(i, n) {
        minj = i;
        for (int j = i; j < n;j++) {
            if (c[j].val < c[minj].val){
                minj = j;
            }
        }
        swap(c[i], c[minj]);
    }
    return c;
}

void print_card(vector<card> c) {
    rep(i, c.size()) {
        printf("%c%d", c[i].egara, c[i].val);
        if (i != c.size()-1)
            cout << " ";
    }
    cout << endl;
}
int main() {
    int n;cin >> n;
    vector<card> c(n);
    rep(i, n) {
        cin >> c[i].egara >> c[i].val;
    }

    vector<card> c_bubble = bubble_sort(c, n);
    print_card(c_bubble);
    cout << (is_stable(c, c_bubble) ? "Stable" : "Not stable") << endl;

    vector<card> c_selection = selection_sort(c, n);
    print_card(c_selection);

    cout << (is_stable(c, c_selection) ? "Stable" : "Not stable") << endl;
}



Measured memory_bytes: 3300
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>

using std::accumulate;
using std::array;
using std::cin;
using std::cout;
using std::endl;
using std::for_each;
using std::getline;
using std::replace;
using std::string;
using std::stringstream;

int main() {
	string input;
	while (getline(cin,input)) {
		replace(input.begin(),input.end(),',',' ');
		array<int,10> len; // length of each section
		stringstream str_in(input);
		for_each(len.begin(),len.end(),[&str_in](int& l){str_in >> l;});
		int v1,v2; // velocity of each train
		str_in >> v1 >> v2;

		double total_time = accumulate(len.begin(),len.end(),0)/static_cast<double>(v1+v2);
		double total_len = total_time*v1; // total length the train passes
		int pass_len = 0; // the length the train passes
		int section = 0; // the number of section where the train passes
		while (pass_len < total_len) {
			pass_len += static_cast<double>(len[section++]);
		}
		cout << section << endl;
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];

	ll res = 0;
	while(1){
		bool flag = true;
		REP(i, N){
			if(a[i]>=N){
				flag = false;
				ll tmp = a[i]/N;
				res += tmp;
				a[i] -= tmp*N;
				REP(j, N){
					if(j==i) continue;
					a[j] += tmp;
				}
			}
		}
		if(flag) break;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; ++i )
int main(){
  int N,L,E[81],dp[81][161];
  cin >> N;
  while( N-- ){
    int ans = 0;
    cin >> L;
    rep(i,L) cin >> E[i];
    fill_n(dp[0],81*161,0);
    dp[0][0] = E[0];
    for(int i = 1 ; i < L ; i++){
      for(int j = 0 ; j < 161 ; j++ ){
        int back = dp[i-1][j];
        dp[i][back] = max(dp[i][back],E[i]);
        if(back>0) dp[i][back-1] = max(dp[i][back-1],E[i]+j);
      }
    }
    cout << *max_element(dp[L-1],dp[L-1]+161) << endl;
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  string s, t;
  int ans = 0;

  cin >> s >> t;
  // vi v(n);
  // REP(i, n) {
  //   cin >> v[i];
  // }
  REV(t);

  cout << (s == t ? "YES" : "NO") << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


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

int main(){
  
  int N;
  string name;
  vector<string> S;
  map<string, int> S2;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    
    cin >> name;
    S.push_back(name);
    
  }  
  
  for (auto SS : S) {
    
    if (!S2.count(SS)) {
      
      S2[SS] = 1;
      
    }  
    
  }  
  
  cout << S2.size() << endl;
}

Measured memory_bytes: 25060
#include <stdio.h>
 
#define LEN 25000
 
int Terrain(char* ascii, int len, int p, int q){
  int depth = 0, i;
  double b = 0;

  for(i = p; i < q; i++){
    if(ascii[i] == '/'){
      b += (double)depth - 0.5;
      depth--;
    }
    if(ascii[i] == '\\'){
      b += (double)depth + 0.5;
      depth++;
    }
    if(ascii[i] == '_'){
      b += depth;
    }
  }
  return b;
}
 
 int main(){
  char ascii[LEN];
  int i, len, det;
  int sum = 0, alt = 0, pl = 0, stk = 0;
  int height[LEN] = {0}, ex[LEN] = {0};

  scanf("%s", ascii);
  for(len = 0; ; len++){
    height[len] = alt;
    if(ascii[len] == '/'){
      alt++;
    }
    if(ascii[len] == '\\'){
      alt--;
    }
    if(ascii[len] == '\0'){
      break;
    }
  }

  while(pl < len){
    while(ascii[pl] != '\\' && pl < len){
      pl++;
    }
    det = pl+1;
    while(det <= len && height[det] != height[pl]){
      det++;
    }
    if(det <= len){
      ex[stk++] = Terrain(ascii, len, pl, det);
      pl = det;
    }else{
      pl++;
    }
  }

  for(i = 0; i < stk; i++){
    sum += ex[i];
  }

  printf("%d\n%d", sum, stk);

  for(i = 0; i < stk; i++){
    printf(" %d", ex[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	// COME_LET_THE_GAMES_BEGIN();
	ll x = 1000000000;
	ll S;
	cin >> S;
	if (S % x == 0) {
		printf("0 0 %lld 0 0 %lld\n", x, S / x);
		return 0;
	}
	ll SS = (S / x) * x + x;
	printf("0 0 %lld %lld %lld %lld\n", x, 1, SS - S, SS / x);
}

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

using namespace std;

int v1[100001][4];

int get_happiness(int day, int n, int last, int arr[][4])
{	
	if(day >=2 && day <=n)
	{
		if(last==1)
		{
			if(arr[day][1]==-1)
			{
				arr[day][1] =  max(v1[day][2] + get_happiness(day+1,n,2,arr), v1[day][3] + get_happiness(day+1,n,3,arr));
			}
			return arr[day][1];
		}
		else if(last==2)
		{
			if(arr[day][2]==-1)
			{
				arr[day][2] =  max(v1[day][1] + get_happiness(day+1,n,1,arr), v1[day][3] + get_happiness(day+1,n,3,arr));
			}
			return arr[day][2];
		}
		else if(last==3)
		{
			if(arr[day][3]==-1)
			{
				arr[day][3] =  max(v1[day][1] + get_happiness(day+1,n,1,arr), v1[day][2] + get_happiness(day+1,n,2,arr));
			}
			return arr[day][3];
		}
	}
	else
	{
		return 0;
	}
}

int wrapper(int n, int arr1[][4])
{
	int arr[3];
	arr[0] = get_happiness(2,n,1,arr1) + v1[1][1];
	arr[1] = get_happiness(2,n,2,arr1) + v1[1][2];
	arr[2] = get_happiness(2,n,3,arr1) + v1[1][3];
	sort(arr,arr+3);
	return arr[2];
}

int main()
{
	int n,i;
	cin>>n;
	int arr[n+1][4];
	for(i=1;i<=n;++i)
	{
		cin>>v1[i][1]>>v1[i][2]>>v1[i][3];
	}
	arr[n][1] = max(v1[n][2],v1[n][3]);
	arr[n][2] = max(v1[n][1],v1[n][3]);
	arr[n][3] = max(v1[n][1],v1[n][2]);
	for(i=1;i<n;++i)
	{
		arr[i][1] = arr[i][2] = arr[i][3] = -1;	
	}
	cout<<wrapper(n,arr)<<endl;
	return 0;
}


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

ll L;

inline ll read(){
    ll s = 0, w = 1;
    char ch = getchar();
    for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
    for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
    return s * w;
}

inline void work(){
    L = read();
    printf("%.12f\n", pow(L * 1.0 / 3, 3));
}

int main(){
    work();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
const int Maxn=200005;
int a[Maxn],b[Maxn];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	if (n%2==0){
		for (int i=0;i<n;i++){
		if (i%2==0){
			int j=i/2+n/2;
			b[j]=a[i];
		}
		else{
			int j=n/2-i/2-1;
			b[j]=a[i];
		}
	}
	}
	else{
		for (int i=0;i<n;i++){
			if (i%2==1){
				int j=i/2+n/2+1;
				b[j]=a[i];
			}
			else{
				int j=n/2-i/2;
				b[j]=a[i];
			}
		}
	}
	for (int i=0;i<n;i++){
		printf("%d ",b[i]);
	}
	printf("\n");
	return 0;
} 

Measured memory_bytes: 3712
n = int(input())
b = list(map(int, input().split()))

ans = []

while b:
    for i in range(len(b)-1, -1, -1):
        if b[i] == i+1:
            ans.append(b.pop(i))
            break
    else:
        ans = [-1]
        break

ans.reverse()
print(*ans, sep="\n")


Measured memory_bytes: 3064
n = int(input())
E = {}

for i in range(n-1):
    a, b, c = map(int, input().split()) 
    found = E.get(a, None)
    if found is None:
        found = []
    found.append((b, c))
    E[a] = found
    found = E.get(b, None)
    if found is None:
        found = []
    found.append((a, c))
    E[b] = found

q, k = list(map(int, input().split()))
Q = [tuple(map(int, input().split())) for i in range(q)]


def make_distance_from_k(k, E):
    d = {}
    d[k] = 0
    queue = [k]
    while queue:
        i = queue.pop()
        for j, c in E[i]:
            if j not in d:
                d[j] = d[i] + c
                queue.append(j)
    return d

d = make_distance_from_k(k, E)

for x, y in Q:
    print(d[x] + d[y])


Measured memory_bytes: 73584
#include <iostream>

int main()
{
    int N; // input
    std::cin >> N;
    int A[N+1]; // food
    int B[N+1]; // satisfaction
    int C[N]; // bonus
    for (int i {1}; i <= N; i++)
        std::cin >> A[i];
    for (int i {1}; i <= N; i++)
        std::cin >> B[i];
    for (int i {1}; i < N; i++)
        std::cin >> C[i];
    int ans {};
    for (int i {1}; i <= N; i++)
    {
        ans += B[A[i]];
        if (i > 1 && A[i] == A[i-1] + 1)
            ans += C[A[i-1]];
    }
    std::cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> d(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> d.at(i);
    }
    int A = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( int j = i + 1; j < N; j++){
            A += d.at(i) * d.at(j);
        }
    }
    cout << A << endl;
}

Measured memory_bytes: 256
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

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

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

  string s;
  cin >> s;
  int ans = 0;
  int tmp = 0;
  REP(i, 3) {
    if (s[i] == 'R')
      tmp++;
    else {
      chmax(ans, tmp);
      tmp = 0;
    }
  }
  chmax(ans, tmp);
  cout << ans << endl;
  return 0;
}


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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a) (a)>0 ?(a):-(a)
#define llong long long

int main(){
	char s[20],t[20];
	scanf("%s %s",s,t);
	int k=0;
	while( s[k]!=0 ){
		if( s[k]!=t[k] ){
			printf("No");
			return 0;
		}
		k++;
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 1728
#!/usr/bin/python3
# -*- coding: utf-8 -*-

mn,mx = -1000000,1000000

k,x = map(int, input().split())

mn = max(mn,x-k+1)
mx = min(mx,x+k-1)
print(" ".join([str(i) for i in range(mn,mx+1)]))


Measured memory_bytes: 38384
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],4)[0];
  var X = myconv(input[0],4)[1];
  input.shift();
    input = input.map((a)=>Number(a));;
  var output = N;
  for(var i = 0; i < N; i++){
    X -= input[i];
  }
  output += Math.floor(X / Math.min.apply(null,input));
  myout(output);
}
Main(myin());

Measured memory_bytes: 7372
import java.io.*;
import java.util.*;

class Main{
	private static ArrayList<String> tri_check(ArrayList<Integer> a){
		ArrayList<String> b = new ArrayList<String>();
		
		for(int i = 0;i<a.size()/3;i++){
			int x2,y2,z2;

			x2 = a.get(i*3)*a.get(i*3);
			y2 = a.get(i*3+1)*a.get(i*3+1);
			z2 = a.get(i*3+2)*a.get(i*3+2);
			
			if((x2+ y2) == z2 || (x2 + z2) == y2 || (y2 + z2) == x2)b.add("YES");  
			else b.add("NO");
			}
		return b;
	}
	private static void print_tri(ArrayList<String> a){
		for(int i = 0;i<a.size();i++){
			System.out.println(a.get(i));
		}
	}
		public static void main(String args[]) throws IOException{
			ArrayList<Integer> tri = new ArrayList<Integer>();
			Scanner scan = new Scanner(System.in);
			
			int a;
			
			a = Integer.parseInt(scan.next());
			
			for(int i = a;i > 0;i--){
				try{
					for(int j = 0;j<3;j++){
						String str1 = scan.next();
						
						tri.add(Integer.parseInt(str1));
						}
					}
				catch(NumberFormatException e){
					break;
				}
			}
			ArrayList<String> res = new ArrayList<String>();
			res = tri_check(tri);
			print_tri(res);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    string s; 
    cin >> s;
    int ans = 0;
    int l = 0, r = s.size() -1;
    while (l < r) {
        if (s[l] == s[r]) {
            ++l; --r;
            continue;
        }
        if (s[l] == 'x') {
            ++l;
            ++ans;
            continue;
        }
        if (s[r] == 'x') {
            --r;
            ++ans;
            continue;
        }
        ans = -1;
        break;
    }
    cout << ans << endl;
    return 0;
}

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

#define F 26

typedef struct trieNode{
  int cnt;
  struct trieNode *next[F];
} trie;

trie* newNode(void){
  static trie *buf=NULL;
  if(buf==NULL) buf=(trie *)malloc(sizeof(trie)*(400000+100000+1));
  trie *res=buf++;
  res->cnt=0;
  int i;
  for(i=0;i<F;i++) res->next[i]=NULL;
  return res;
}

trie* add(trie *r,char *s){
  if(r==NULL) r=newNode();
  r->cnt++;
  if(*s!='\0') r->next[*s-'a']=add(r->next[*s-'a'],s+1);
  return r;
}

int count(trie *r){
  return r==NULL?0:r->cnt;
}

void calc(trie *r,char *s,int *cnt,int *before){
  if(*s=='\0') return;
  int local=r->cnt;
  int i;
  for(i=0;i<F;i++){
    int c=count(r->next[i]);
    local-=c;
    if(*s!='a'+i) cnt[(*s-'a')*F+i]+=c;
  }
  *before+=local;
  calc(r->next[*s-'a'],s+1,cnt,before);
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  char **sp=(char **)malloc(sizeof(char *)*n);
  char *s=(char *)malloc(sizeof(char)*(400000+n));
  trie *root=NULL;
  char *p=s;
  int i;
  for(i=0;i<n;i++){
    scanf("%s",p);
    root=add(root,p);
    sp[i]=p;
    while(*p!='\0') p++;
    p++;
  }
  int *before=(int *)calloc(n,sizeof(int));
  int *cnt=(int *)calloc(F*F*n,sizeof(int));
  for(i=0;i<n;i++) calc(root,sp[i],cnt+F*F*i,before+i);
  int q;
  scanf("%d",&q);
  while(q--){
    int k;
    char pe[27];
    scanf("%d%s",&k,pe);
    k--;
    int ans=before[k];
    int j;
    for(i=F-1;i>=0;i--){
      for(j=i-1;j>=0;j--){
	ans+=cnt[(k*F+pe[i]-'a')*F+pe[j]-'a'];
      }
    }
    printf("%d\n",ans+1);
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 292480
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

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

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


	ll N;
	vector<ll> h(102, 0);
	

	cin >> N;

	rep(i, N) {
		cin >> h[i];
	}

	ll max = *max_element(h.begin(), h.end());
	ll count = 0;
	
	rep(i, max) {
		rep(k, N) {
			if (h[k] != 0 && h[k + 1] == 0) {
				count++;
			}

			if (h[k] != 0) h[k]--;
		}
	}

	cout << dec << count;

	return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

bool is_number(string str);

int main()
{
    string str;
    getline(cin, str);

    stringstream ss;
    ss << str;

    int count;
    vector<string> vec(200);
    for (count = 0; !ss.eof(); ++count)
        ss >> vec[count];

    vector<int> stack;
    for (int i = 0; i < count; ++i) {
        if (is_number(vec[i])) {
            stringstream ss;
            ss << vec[i];
            int tmp;
            ss >> tmp;
            stack.push_back(tmp);
        } else {
            if (vec[i] == "+") {
                int num1, num2;
                num2 = stack.back();
                stack.pop_back();
                num1 = stack.back();
                stack.pop_back();

                stack.push_back(num1 + num2);
            } else if (vec[i] == "-") {
                int num1, num2;
                num2 = stack.back();
                stack.pop_back();
                num1 = stack.back();
                stack.pop_back();

                stack.push_back(num1 - num2);
            } else if (vec[i] == "*") {
                int num1, num2;
                num2 = stack.back();
                stack.pop_back();
                num1 = stack.back();
                stack.pop_back();

                stack.push_back(num1 * num2);
            }
        }
    }

    cout << stack.front() << '\n';
}

bool is_number(string str)
{
    for (int i = 0; i < str.size(); ++i) {
        if (i == 0 && str[i] == '-' && str.size() != 1)
            continue;

        if (!isdigit(str[i]))
            return false;
    }

    return true;
}



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

using namespace std;

int facctorialMethod(int k);

int main(){
    int h,w;
	cin>>h>>w;
	string s;
	for(int i=0;i<h;i++){
    	cin>>s;
		cout<<s<<endl<<s<<endl;
    }
}


Measured memory_bytes: 256