akhauriyash/Code-Regression huggingface dataset:
//g++ -std=c++14 test.cpp -o test.out

//参考：
//https://www.youtube.com/watch?v=WpUkC4-hyLE

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;

LL ans = 0;

void solve(){
	int N = S.size();
	int left,right;
	if(N%2==0){
		ans = N/2;
		left = N/2 - 1;
		right = N/2;
		while(right<N){
			if(S[left]==S[right]){
				left--;
				right++;
				ans = right;
			}else{
				return;
			}
		}
	}else{
		left = N/2;
		right = left;
		if(S[left]!=S[left+1]){
			ans = N/2 + 1;
			return;
		}
		while(right<N){
			//cout << left << " " << right << endl;
			if(S[left]==S[right]){
				left--;
				right++;
				ans = right;
			}else{
				return;
			}
		}
	}
}

int main(){
    cin >> S;

    solve();

	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
 
 
public class Main{
 public static void  main(String[] args)throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
                     
                    while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } 
 }
}

Measured memory_bytes: 25008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main{
	static int n;
	static HashSet<Integer> S = new HashSet<Integer>();;
	static int q;
	static int t;
	static int count;

	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		String [] temp = br.readLine().split(" ");
		for(int i=0;i < n;i++){
			S.add(Integer.parseInt(temp[i]));
		}

		q =Integer.parseInt(br.readLine());
		temp = br.readLine().split(" ");

		for(int i = 0;i < q;i++){
			t = Integer.parseInt(temp[i]);
			search(t);
		}

		System.out.println(count);

	}

	public static void search(int num){
		if(S.contains(num)){
			count++;
			return;
		}
	}

}

Measured memory_bytes: 28352
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x) = parse(Int, x)
pM(x::Array{SubString{String},1}) = map(pI, x)
function main()
  a,b,n=pM(split(readline()))
  ans=min(b-1,n)
  print(fld(a*ans,b))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 161492
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+9;
const double ep=1e-7;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double pi=acos(-1);
#define debug1 puts("?");
#define debug(x) cout<<"##"<<(x)<<endl;
#define mk make_pair
#define PII pair<int,int>
#define PIII pair<PII,int>
#define PIL pair<int,ll>
#define PLL pair<ll,ll>
#define eb emplace_back
#define fi first
#define se second
#define rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
typedef long long ll;
int n,m;
int pre[maxn],be[maxn],res;
int Find(int x)
{
	return x==pre[x]?x:pre[x]=Find(pre[x]);
}
void mix(int x,int y)
{
	int fx=Find(x),fy=Find(y);
	if(fx!=fy)pre[fx]=fy;
}
void solve()
{
	sdd(n,m);
	rep(i,1,n)pre[i]=i;
	rep(i,1,m)
	{
		int a,b;
		sdd(a,b);
		mix(a,b);
	}
	rep(i,1,n)
	{
		int x=Find(i);
		be[x]++;
		res=max(res,be[x]);
	}
	pd(res);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
//	sd(T);
	while(T--)solve();
} 

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

