akhauriyash/Code-Regression huggingface dataset:
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = (int) 1e5;

int n;

vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

inline int BFS(int S)
{
	static queue<int> q;
	static int d[MAXN + 5];
	memset(d, -1, sizeof d);

	d[S] = 0, q.push(S);
	while(!q.empty())
	{
		int u = q.front();
		q.pop();

		for(auto v : adj[u]) if(d[v] == -1) d[v] = d[u] + 1, q.push(v);
	}

	return max_element(d + 1, d + n + 1) - d;
}

int is_dia[MAXN + 5], pre[MAXN + 5], size[MAXN + 5], son[MAXN + 5];

inline void dfs(int u, int fa)
{
	pre[u] = fa, is_dia[u] = 1;

	size[u] = 1;
	son[u] = 0;
	for(auto v : adj[u]) if(v != fa)
	{
		dfs(v, u);
		size[u] += size[v];
		++son[u];
	}
}

int s[MAXN + 5], N = 0;

inline int find_dia()
{
	int u = BFS(1), v = BFS(u);
	dfs(u, 0);

	if(son[v] != size[v] - 1) return 0;
	s[++N] = son[v];
	for(int p = v; pre[p]; p = pre[p])
	{
		if(son[pre[p]] - 1 != size[pre[p]] - size[p] - 1) return 0;
		s[++N] = son[pre[p]] - 1;
	}
	return 1;
}