int main() {
    string n;
    int t;
    long long sum = 0;
    cin >> n;
    for(int i = 0; i < (int)(n.length()); ++i){
        t = n[i] - '0';
        sum += t;
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3748
#include"bits/stdc++.h"
#define int long long
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

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

signed main(){
    int n,s;
    cin>>n>>s;
    if(n==s){
    	cout<<n+1<<endl;
    	return 0;
    }
    rep(i,(int)sqrt(n)) if(digitsum(n,i+2)==s){
    	cout<<i+2<<endl;
    	return 0;
    }
    for(int i=(int)sqrt(n)+1;i>0;--i){
    	int b=(n-s)/i+1;
    	if(digitsum(n,b)==s){
    		cout<<b<<endl;
    		return 0;
    	}
    }
    cout<<-1<<endl;
    return 0;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

if h % 3 == 0 || w % 3 == 0
    puts 0
else
    ans = [h, w]

    calc = ->(h, w, x) {
        a, b = [h * x, h / 2 * (w - x), (h + 1) / 2 * (w - x)].minmax
        b - a
    }

    ans << calc.(h, w, w/3)
    ans << calc.(h, w, w/3+1)
    ans << calc.(w, h, h/3)
    ans << calc.(w, h, h/3+1)

    puts ans.min
end

Measured memory_bytes: 14364
use proconio::input;

macro_rules! chmax {
    ($max_v: expr, $v: expr) => {
        if $v > $max_v {
            $max_v = $v;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize,
        w: usize,
        wv: [(usize, usize); n],
    };
    let mut dp = vec![vec![0; w + 1]; n + 1];
    for (i, &(w_i, v_i)) in wv.iter().enumerate() {
        for j in 0..w {
            chmax!(dp[i + 1][j], dp[i][j]);
            if j + 1 <= w {
                chmax!(dp[i + 1][j + 1], dp[i][j]);
            }
            if j + w_i <= w {
                chmax!(dp[i + 1][j + w_i], dp[i][j] + v_i);
            }
        }
    }
    let ans = dp[n][w];
    println!("{}", ans);
}


Measured memory_bytes: 81224
#include <bits/stdc++.h>
using namespace std;
int main(){
    double a, b, c;
    double pi = 3.14159265;
    cin >> a >> b >> c;
    double S, L, h;
    c = c * pi / 180; // ラジアン化
    S = a * b * sin(c) / 2;
    L = sqrt(a*a + b*b - 2*a*b*cos(c)) + a + b;
    h = 2*S / a;
    
    cout << fixed << setprecision(7) << S << endl;
    cout << fixed << setprecision(7) << L << endl;
    cout << fixed << setprecision(7) << h << endl;
    return 0;

}


Measured memory_bytes: 3516
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long S = sc.nextLong();
		long c = sc.nextLong();
		long ans = 0;
		if( S>=c/2 ){
			ans = c/2;
		}else{
			ans = S + (c/2-S)/2;
		}
		System.out.println(ans);
	}
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    int N = S.length();
    stack<char> stk;
    rep(i, S.length()){
        if(S[i] == 'S') stk.push(S[i]);
        else{
            if(!stk.empty() && stk.top() == 'S') stk.pop();
            else stk.push(S[i]);
        }
    }
    cout << stk.size() << endl;
    return 0;
}

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

int main() {
    string s; cin>>s;
    int a=0,b=0,c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='a')a++;
        else if(s[i]=='b')b++;
        else c++;
    }
    if(abs(a-b)<=1 && abs(a-c)<=1 && abs(b-c)<=1) cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 512
n = int(input())
fs = [list(map(int, input().split())) for _ in range(n)]
ps = [list(map(int, input().split())) for _ in range(n)]

anss = []
for i in range(1, 2**10):
  l = [0]*n
  for j in range(10):
    if  (i >> j) & 1:
      for k in range(n):
        l[k] += fs[k][j]
  ans = 0
  for m in range(n):
    ans += ps[m][l[m]]
  anss.append(ans)
  
anss.sort(reverse=True)
print(anss[0])


Measured memory_bytes: 3064
#include<stdio.h>
#define N 100
#define MAX 1000000
#define NIL -1

int isEmpty(void);
void enqueue(int);
int dequeue(void);
int dijkstra(int);

int n;
int A[N][N],pi[N],c[N],d[N];
int Q[N];
int head=0,tail=0;

int main(){
  int i,j;
  int u,v,k,c;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=MAX;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      A[u][v]=c;
    }
  }
  dijkstra(0); 
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}

int isEmpty(){
  if(head==tail) return 1;
  return 0;
}

void enqueue(int n){
  
  Q[tail]=n;
  if(tail+1==N){
    tail=0;
  }
  else{
    tail++;
  }
}

int dequeue(){

  int n;

  n=Q[head];
  if(head+1==N){
    head=0;
  }
  else{
    head++;
  }
  return n;
}

dijkstra(int s){
  int i;
  int min;
  int u,v;
  //初期化
  for(i=0;i<n;i++){
    d[i]=MAX;
    c[i]=0;
    pi[i]=NIL;
  }
  d[s]=0;
  //計算
  while(1){
    min=MAX;
    for(i=0;i<n;i++){
      if(c[i]!=2 && d[i]<min){
	min=d[i];
	u=i;
      }
    }
    if(min==MAX) break;
    c[u]=2;
    for(v=0;v<n;v++){
      if(A[u][v]>=1){
	if(c[v]!=2 && d[u]+A[u][v]<d[v]){
	  pi[v]=u;
	  d[v]=d[u]+A[u][v];
	}
      }
    }
  }
}



Measured memory_bytes: 2024
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int parent[30][100005];//parent[i][j]:jの2^i親の場所
int d[100005],depth[100005];//根からの距離,根からの深さ
int lca(int u,int v){//共通の直近の親を伝える
  if(depth[u]>depth[v])swap(u,v);
  int U=u,V=v;
  int diff=depth[v]-depth[u];
  int cnt=0;
  while(diff){
    if(diff&1)v=parent[cnt][v];
    cnt++;
    diff>>=1;
  }
  if(u==v)return u;
  int high=25,low=-1;
  for(int k=25;k>=0;k--)if(parent[k][u]!=parent[k][v])u=parent[k][u],v=parent[k][v];
  return parent[0][u];
}
//main
signed main(){
  int N,Q;cin>>N>>Q;
  typedef pair<int,int> P;
  typedef pair<int,P> PP;
  std::vector<PP> edge[N];//行き先、色、長さ
  for(int i=1;i<N;i++){
    int u,v,c,d;cin>>u>>v>>c>>d;u--;v--;
    edge[u].push_back(PP(v,P(c,d)));
    edge[v].push_back(PP(u,P(c,d)));
  }
  //ここからdを作る
  std::vector<PP> ed[N],ged[N];//根付き木として見た時に下に降りる辺と上に上がる辺に分ける
  queue<int> que;
  std::vector<int> used(N,0);
  que.push(0);d[0]=0;depth[0]=0;
  while(que.size()){
    int p=que.front();que.pop();
    if(used[p])continue;used[p]++;
    for(auto q:edge[p]){
      int u=q.first,c=q.second.first,l=q.second.second;
      if(used[u])ged[p].push_back(PP(u,P(-c,-l)));
      else{
        ed[p].push_back(q);
        d[u]=d[p]+l;
        que.push(u);
        depth[u]=depth[p]+1;
      }
    }
  }
  //ここまでdを作った
  //ここからparentを作る
  memset(parent,-1,sizeof(parent));
  for(int i=0;i<N;i++)for(auto q:ged[i])parent[0][i]=q.first;
  for(int i=1;i<30;i++)
    for(int j=0;j<N;j++)
      if(parent[i-1][j]>=0)parent[i][j]=parent[i-1][parent[i-1][j]];
  //ここまでparentを作った
  std::vector<int> qu[N],x(Q),y(Q),u(Q),v(Q);
  for(int i=0;i<Q;i++){
    cin>>x[i]>>y[i]>>u[i]>>v[i];u[i]--;v[i]--;
    qu[u[i]].push_back(x[i]);
    qu[v[i]].push_back(x[i]);
    qu[lca(u[i],v[i])].push_back(x[i]);
  }
  std::vector<int> cnum(N,0),clong(N,0);//色iの今の個数と距離の合計
  stack<PP> sta;
  map<P,P> ma;//ma[P(i,j)]:頂点iの色jの個数と距離
  sta.push(PP(0,P(0,-1)));
  fill(used.begin(),used.end(),0);
  while(sta.size()){
    PP statop=sta.top();sta.pop();
    int p=statop.first,colo=statop.second.first,lon=statop.second.second;
    if(colo){
      if(colo>0)cnum[colo]++;
      else cnum[-colo]--;
      clong[abs(colo)]+=lon;
    }
    if(used[p]==0){
      for(auto qco:qu[p])ma[P(p,qco)]=P(cnum[qco],clong[qco]);//初めて来たならmapに書き込み
      for(auto rev:ged[p])sta.push(rev);//初めて来たなら辺を張る
      for(auto nonrev:ed[p])sta.push(nonrev);
    }
    used[p]++;
  }
  for(int i=0;i<Q;i++){
    int du=d[u[i]]-ma[P(u[i],x[i])].second+ma[P(u[i],x[i])].first*y[i];
    int dv=d[v[i]]-ma[P(v[i],x[i])].second+ma[P(v[i],x[i])].first*y[i];
    int w=lca(u[i],v[i]);
    int dw=d[w]-ma[P(w,x[i])].second+ma[P(w,x[i])].first*y[i];
    cout<<du+dv-2*dw<<endl;
  }
}