inline void solve()
{
	if(!find_dia()) { puts("-1"); return; }

	auto calc = [] (int *p)
	{
		int cnt = 0;
		for(int i = 1, j = 0; i <= N; ++i)
		{
			p[j + s[i] + 1] = ++cnt;
			for(int k = 1; k <= s[i]; ++k) p[j + k] = ++cnt;
			j += s[i] + 1;
		}
	};

	auto output = [] (int *p)
	{
		for(int i = 1; i <= n; ++i) printf("%d ", p[i]);
		puts("");
	};

	static int p[MAXN + 5], q[MAXN + 5];

	calc(p);
	reverse(s + 1, s + N + 1);
	calc(q);
	for(int i = 1; i <= n; ++i)
	{
		if(p[i] < q[i]) { output(p); return; }
		if(p[i] > q[i]) { output(q); return; }
	}
	output(p);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 12544
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int n;
    scan(n);

    if (n == 0 || n == 1) {
        writeln(1);
        return;
    }

    auto f = new long[](n + 1);
    f[0] = f[1] = 1;
    foreach (i ; 2 .. n + 1) {
        f[i] = f[i - 1] + f[i - 2];
    }

    writeln(f[n]);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



Measured memory_bytes: 2496
#!/usr/bin/env python3
m, d = map(int, input().split())
ans = 0
for i in range(1, m + 1):
    for j in range(10, d + 1):
        if j // 10 < 2 or j % 10 < 2:
            continue
        if i == (j // 10) * (j % 10):
            ans += 1
print(ans)


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

typedef long long int ll;
typedef vector<int> vi;            
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int>     pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

vvl vects;
void dfs(ll id, vl &p, vl &c, vb &visit){
    if(visit[id]) return;
    vects.back().pb(c[id]);
    visit[id] = true;
    dfs(p[id], p, c, visit);
}

void solve(){
    ll n, k; cin>>n>>k;
    vl p(n); for(auto &e: p) cin>>e, e--;
    vl c(n); for(auto &e: c) cin>>e;
    vb visit(n, false);
    for(int i = 0; i<n; i++){
        if(!visit[i])
            vects.pb(vl()), dfs(i, p, c, visit);
    }

    ll ans = -2e18;
    for(auto &v: vects){
        ll univ = 0, cntr = 0;
        for(auto &e: v) univ += e;

        for(ll i = 0; i<sz(v); i++){
            ll curr = 0;
            for(ll j = 0; j<min(k, sz(v)); j++)
                curr += v[(i+j)%sz(v)], ans = max({ans, ((k-j-1)/sz(v))*univ + curr, curr});
        }
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen(".inp.txt", "r", stdin);
        freopen(".out.txt", "w", stdout);
        freopen(".err.txt", "w", stderr);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  if((a>=b&&b>=c)||(a>=c&&c>=b)){
    cout<<b+c<<endl;
  }
  
  else if((b>=a&&a>=c)||(b>=c&&c>=a)){
    cout<<a+c<<endl;
  }
  
    else if((c>=a&&a>=b)||(c>=b&&b>=a)){
      cout<<a+b<<endl;
    }
  
  return 0;
}
  
  

Measured memory_bytes: 256
import numpy as np


def foo(x, y):
    return y * (y + 1) // 2 + x * (x - 1) // 2

S = input().strip()
if S[0] == '>':
    S = '<' + S
if S[-1] == '<':
    S = S + '>'

s = [S[0]]
n = [0]
for si in S:
    if si == s[-1]:
        n[-1] += 1
    else:
        s.append(si)
        n.append(1)

n1, n2 = np.sort(np.array(n).reshape((-1, 2)), axis=-1).T
print(np.sum(foo(n1, n2)))



Measured memory_bytes: 21616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector <ll> X={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    K--;
    cout << X[K] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1001;

int m,n,f[N][N];
char c[N][N];

int main() 
{
  scanf ("%d%d", &m,&n);
  for (int i=1; i<=m; i++) 
  {
    scanf (" %s", c[i] + 1);
  }
  f[1][0] = 1;
  for (int i=1; i<=m; i++) 
  for (int j=1; j<=n; j++) 
    if (c[i][j] == '.') 
      f[i][j] = (f[i][j-1] + f[i-1][j]) % 1000000007;
  cout << f[m][n];
  return 0;
}


Measured memory_bytes: 5120
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] b = new int[n - 1];
            for (int i = 0; i < n - 1; i++)
                b[i] = in.nextInt();
            int[] a = new int[n];
            a[0] = b[0];
            for (int i = 1; i < n - 1; i++) {
                a[i] = Math.min(b[i - 1], b[i]);
            }
            a[n - 1] = b[n - 2];
            int ans = 0;
            for (int el : a)
                ans += el;
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h> 
using namespace std;
#define     mod             1e9+7
#define     ll              long long int 
#define     mp              make_pair
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     ii              pair<int,int>
#define     vi              vector<int>
#define     vvi				vector<vector<int>>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int>>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            '\n'


void solve(){

	ll n,d;
	ll r = 0;
	cin>>n>>d;
	while(n--){
		ll x,y;
		cin>>x>>y;
		ll curr = x*x + y*y;
		ll ans = ceil(sqrt(curr));
		if(ans <= d) 
			r++;
	}
	cout<<r;

}
 
int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif

    IOS;
    int t = 1;

    solve();
    // t(){
    // 	cout<<"Case #"<<t<<": ";
    // 	solve();
    // 	t++;
    // }


}








Measured memory_bytes: 3760
#include <stdio.h>
void matrix(void);

int P[100],q,m[100][100],n;

int main(){
  int i;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&P[i]);
    scanf("%d",&P[i+1]);
  }
  
  matrix();

  printf("%d\n",m[1][n]);
  
 return 0;

}

void matrix(){
  int i,l,j,k;
  
 
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=20000000;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+P[i-1]*P[k]*P[j];
	if(m[i][j]>q)
	  m[i][j]=q;

      }
    }
  }
 
}

Measured memory_bytes: 636
#https://img.atcoder.jp/agc016/editorial.pdf
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  ans = 'Yes'
  alone = 0
  group = 0
  ha = max(a)
  la = min(a)
  if ha - la >= 2: ans = 'No'
  
  elif ha - la == 1:
   for i in a:
     if i == ha-1 : alone += 1
     else: group += 1
   if alone < ha and 2*(ha-alone)<= group: pass
   else: ans = 'No'
  
  
  elif ha - la == 0:
    if a[0] == n-1 or 2*a[0] <= n:
      pass
    else: ans = 'No'
  return ans

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