/*
解説AC
LCA、クエリ先読み、dfsをうまくやると根付き木を降りて登ってがやりやすいなどいろんな知識を学べる問題だった
LCAの実装は空でかけるようになったかな？
クエリ先読みにももう一つやり方があるみたいだし公式はそもそも先読みすらしてないっぽい？
いろんな提出をしてみたいね
*/

Measured memory_bytes: 75384
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
int N;
int datas[1145141]={0};
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int M;
int main(){
	cin>>M;
	ll ans=0;
	ll now=0;
	rep(i,M){
		ll d,c;
		cin>>d>>c;
		int hosei=1;
		if(d==0)hosei=0;
		ans+=(c*d-hosei)/9 + c - 1;
		ll res=(c*d)%9;
		if(res==0&&d!=0)res=9;
		if(now!=0){
			ans++;
			if(now+res>=10)ans++;
		}
		now+=res;
		now%=9;
		if(now==0)now=9;

	}
	cout<<ans<<endl;
}





Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
s = sum(A)
def md(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
P = md(s)
def test(x):
  L = sorted([a%x for a in A])
  M = sum(L)
  c = M//x
  for _ in range(c):
    M -= L.pop()
  return M <= k

for p in P:
  if test(p):
    print(p)
    break

Measured memory_bytes: 3192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    V<ll> x(2), y(2);
    rep(i, 2) cin >> x[i];
    rep(i, 2) cin >> y[i];
    ll ans = -3e18;
    rep(i, 2) {
        rep(j, 2) {
            chmax(ans, x[i]*y[j]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    string S;
    cin>>S;
    rep(i, S.size()){
        S[i]='x';
    }
    cout<<S<<endl;
    return 0;
}


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

using namespace std;

int main(){
  int N,A,B,C,D;
  cin>>N;
  int t=N*(N-1)/2;
  vector<int> TP(N);

  for(int i=0;i<t;i++){
    cin>>A>>B>>C>>D;
    if(C>D){
      TP[A-1]+=3;
    }
    else if(C<D){
      TP[B-1]+=3;
    }
    else if (C==D){
      TP[A-1]++;
      TP[B-1]++;
    }
  }

  for(int i=0;i<N;i++){
    int g=1;
    for(int j=0;j<N;j++){
      if(TP[j]>TP[i])
        g++;
    }
    cout<<g<<endl;
  }
  
}



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

int main() {
  int n,m;
  double x=0;
  cin >> n >> m;
  vector<int> vec(n);
  for (int i=0;i<n;i++) {
    cin >> vec.at(i);
    x+=vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  bool y=true;
  for (int i=0; i<m; i++) {
    if (x/(4*m)>vec.at(i)) {
      y=false;
      break;
    }
  }
  if (y) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
const int maxn = 2e5+5;
int a[maxn];
int b[maxn]; 
int main(){
	cin >> n ;
	for (int i=2;i<=n;i++){
		cin >> a[i];
		b[a[i]]++;
	}
	for (int i=1;i<=n;i++) cout << b[i] << endl;
	return 0;
}

Measured memory_bytes: 5112
import javax.print.attribute.SupportedValuesAttribute;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.function.Predicate;

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);
        TaskB solver = new TaskB();
        solver.solve(in, out);
        out.close();
    }

    static class TaskB {


        public static int binarySearch(int arr[], int low, int high, int key)
        {
            int mid = (low + high)/2;
            while( low <= high )
            {
                if ( arr[mid] < key )
                {
                    low = mid + 1;
                }
                else if ( arr[mid] == key )
                {
                    return mid;
                }else
                {
                    high = mid - 1;
                }
                mid = (low + high)/2;
            }
            if( low > high )
            {
                return -1;
            }
            return -1;
        }

        public static int[][] maxPos;

        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if(n>=30)out.println("Yes");
            else out.print("No");
        }
    }


    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public InputReader(InputStream inputStream) {
            this.reader = new BufferedReader(
                    new InputStreamReader(inputStream));
        }

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

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

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

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

    }
}