Measured memory_bytes: 13964
// 参考: http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

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

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            int num = i * M - j * i + j * (N - i);
            if (num == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,n,j,c=0;
  static int k=0;
  scanf("%d",&n);
  for(i=1;i<=n;i=i+2){
    for(j=1;j<=i;j++){
      if(i%j==0) c++;
    }if(c==8) k++;
    c=0;
  }
  printf("%d",k);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

char getchar(int z){
  if(z==0) return 'z';
  else return "abcdefghijklmnopqrstuvwxy"[z-1];
}
int main(){
  ll n; cin >>n;
  vector<char>v(11); int cnt=10;
  while(n){
    v[cnt]=getchar(n%26);
    if(n%26) n/=26;
    else{n/=26; n--;}
    cnt--;
  }
  for(int i=cnt+1; i<11; i++) cout <<v[i];
return 0;}

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

int partition(int *,int);
void swapping(int *,int *,int *);

int main(){
  int *A,n,i,box;

  scanf("%d",&n);
  A = (int *)malloc(1 + n * sizeof(int));
  for(i = 1;i < n + 1;i++) scanf("%d",&A[i]);

  box = partition(A,n);


  for(i = 1;i < box;i++) printf("%d ",A[i]);
  printf("[%d] ",A[box]);
  for(i = box + 1;i < n + 1;i++){
    printf("%d",A[i]);
    if(i != n) printf(" ");
  }
  printf("\n");
  
  free(A);
  return 0;
}

int partition(int *A,int n){
  int x,i,j,hako = 0;
  x = A[n];
  i = -1;
  for(j = 0;j < n;j++){
    if(A[j] <= x){
      i += 1;
      swapping(&A[i],&A[j],&hako);
    }
  }
  swapping(&A[i + 1],&A[n],&hako);
  
  return i + 1;
}

void swapping(int *A,int *AA,int *dust){
  *dust = *A;
  *A = *AA;
  *AA = *dust;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();// 箱の数
		int x = sc.nextInt();// 飴の合計の最大値
		int a[] = new int[N];
		long result = 0;

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < N-1; i++) {
			int s = a[i] + a[i + 1] - x;// 飴の合計値-最大値(ｘ)=最大値をオーバーした数値ｓ

			if (s > 0 && a[i] + a[i + 1] > x) {// 飴の合計がオーバーした場合
				if (a[i + 1] >= s) {// オーバーした数値が右隣の値の方が大きい場合
					a[i + 1] = a[i + 1] - s;// 右隣の飴をｓ個食べる
				} else {
					a[i] = a[i] - (s - a[+1]);// 参照-（オーバー値-右隣）
					a[i + 1] = 0;// 右隣を0にする
				}
				result += s;// 飴を食べるカウント
			}
		}
		System.out.println(result);// 飴を食べた個数のトータル
	}

}

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif



int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> path(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    vector<int> prv(n, -1);
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (auto& w : path[v]) {
            if (prv[w] == -1) {
                prv[w] = v;
                q.push(w);
            }
        }
    }
    for (auto v : prv) {
        if (v == -1) {
            puts("No");
            return 0;
        }
    }
    cout << "Yes" << '\n';
    for (int i = 1; i < n; i++) {
        cout << prv[i] + 1 << '\n';        
    }
}


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

n,m= map(int, input().split())
a= [list(map(int, input().split())) for i in range(m)]
b = [[] for i in range(n)]

for x,y in a:
    b[x-1].append(y-1)
    b[y-1].append(x-1)


import collections
from collections import deque
def tree(s):

    INF=-10**9
    dis = [INF for i in range(n)]
    dis[s]=0
    ans=[0]*n
    def bfs():
        d = deque()
        d.append(s)

        while len(d):
            x = d.popleft()

            for i in range(len(b[x])):
                y=b[x][i]
                if dis[y] == INF:
                    d.append(y)
                    dis[y]=dis[x]+1
                    ans[y]=x+1


        return ans
    return bfs()