Measured memory_bytes: 32600
from sys import setrecursionlimit

def find(parent, i):
   t = parent[i]
   if t < 0:
      return i
   t = find(parent, t)
   parent[i] = t
   return t

def unite(parent, i, j):
   i = find(parent, i)
   j = find(parent, j)
   if i == j:
      return
   parent[j] += parent[i]
   parent[i] = j

setrecursionlimit(10 ** 5)

n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]

parent = [-1] * n
friends = [[] for _ in range(n)]
for A, B in ab:
   unite(parent, A-1, B-1)
   friends[A-1].append(B-1)
   friends[B-1].append(A-1)

blocks = [[] for _ in range(n)]
for C, D in cd:
   blocks[C-1].append(D-1)
   blocks[D-1].append(C-1)

result = []
for i in range(n):
   p = find(parent, i)
   t = -parent[p] - 1
   t -= len(friends[i])
   for b in blocks[i]:
      if p == find(parent, b):
         t -= 1
   result.append(t)

print(*result)


Measured memory_bytes: 101264
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

	System.out.println(nextInt()*nextInt());

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

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

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35656
#include <vector>
#include <iostream>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

#define ff first
#define ss second

int main() {

	int n; cin >> n;
	vector<int> a(n); for (int i = 0; i <= n - 1; i++) cin >> a[i];

	vector<vector<long long>> dp(n, vector<long long>(n, 0));

	for (int i = n - 1; i >= 0; i--) {
		for (int j = i; j <= n - 1; j++) {
			if (i == j) dp[i][j] = a[i];
			else dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
		}
	}
	cout << dp[0][n - 1];

	return 0;
}

Measured memory_bytes: 73652
import itertools

a,b,c,x=map(int,open(0).read().split())
a=[list(range(a+1)),list(range(b+1)),list(range(c+1))]
l=list(itertools.product(*a))
ans=list((a,b,c) for a,b,c in l if (a*500)+(b*100)+(c*50)==x)
print (len(ans))

Measured memory_bytes: 13604
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x,0), b(y,0), c(z,0);
  vector<ll> sum;
  for(int i=0; i<x; i++){ cin>>a[i]; }
  for(int j=0; j<y; j++){ cin>>b[j]; }
  for(int j=0; j<z; j++){ cin>>c[j]; }
  for(int i=0; i<x; i++){ for(int j=0; j<y; j++){ 
    sum.emplace_back(a[i]+b[j]);
  }}
  sort(sum.rbegin(),sum.rend());

  vector<ll> ans;
  for(int i=0; i<min(k,(ll)sum.size()); i++){ for(int j=0; j<z; j++){ 
    ans.emplace_back(sum[i]+c[j]);
  }}
  sort(ans.rbegin(),ans.rend());
  for(int i=0; i<k; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


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

// MEMO
//
// unite,same: O(A(n))
//
// unite(x, t): x が属する集合と y が属する集合を併合する。
// same(x, y): x と y が同じ集合に属するかどうか判定する。
// root(x): x が属する集合を求める。
// size(x): x が属する集合の要素数を求める。

// THE BEGINNING OF THE LIBRARY.

struct UnionFind {
	vector< int > data;

    UnionFind(int size) : data(size, -1) {}

    bool unite(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 same(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)];
	}
};


// THE ENDING OF THE LIBRARY.
// THE FOLLOWING IS AN EXAMPLE OF USE.

int n, m;