x=tree(0)

for i in range(1,n):
    if x[i]==0:
        print('No')
        exit()

print('Yes')
for i in range(1,n):
    print(x[i])

Measured memory_bytes: 125148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_GrandContest_032
{
    class Program
    {

        public const int MOD = 1000000000 + 7;

        static void Main(string[] args)
        {

            int cnt = int.Parse(Console.ReadLine());
            int[] numArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
          
            List<int> numList = new List<int>();
            for(int i = cnt - 1; 0 <= i; i--)
            {
                numList.Add(numArr[i]);
            }

            Stack<int> retStack = new Stack<int>();
            int idx = 0;
            while (idx < numList.Count)
            {
                if (numList.Count - idx == numList[idx])
                {
                    retStack.Push(numList[idx]);
                    numList.RemoveAt(idx);
                    idx = 0;
                }
                else
                {
                    idx++;
                }
            }

            if (cnt == retStack.Count)
            {
                for (int i = 0; i < cnt; i++)
                {
                    Console.WriteLine(retStack.Pop());
                }
            }
            else
            {
                Console.WriteLine(-1);
            }
        }

    }
}



Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

int main() {

	int L;
	cin >> L;

	double ans = double(L * L * L) / 27.0;

	cout << fixed;
	cout << setprecision(8) << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

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

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll n,h;
pair<ll,ll> p[100005] = {};

int main(){

    cin >> n >> h;
    ll b = 0,a = 0;
    vector<ll> v;
    
	rep(i,0,n){
	    cin >> p[i].ft >> p[i].sd;
	    a = max(a,p[i].ft);
	}
	rep(i,0,n){
        if(a < p[i].sd){
            b+=p[i].sd;
            v.pb(p[i].sd);
        }
	}
    
    ll nh = h-b,ans = 0;
    if(nh > 0){
        ans = (nh+a-1)/a;
        ans += sz(v);	
    }else{
        
        vsort(v);
        int i = sz(v)-1;
        while(h > 0){
            h -= v[i];
            ans++;
            i--;
        }
    }
    
	P(ans);
	
	
	return  0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;

int main(){
   int d, n;
   cin >> d >> n;
   int cnt = 0;
   for(int i = 1; ; i++){
      
       	int temp = 0, foo = i;
       	while(foo > 0){
       	 	if(foo%100 == 0)foo /= 100;
       	 	else break;
       	 	temp++;
       	}
       	if(temp == d)cnt++;
         if(cnt == n){
          	cout << i << endl; return 0;
         }
   }	   
	return 0;
}                  


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


int main() {
int N=0;

cin >> N;
vector<string> S(N);
for(int i=0;i<N;i++){
    
    cin >> S[i];

}
sort(S.begin(),S.end());
S.erase(unique(S.begin(),S.end()),S.end());
cout <<S.size()<<endl;

}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
  string s;
  getline(cin, s);
  for (int i = 0; s[i]; ++i){
    if(s[i]==',')  s[i] = ' ';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int w,a1,b1;
  	cin>>w>>a1>>b1;
  	
    	
  //すでに連結状態の場合
  	if(abs(a1-b1)<=w){
    	cout<<0<<endl;
      	return 0;
    }
  
  //連結状態ではない場合
  	cout<<abs(a1-b1)-w<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <list>
#include <vector>

using namespace std;

#define MIN(x, y) x<y?x:y

int main()
{
	int n, m;
	int a;
	int total = 0;

	priority_queue<int> pq;

	cin>>n>>m;

	for(int i=0 ; i<n ; i++) {
		cin>>a;
		total += a;
		pq.push(a);
	}

	for(int i=0 ; i<m-1 ; i++) {
		pq.pop();
	}

//	cout<<pq.top()<<endl;

	total += 4*m -1;

	if(pq.top() < total / (4*m)) {
		cout<<"No"<<endl;
	} else {
		cout<<"Yes"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,n,counter=0;
  cin>>N;
  vector<int>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<N;i++){
    if(i==0){
      if(vec.at(i)==2)
        break;
      n=vec.at(i);
      counter++;
    }
    else if(i<N-1){
      if(vec.at(n-1)==2){
        break;
      }
      else{
        n=vec.at(n-1);
        counter++;
      }
    }
    else if(i==N-1)
      counter = -2;
  }
  cout<<counter+1<<endl;
}

Measured memory_bytes: 3736
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

const int N = 1e4 + 5;
const int MOD = 1e9 + 7;

int dp[N][105][2];
// dp[i][j][k] means the count of numbers which at pos i, 
// with sum of each digit modulo D equals to j
// if k == 1, then it hasn't chosen any digit that is smaller than k
// how to ensure all numbers in result is smaller than K?
char K[N];
int d;

void add(int& a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

int sub(int a, int b) {
    int res = a - b;
    if (res < 0) res += MOD;
    return res;
}

void solve() {
    if (K[0] == '1' && K[1] == 0 && d == 1) {
        printf("1\n");
        return;
    }
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < K[0] - '0'; ++i) dp[0][i][0] = 1;
    dp[0][K[0] - '0'][1] = 1;
    int len = strlen(K);
    for (int i = 1; i < len; ++i) {
        for (int j = 0; j < max(d, 10); ++j) {
            for (int k = 0; k < 10; ++k) {
                int new_sum = (j + k) % d;
                add(dp[i][new_sum][0], dp[i - 1][j][0]);
                if (k < K[i] - '0') add(dp[i][new_sum][0], dp[i - 1][j][1]);
                if (k == K[i] - '0') add(dp[i][new_sum][1], dp[i - 1][j][1]);
            }
        }
    }
    printf("%d\n", sub((dp[len - 1][0][0] + dp[len - 1][0][1]) % MOD, 1));
}

void debug() {
    for (int i = 0; K[i]; ++i, putchar('\n')) {
        for (int j = 0; j <= d; ++j) {
            printf("%10d %10d ", dp[i][j][0], dp[i][j][1]);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    while (~scanf("%s%d", K, &d)) {
        solve();
        // debug();
    }
    return 0;
}

Measured memory_bytes: 8448
import numpy as np
from numba import njit

N=int(input())
a=[int(i) for i in input().split()]
x,y,z=0,0,0
for i in a:
    if i==1:
        x+=1
    elif i==2:
        y+=1
    elif i==3:
        z+=1


dp=np.full((N+1,N+1,N+1),-1,dtype=np.float64)

dp[0][0][0]=0

@njit('f8(i8,i8,i8,i8,f8[:,:,:])', cache=True)
def calc(h,i,j,N,dp):
    if h+i+j==0:
        return 0
    if dp[h][i][j]>=0:
        return dp[h][i][j]
    A=1
    if h>=1:
        A+=calc(h-1,i,j,N,dp)*h/N
    if i>=1:
        A+=calc(h+1,i-1,j,N,dp)*i/N
    if j>=1:
        A+=calc(h,i+1,j-1,N,dp)*j/N
    A=A*N/(h+i+j)
    dp[h][i][j]=A
    return A

a=calc(x,y,z,N,dp)

print(dp[x][y][z])

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

int main(void){
  int n,f;
  
  scanf("%d", &n);
  printf("%d:", n);
  while (n%2==0) {
    printf(" 2");
    n/=2;
  }
  f = 3;
  while (f*f<=n){
    while (n%f==0){
      printf(" %d", f);
      n /= f;
    }
    f+=2;
  }
  if (n>=2) printf(" %d", n);
  puts("");
  return 0;
}


Measured memory_bytes: 3220
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)

#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#include<vector>
#define elif else if
typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 200005
int N;

int main(){
    string S;
    ll K;
    cin>>S>>K;
    int len = S.size();
    rep(i,len){
        if(i<K-1){
            if(S[i] != '1'){
                cout<<S[i]<<endl;
                return 0;
            }
        }else if(i==K-1){            
            cout<<S[i]<<endl;
            return 0;
            
        }
    }
    return 0;
}

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

ans=[]
ans1=[]

for _ in range(n):
  a,b=map(int,input().split())
  d=a-b
  c=a+b
  ans.append(c)
  ans1.append(d)
  
m=min(ans)
M=max(ans)

P=M-m
Q=max(ans1)-min(ans1)

print(max(P,Q))

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

    int ans;
    if (N%2==0) ans=N/2;
    else ans=N/2+1;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n; cin >> n;
	vector<ll> pos;
	vector<ll> neg;
	rep(i,0,n){
		ll x, y; cin >> x >> y;
		pos.push_back(x + y);
		neg.push_back(x - y);
	}
	sort(all(pos));
	sort(all(neg));
	ll posans = pos[0] - pos[n - 1];
	ll negans = neg[0] - neg[n - 1];
	ll ans = max(abs(posans), abs(negans));
	cout << ans << endl;
}

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

int main() {
  vector<int>data(9);
  for(int i = 0;i < 9;i++){
    cin >> data.at(i);
  }
  int d1,d2,d3;
  d1 = data.at(0)+data.at(4)+data.at(8);
  d2 = data.at(1)+data.at(5)+data.at(6);
  d3 = data.at(2)+data.at(3)+data.at(7);
  if(d1 == d2 && d2 == d3){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;


bool dividable[1000001];


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

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    set<int> S;
    rep(i, N) {
        if (S.find(A[i]) == S.end()) {
            if (dividable[A[i]]) continue;
            for (int x = A[i]*2; x <= 1000000; x += A[i]) {
                dividable[x] = true;
            }
            S.insert(A[i]);
        } else {
            dividable[A[i]] = true;
        }
    }

    int ans = 0;
    rep(i, N) {
        if (!dividable[A[i]]) ++ans;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;



int main()
{

   string s;
   cin >> s;

   if(s[0]==s[1]){

        if(s[2]==s[3] && s[2]!= s[0]) cout << "Yes";
        else cout << "No";

   }
   else{
        if( s[2] == s[0] && s[3] == s[1] ) cout << "Yes";
        else if( s[2] == s[1] && s[3] == s[0] ) cout << "Yes";
        else cout << "No";


   }


    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;

int main() {
	unsigned int a, b, c, x, y, sum = 0;
	cin >> a >> b >> c >> x >> y;
	if ((a + b) / 2 >= c) {
		while (x > 0 && y > 0) {
			--x; --y; sum += 2 * c;
		}
	}
	while (x > 0) {
		if (a > c * 2) {
			--x; --y; sum += c * 2;
		}else{
			--x; sum += a;
		}
	}
	while (y > 0) {
		if (b > c * 2) {
			--x; --y; sum += c * 2;
		}
		else {
			--y; sum += b;
		}
	}
	cout << sum << endl;
	return 0;
}

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

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

  int sum = 0;
  int max_p = 0;
  rep(i, N) {
    int p;
    cin >> p;
    sum += p;
    max_p = max(max_p, p);
  }

  cout << sum - max_p / 2 << endl;
}

Measured memory_bytes: 256
def getWbStr(length, start):
    clr = ['0', '1']
    cstr = ''
    for i in range(0, length):
        cstr += '0' if i % 2 == start else '1'

    return cstr

s = input()

wstr = getWbStr(len(s), 0)
bstr = getWbStr(len(s), 1)
wcnt, bcnt = 0, 0

for i in range(0, len(s)):
    if s[i] != wstr[i]:
        wcnt += 1
    if s[i] != bstr[i]:
        bcnt += 1

print(min(wcnt, bcnt))


Measured memory_bytes: 3316
import os

def main():
	s = input()
	seikai = 0
	s = list(s)
	for i,v in enumerate(s):
		if i == 2 or i == 4:
			if s[i] == s[i+1]:
				seikai += 1
	
	if seikai == 2:
		print("Yes")
	else:
		print("No")
			

if __name__ == "__main__":
	main()


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

using namespace std;
using ll = long long;

int q;
ll sb = 0;

//heap max - min
ll sl, sr;
priority_queue<int, vector<int>> ql;
priority_queue<int, vector<int>, greater<int>> qr;

int main() {
  ios::sync_with_stdio(false);
  cin >> q;
  ql.push(INT_MIN);
  qr.push(INT_MAX);
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int a, b;
      cin >> a >> b;
      sb += b;
      if (a <= qr.top()) {
        ql.push(a);
        sl += a;
      } else {
        qr.push(a);
        sr += a;
      }
      while (ql.size() > qr.size() + 1) {
        qr.push(ql.top());
        sr += ql.top();
        sl -= ql.top();
        ql.pop();
      }
      while (ql.size() < qr.size()) {
        ql.push(qr.top());
        sl += qr.top();
        sr -= qr.top();
        qr.pop();
      }
    } else {
      ll x = ql.top();
      ll mv = x * (ql.size() - qr.size()) - sl + sr + sb;
      cout << x << " " << mv << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3452
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>
#include <string>
#include <time.h>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN 10000007
#define MOD 998244353
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v;
ll x1, p1, x2;
pii a[100500], b[100500];
ll c[100500];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].X;
        a[i].Y = i;
    }

    for (int i = 0; i < n; i++) {
        cin >> b[i].X;
        b[i].Y = i;
    }
    sort(a, a+n);
    sort(b, b+n);
    for (int i = 0; i < n; i++) {
        if (a[i].X > b[i].X) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 1; i < n; i++) {
        if (a[i].X <= b[i-1].X) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (int i = 0; i < n; i++) {
        c[a[i].Y] = b[i].Y;
    }
    ll x = 0;
    ll y = 0;
    do {
        x++;
        y = c[y];
    } while (y != 0);
    if (x == n) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }


    return 0;
}

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

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n, cnt = 0, x; cin >> n;
	unordered_map<int,int> f;
	for (int i = 0; i < n; i++) {
		cin >> x;
		f[x]++;
	}
	for (auto fi : f) {
		cnt += (fi.second - 1);
	}
	cnt = ((cnt + 1) / 2) * 2;
	cout << n - cnt << "\n";
	return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}



int main(){FIN
    vvll a(2,vll(105,-1));
    ll n=0;cin>>n;
    REP(i,2) REP(j,n) {cin>>a[i][j]; }

    ll ans = 0;
    REP(i,n){
        ll sm=0;
        REP(j,i+1) sm += a[0][j];
        // cout<<sm<<endl;
        REP(j,n-i) sm += a[1][j+i];
        ans = max(ans,sm);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

//next_permutation
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> A(m),B(m);
  rep(i,m)cin >> A.at(i) >> B.at(i);
  vector<set<int>> AL(n);
  rep(i,m){
    AL.at(A.at(i)-1).insert(B.at(i));
    AL.at(B.at(i)-1).insert(A.at(i));
  }

  vector<int> v(n);
  int ans = 0;
  rep(i,n)v.at(i)=i;//z_index
  do{
    if(v.at(0)!=0)break;
    int flag = 0;
    for(int i = 0; i < n-1; i++){
      if(!AL.at(v.at(i)).count(v.at(i+1)+1))flag=1;
    }
    if(flag)continue;
    else ans++;
  }while(next_permutation(v.begin(),v.end()));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
main(){
  int n,i,a,b,c;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a >> b >> c;
    if(a*a+b*b==c*c){
      cout << "YES" << endl;
    }
    else if(a*a+c*c==b*b){
      cout << "YES" << endl;
    }
    else if(b*b+c*c==a*a){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define add push_back
#define endl "\n"
const double PI = acos(-1);
using ll = long long;
using namespace std;

int n, a[21], b[21], c[21];
int main() {
    IOS
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    for (int i = 1; i < n; ++i) {
        cin >> c[i];
    }
    int sm = 0, lst = 0;
    for (int i = 1; i <= n; ++i) {
        sm += b[a[i]];
        if (a[i] == lst+1) {
            sm += c[lst];
        }
        lst = a[i];
    }
    cout << sm << endl;
    return 0;
}





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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    for(int i=0; i<n-1; i++)
    {
        if(arr[i] == arr[i+1])
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        if (k <= a) {
            result = k;
        } else if (k <= a + b) {
            result = a;
        } else {
            result = a - (k - (a + b));
        }

        // 出力
        System.out.println(result);
    }
}


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


int main() {
  int n;
  cin >> n;
  int m[n][n];
  rep(i, n){
    rep(j,n){
      m[i][j] = 0;
    }
  }
  rep(i,n){
    int u, k;
    cin >> u >> k;
    u--;
    rep(j,k){
      int v;
      cin >> v;
      v--;
      m[u][v] = 1;
    }
  }
  rep(i,n){
    rep(j,n){
      cout << m[i][j] << (j == n - 1 ? "\n" : " ");
    }
  }
}


Measured memory_bytes: 3112
n=int(input())
li=[None]*n
for i in range(0,n):
    flag=True
    x,l=map(int, input().split())
    li[i]=(x+l, x-l)
li=sorted(li)
count=1
x,y=li[0]
for i in range(1,n):
    x2,y2=li[i]
    if y2 < x:
        continue
    count=count+1
    x=x2
print(count)


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

const long INF = 1L << 60;

int main(){
	long a, b, n;
	scanf("%ld%ld%ld", &a, &b, &n);
	if(b - 1 >= n)
		printf("%ld\n", (long)(floor(a * n / b) - a * floor(n / b)));
	else
		printf("%ld\n", (long)(floor(a * (b - 1) / b) - a * floor((b - 1) / b)));
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#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++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;


int main(){
    int n, m, si, ci;
    cin >> n >> m;

    vector<int> res(n, 0);
    REP(i, m){
        cin >> si >> ci;
        if (res[si-1] != 0 && res[si-1] != ci){
            cout << "-1" << endl;
            return 0;
        }
        if (ci == 0 && si == 1 && n != 1){
            cout << "-1" << endl;
            return 0;
        }
        res[si-1] = ci;
    }

    REP(j, n){
        if (j == 0 && res[j] ==0 && n != 1) cout << 1;
        else cout << res[j];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

int main(){

	int x, y;


	std::cin >> x >> y;

	std::cout << gcd(x, y) << std::endl;
	

	return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
//	string str=lcs(s,t,"");
//	cout<<str<<"\n";
  int m=s.size(),n=t.size();
	vector<vector<int> >dp(m+1,vector<int>(n+1,0));
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(s[i-1]==t[j-1])
			   dp[i][j]=dp[i-1][j-1]+1;
			else
			{
				if(dp[i-1][j]>=dp[i][j-1])
				   dp[i][j]=dp[i-1][j];
				else
				   dp[i][j]=dp[i][j-1];
				  
			}
		}
	}
  int index=dp[m][n];
  string x="";
  int i=m,j=n;
  while(i>0 && j>0)
  {
    if(s[i-1]==t[j-1]){
      x=s[i-1]+x;
      i--;
      j--;
    }
    else if(dp[i-1][j]>dp[i][j-1])
      i--;
    else
      j--;
  }
	cout<<x<<"\n";
	
}


Measured memory_bytes: 35584
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    int n; cin >> n;

    ll d[n];
    rep(i, n){
        cin >> d[i];
    }

    ll ans = 0;
    rep(i, n){
        reps(j, i+1, n){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    regex re("A[a-z]+C[a-z]+");
    string s;
    cin >> s;
    if (regex_match(s, re)) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    return 0;
}



Measured memory_bytes: 256