int main() {
  
  	cin >> n >> m;
    UnionFind uf(2 * n);
  
  	for(int i = 0; i < m; i++) {
    	int a, b;
      	cin >> a >> b;
      	a--, b--;
      	uf.unite(a, b + n);
      	uf.unite(a + n, b);
    }
  
  	for(int i = 0; i < n; i++) {
    	if (uf.same(i, i + n)) {
        	cout << (long long)n * (n - 1) / 2 - m << endl;
          	return 0;
        }
    }
  
  	long long cnt = 0;
  	for(int i = 0; i < n; i++) {
    	if (uf.same(0, i)) cnt++;
    }
  	cout << cnt * (n - cnt) - m << endl;

	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int n;
	cin >> n;
	cout << "ABC";
	cout << n;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
// using Graph = vector<vector<Edge>>;
const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

vector<vector<ll>> dp(110, vector<ll>(1e5 + 100, INF_64));
int main()
{
    int N, W;
    cin >> N >> W;
    vector<int> w(N + 5);
    vector<int> v(N + 5);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 1e5; j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (j - v[i] >= 0) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }
    ll res = INF_64;
    for (int j = 1e5; j >= 0; j--) {
        if (dp[N][j] <= W) {
            cout << j << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    ll x, k, d;
    cin>> x>> k>> d;

    x= abs(x);

    ll n, p, pk, nk;


    pk= x/ d;

    p= (x- d*pk);
    n= abs(p-d);

    if(k<= pk)
    {
        cout<< x- (k*d);
        return 0;
    }

    cout<<  ((k- pk ) %2==0 ? p: n);
    nl;

    return 0;
}




Measured memory_bytes: 3648
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author c0117321c5
 */
public class Main{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a >= b * 2) {
            System.out.println(a - (b * 2));
        } else {
            System.out.println(0);
        }

    }

}


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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    lli n;
    cin >> n;
    lli a[n*3];
    REP(i, 0, 3*n) {
        cin >> a[i];
    }

    priority_queue<lli, vector<lli>, greater<lli>> l_que;
    lli l_sum = 0;
    REP(i, 0, n) {
        l_que.push(a[i]);
        l_sum += a[i];
    }
    lli l_sums[n+1];
    l_sums[0] = l_sum;
    REP(i, 1, n+1) {
        // 左から i 個、右から n-i 個取る
        // n+i 個目を入れて何かを捨てる
        l_sum += a[n+i-1];
        l_que.push(a[n+i-1]);
        l_sum -= l_que.top();
        l_que.pop();

        l_sums[i] = l_sum;
    }

    priority_queue<lli> r_que;
    lli r_sum = 0;
    REP(i, 0, n) {
        r_que.push(a[3*n-i-1]);
        r_sum += a[3*n-i-1];
    }
    lli r_sums[n+1];
    r_sums[n] = r_sum;
    REP(i, 1, n+1) {
        // 右から i 個、左から n-i 個取る
        // 2*n-i 個目を入れて何かを捨てる
        r_sum += a[2*n-i];
        r_que.push(a[2*n-i]);
        r_sum -= r_que.top();
        r_que.pop();

        r_sums[n-i] = r_sum;
    }
    lli ans = -LLONG_MAX;
    REP(i, 0, n+1) {
        ans = max(ans, l_sums[i] - r_sums[i]);
    }
    cout << ans << endl;
    //lli ans = -LLONG_MAX;
    //REP(i, 0, n+1) {
    //    // 左から i 個、右から n-i 個取る
    //    lli l_count = n+i;
    //    //lli r_count = n+n-i;
    //    // l_count 入った que と r_count 入った que を作成
    //    priority_queue<lli, vector<lli>, greater<lli>> l_que;
    //    priority_queue<lli> r_que;
    //    lli l_sum = 0;
    //    lli r_sum = 0;
    //    REP(j, 0, 3*n) {
    //        if (j < l_count) {
    //            l_que.push(a[j]);
    //            l_sum += a[j];
    //        }
    //        else {
    //            r_que.push(a[j]);
    //            r_sum += a[j];
    //        }
    //    }
    //    REP(j, 0, n) {
    //        if (j < i) {
    //            l_sum -= l_que.top();
    //            l_que.pop();
    //        }
    //        else {
    //            r_sum -= r_que.top();
    //            r_que.pop();
    //        }
    //    }

    //    ans = max(ans, l_sum - r_sum);
    //}
    //cout << ans << endl;
}


Measured memory_bytes: 5876
N = int(input())
S = input()

left = 0
left_E = 0
right = N-1
right_W = S[1:].count("W")
ans = ((left-left_E) + (right-right_W))

for i in range(1,N):
    left += 1
    if S[i-1] == "E":
        left_E += 1
        
    right -= 1
    if S[i] == "W":
        right_W -= 1
        
    ans = min(ans, (left-left_E) + (right-right_W))
    
print(ans)

Measured memory_bytes: 3828
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

struct SegTree {
    data: Vec<i64>,
}

impl SegTree {
    fn id() -> i64 {
        0
    }

    fn op(a: i64, b: i64) -> i64 {
        a + b
    }

    fn new(v: Vec<i64>) -> SegTree {
        let mut n = v.len().next_power_of_two();
        let mut data = vec![Self::id(); n * 2];
        for (i, x) in v.into_iter().enumerate() {
            data[n + i] = x;
        }
        for i in (1..n).rev() {
            data[i] = Self::op(data[i * 2], data[i * 2 + 1]);
        }
        SegTree { data: data }
    }

    // update data[n] to x
    fn update(&mut self, n: usize, v: i64) {
        let mut n = n + self.data.len() / 2;
        self.data[n] = v;
        while n > 0 {
            n = n / 2;
            self.data[n] = Self::op(self.data[n * 2], self.data[n * 2 + 1]);
        }
    }

    // query for data[l, r)
    fn query(&mut self, l: usize, r: usize) -> i64 {
        let mut l = l + self.data.len() / 2;
        let mut r = r + self.data.len() / 2;
        let mut vl = Self::id();
        let mut vr = Self::id();
        while l < r {
            if l % 2 == 1 {
                vl = Self::op(vl, self.data[l]);
            }
            l = (l + 1) / 2;

            if r % 2 == 1 {
                vr = Self::op(self.data[r - 1], vr);
            }
            r = r / 2;
        }
        Self::op(vl, vr)
    }
}

fn main() {
    input! {
        n: usize, q: usize,
        s: chars,
        lr: [(usize, usize); q]
    }

    let mut v = vec![0; n + 1];
    for i in 1..s.len() {
        if s[i - 1] == 'A' && s[i] == 'C' {
            v[i + 1] = 1;
        }
    }

    let mut t = SegTree::new(v);
    for i in 0..q {
        let ans = t.query(lr[i].0 + 1, lr[i].1 + 1);
        println!("{}", ans);
    }
}


Measured memory_bytes: 11004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> a(9);
  for (int i = 0; i< 9; i++) {
    cin >> a.at(i);
  }
  vector<bool> f(9, false);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int s;
    cin >> s;
    for (int j = 0; j < 9; j++) {
      if (a.at(j) == s) {
        f.at(j) = true;
        break;
      }
    }
  }
  if (f.at(0) && f.at(1) && f.at(2) || f.at(3) && f.at(4) && f.at(5) || f.at(6) && f.at(7) && f.at(8) || f.at(0) && f.at(3) && f.at(6) || f.at(1) && f.at(4) && f.at(7) || f.at(2) && f.at(5) && f.at(8) || f.at(0) && f.at(4) && f.at(8) || f.at(6) && f.at(4) && f.at(2)) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin>>s;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='U' || s[i]=='D')continue;
        if(i%2==0){
            if(s[i]!='R'){
                cout<<"No";
                return 0;
            }
        }
        else {
            if(s[i]!='L'){
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    int ans = v[n/2] - v[n/2-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
// #include <map>
// #include <set>
// #include <cmath>
// #include <string>

using namespace std;
typedef unsigned long long ull;


int main(int argc, char const *argv[]) {
    int N;
    ull A, B;
    cin >> N >> A >> B;
 
    vector<ull> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }

    ull ans = 0;
    for (int i = 0; i < N-1; i++) {
        ans += min((X[i+1] - X[i]) * A, B);
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
  

int main(){
    int num_query,command,key,ind;
    vector<int> num_array;
    cin >> num_query;
    for(int i = 0; i < num_query;i++){
        cin >> command;
        if(command == 0){
            cin >> key;
            num_array.push_back(key);
        }else if(command == 1){
            cin >> ind;
            cout << num_array[ind] << "\n";
        }else if(command == 2){
            num_array.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 3880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はNextPrime

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerNextPrime sc = new FastScannerNextPrime(System.in);

		try {
			//String S = sc.nextLine().trim();
			//long N = sc.nextlong();
			int X = sc.nextInt();

			PrimeNumber primeNumber = new PrimeNumber();

			while (true) {
				if (primeNumber.judgePrime(X))
					break;
				X++;
			}

			System.out.println(X);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

class PrimeNumber {
	/**
	 * 素数の場合、Trueを返す
	 * @param N
	 * @return
	 */
	public boolean judgePrime(int N) {
		for (int i = 2; i * i < N; i++) {
			if (N % i == 0)
				return false;
		}
		return true;
	}
}

//高速なScanner
class FastScannerNextPrime {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerNextPrime(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

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


Measured memory_bytes: 29264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	cin>>N;
	vector<int> a(N),b(N);
	rep(i,N) cin>>a[i];
	rep(i,N) cin>>b[i];

	set<int> st;
	rep(i,N) st.insert(b[i]);
	rep(I,N) if(!st.count(a[I])){
		puts("No");
		rep(i,N) cout<<a[i]<<(i==N-1?"\n":" ");
		a[I] = a[(I+1)%N];
		rep(i,N) cout<<a[i]<<(i==N-1?"\n":" ");
		return 0;
	}
	puts("Yes");
}



Measured memory_bytes: 8352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MOD=1e9+7;
typedef long long ll;

const int MAX_N=1e5;

int N;
int A[MAX_N];

int cnt[MAX_N];

void solve(){
	int x=1;
	if (N%2==1){
		if (cnt[0]!=1){
			printf("0\n");
			return;
		}
		x=2;
	}
	while(x<N){
		if (cnt[x]!=2){
			printf("0\n");
			return;
		}
		x+=2;
	}
	ll ans=1;
	REP(i,N/2){
		ans<<=1;
		ans%=MOD;
	}
	printf("%lld\n",ans);
}

int main(){
	scanf("%d",&N);
	REP(i,N){
		scanf("%d",&A[i]);
		cnt[A[i]]++;
	}
	solve();
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

int N;
int A[200010];

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];
    sort(A, A + N, greater<int>());
    ll ans = A[0];
    REP(i, 1, N - 1) {
        if (i % 2 == 1) {
            ans += A[(i + 1) / 2];
            //cout << A[(i + 1) / 2] << endl;
        }
        else {
            ans += A[i / 2];
            //cout << A[i / 2] << endl;
        }
    }
    cout << ans << endl;
}
/*
8
2 2 1 3 6 10 11 21
*/

Measured memory_bytes: 4392
#"""
import sys
input = sys.stdin.readline
#"""
def main():
    def get_key(i,j):
        if i<j: i,j = j,i
        return i*N+j
    N=int(input())
    A = [list(map(int,input().split())) for _ in [0]*N]
    V = [-1]*(N*N)
    for i in range(N):
        for j in range(i+1,N):
            V[get_key(i,j)] = 0
    Ef = [[] for _ in V]

    for i,B in enumerate(A):
        a0 = B[0]-1
        k1 = (i,a0)
        for a1 in B[1:]:
            a1 -= 1
            k0 = k1
            k1 = (i,a1)
            Ef[get_key(*k0)].append(get_key(*k1))
            V[get_key(*k1)] += 1

    q = [i for i,v in enumerate(V) if v == 0]
    ans = 0
    rmv = 0
    while q:
        qq = []
        for i in q:
            for j in Ef[i]:
                V[j] -= 1
                rmv += 1
                if V[j] == 0 : qq.append(j)
        ans += 1
        q = qq
    if rmv != N*(N-2) : ans = -1
    print(ans)
main()

Measured memory_bytes: 146160