akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string>

#include <numeric>

#include <cstdio>

#include <cstdlib>

using namespace std;


const int INF = 10000000;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back

//char maze[100][101];

ll n, m;

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離

int d[100][100];


//移動方向のベクトル

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int ans = 0;
pair<int, int> red[101], blue[101];
//ll a[200000], b[20000];

//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

//エラトステネスの篩 prime(n)[k]で1~nまで探索して(k+1)番目の素数を出力
vector<int> prime(int n) {
	vector<int> erst;
	for (int i = 0; i < n; ++i) erst.PB(i);
	erst[0] = erst[1] = NULL;
	auto dmax = sqrt(n);

	for (int dx = 2; dx < dmax; ++dx) {
		if (erst[dx] == NULL) continue;
		for (int i = dx * 2; i < n; i += dx) erst[i] = NULL;
	}

	vector<int> erstlist;
	for (auto i : erst) if (i) erstlist.PB(i);

	return erstlist;
}

ll v_find(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

ll BIG = 10000000000;

ll POW(ll a, ll b) {
	if (b == 0) return 1;
	return (a*POW(a, b - 1)) % BIG;
}

int Kaijou(int a) {
	if (a < 2) return 1;
	return a * Kaijou(a - 1);
}


ll aa[51];

int main() {
	/*int n,k;
	cin >> n >> k;
	int a[5000] = { 0 };
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	int sum = 0;
	int i;
	for (i = n - 1; i >= 0; --i) {
		sum += a[i];
		if(sum)
	}
	cout << pp << endl;*/
	int x;
	cin >> x;
	int t = 1;
	int sum = 0;
	while (1) {
		sum += t;
		if (sum >= x) {
			cout << t << endl;
			return 0;
		}
		t++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

vec x(100), y(100), h(100);
ll simu(ll tempH, ll cx, ll cy){
    rep(k,N){
        if(max(tempH - abs(x[k] - cx) - abs(y[k] - cy), 0LL) > h[k]){
            return 1;
        }else if(max(tempH - abs(x[k] - cx) - abs(y[k] - cy), 0LL) < h[k]){
            return -1;
        }
    }
    return 0;
}

int main() {
    cin>>N;
    rep(i,N) cin>>x[i]>>y[i]>>h[i];
    vec so(N);
    rep(i,N) so[i] = h[i];
    sort(so.begin(),so.end());
    P ans = mp(-1, -1);
    ll hei = -1;
    rep(i,101){
        rep(j,101){
            ll lb = so[0], ub = so[N-1] + 101;
            while(ub - lb > 1){
                ll cen = (ub + lb)/2;
                if(simu(cen, i, j) == 1){
                    ub = cen;
                }else{
                    lb = cen;
                }
            }
            if(simu(lb,i,j) == 0){
                ans = mp(i,j);
                hei = lb;
                break;
            }
        }
        if(hei != -1){
            break;
        }
    }
    //cout<<so[0]<<' '<<so[N-1]<<endl;
    cout<<ans.fi<<' '<<ans.se<<' '<<hei<<endl;
}


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

int main() {
	int n,i,j;
	cin>>n;
	cout<<fixed;
	cout<<setprecision(10);
	vector<double>a(n);
	for(i=0;i<n;i++)
	cin>>a[i];
	vector<vector<double>>dp(n+1,vector<double>(n+1,0.0));
	dp[0][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(j==0)
			dp[i][j]=dp[i-1][j]*(1-a[i-1]);
			else 
			dp[i][j]=dp[i-1][j]*(1-a[i-1])+dp[i-1][j-1]*a[i-1];
		}
	}
	double ans=0.0;
	for(int i=n;i>n/2;i--)
	ans+=dp[n][i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 73780
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>



using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};

int gcd(int a,int b)
{
    if(a<b) return gcd(b,a);
    if(b==0)return a;
    int r;
    while((r=a%b))
    {
        a=b;
        b=r;
    }
    return b;
}

//*****************************************
//方針：この問題はＮコからN-1コもってきたときの最大公約数が最大となるときの最大公約数を出せという問題になる
//したがって、N-1コに対する最大公約数を全探索すれば良いのではないか

//反省：案の定ＧＣＤ全探索はＴＬＥになる、ＤＰで時間短縮だ！！
int n,i;

int main(void){

    
    scanf("%d",&n);

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


    int L[n+1],R[n+1];
    L[0]=0;
    R[n]=0;

    for(i=0;i<n;i++)
    {
        L[i+1]=gcd(L[i],A[i]);
    }

    for(i=n;i>0;i--)
    {
        R[i-1]=gcd(R[i],A[i-1]);
    }

    int dp[n];
    int max=-100;
    for(i=0;i<n;i++)
    {
        dp[i]=gcd(L[i],R[i+1]);
        if(max<dp[i])
        {
            max=dp[i];
        }
    }

    cout<<max<<endl;


    return 0;
}





Measured memory_bytes: 1792
n, x = map(int,input().split())
a_ls = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    target = a_ls[i:i+2]
    eat = sum(target) - x
    if eat > 0:
        ans += eat
        if eat < target[1]:
            target[1] -= eat
        else:
            rest = eat - target[1]
            target[1] = 0
            target[0] -= rest
    a_ls[i:i+2] = target
print(ans)

Measured memory_bytes: 14132
while True:
    n=int(input())
    if n==0:
        break
    x=[]
    for i in range(n):
        a=int(input())
        x.append(a)
    y=sorted(x)
    sum=0
    for j in range(1,len(y)-1):
        sum+=y[j]
    ave=sum//((len(y))-2)
    print(ave)


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

int main(){
    ll A, B;
    ll V ,W;
    ll T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    if(W < V && abs(B - A) <= (V - W) * T){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int N;
	int K;
	scanf("%d%d", &N, &K);
	int x[N];
	int a[N];
	int kyori[N];
	int i = 0;
	int sum = 0;
	while (i < N)
	{
		scanf("%d", &x[i]);
		if (x[i] >= K)
			kyori[i] = (x[i] - K) * 2;
		else
			kyori[i] = (K - x[i]) * 2;
		if (kyori[i] >= (x[i] * 2))
			sum += (x[i] * 2);
		else
			sum += kyori[i];
		i++;
	}
	printf("%d", sum);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
using ll = long long;

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

    int remain = price % 1000;

    if (remain > 0) {
        cout << 1000 - remain << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

double pi = 4.0 * atan(1.0);

int main()
{
    double r;
    cin >> r;
    printf("%.6f %.6f\n", pi * r * r, 2 * pi * r);

    return 0;
}

Measured memory_bytes: 3276
// atcoder/abc149/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  const int N = 1e6;
  bool prime[N];
  fill(prime, prime + N, true);
  prime[0] = prime[1] = false;
  for (lli i = 2; i * i < N; ++i) {
    for (lli j = 2; i * j < N; ++j) {
      prime[i * j] = false;
    }
  }
  vector<lli> p;
  for (int i = 0; i < N; ++i) {
    if (prime[i]) p.push_back(i);
  }

  lli x;
  while (cin >> x) {
    cout << *lower_bound(p.begin(), p.end(), x) << endl;
  }

  return 0;
}


Measured memory_bytes: 2424
#include <iostream>
#include<string.h>
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;

	int ans = 0;
	if (S[0] == T[0]) ans = ans + 1;
	if (S[1] == T[1]) ans = ans + 1;
	if (S[2] == T[2]) ans = ans + 1;

	cout << ans << endl;

	return 0;
}

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

#define Pi acos(-1)
#define INPUT_OUTPUT { \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout); \
}

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main()
{
	//INPUT_OUTPUT; // I use this to test code easily in my code editor!
	
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	for(int i=0; i < n; i++) {
		cout << a.at(i) << b.at(i);
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main () 
{
    ll a,b,n,k,ans=0,ans1=0;cin>>a>>b>>n;
    if (b==1) {
     ans1=0;
    }
    else {
      for (ll i=1;i<=100000;i++) {
        k=b*i-1;
        if (k<n) {
           ans=(a*k)/b - a*(i-1);
           ans1=max(ans,ans1);
        }
        else {
           ans=(a*n)/b - a*(i-1);
           ans1=max(ans,ans1);
           break;
        }
      }

    }
    cout<<ans1<<endl;
}



Measured memory_bytes: 3636
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll K = 0, N =0;
    cin >> K >> N;

    vll A(N);
    REP(i,N) cin >> A[i];


    //本文
    ll diff= 0;
    REP(i,N-1){
        diff=max(A[i+1]-A[i],diff);
    }

    ll ans = min(A[N-1]-A[0],K-diff);
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 4704
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int unused __attribute__((unused));
  long long A, B, N, x;
  unused = scanf("%lld %lld %lld", &A, &B, &N);

  x = fmin(B-1, N);
  printf("%lld", A*x/B - A*(x/B));
  return 0;
}

Measured memory_bytes: 2148
def solve():
    def measurement(a, b, w):
        a_root = root[a]
        b_root = root[b]
        if a_root != b_root:
            a_member = member[a_root]
            b_member = member[b_root]
            offset = w - (weight[b] - weight[a])
            if len(a_member) > len(b_member):
                a_member.extend(b_member)
                for n in b_member:
                    root[n] = a_root
                    weight[n] += offset
            else:
                b_member.extend(a_member)
                for n in a_member:
                    root[n] = b_root
                    weight[n] -= offset
    
    def inquiry(a, b):
        if root[a] == root[b]:
            return weight[b] - weight[a]
        else:
            return 'UNKNOWN'
    
    def operation(line):
        if line[0] == '!':
            a, b, w = map(int, line[2:].split())
            measurement(a, b, w)
        else:
            a, b = map(int, line[2:].split())
            return inquiry(a, b)
    
    import sys
    file_input = sys.stdin.readlines()
    
    while True:
        N, M = map(int, file_input[0].split())
        if N == 0:
            break
        
        root = [i for i in range(N + 1)]
        member = [[i] for i in range(N + 1)]
        weight = [0] * (N + 1)
        
        ans = (operation(line) for line in file_input[1:M+1])
        ans = filter(lambda x: x != None, ans)
        print(*ans, sep='\n')
        
        del file_input[:M+1]

solve()


Measured memory_bytes: 133988
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[22], b[22], c[22];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for (i = 0; i < n - 1; i++)
		scanf("%d", &c[i]);
	int ans = b[a[0] - 1];
	for (i = 1; i < n; i++)
	{
		ans += b[a[i] - 1];
		if (a[i] == a[i - 1] + 1)
			ans += c[a[i - 1] - 1];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<H*W-h*W-w*H+h*w<<endl;
    
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
  	cin>>n;
  	int a[n+1],temp;
  	for(int i=0;i<=n;i++){
      cin>>a[i];
    }
  long long int ans=0;
  	for(int i=0;i<n;i++){
		cin>>temp;
      	if(temp>=a[i]){
          	ans+=a[i];
          	temp-=a[i];
          	a[i]=0;
        }
        else{
            ans+=temp;
            a[i]-=temp;
            temp=0;
        }
      	if(temp>=a[i+1]){
          ans+=a[i+1];
          temp-=a[i+1];
          a[i+1]=0;
        }
      	else{
          ans+=(temp);
          a[i+1]-=temp;
          temp=0;
        }
          	
    }
  cout<<ans<<"\n";
  return 0;
}
  	
  

Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[]ss = S.toCharArray();
 
        for(int i=0; i<S.length(); i++){
            if(ss[i]+N <= 90){
                ss[i]=(char)(ss[i]+N);
            }else{
                ss[i]=(char)(ss[i]+N-26);
            }        
        }         
            System.out.print(String.valueOf(ss));
        }
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  vector<vector<ll>> a(3, vector<ll>(3, 0));
  for (ll i = 0; i < 3; ++i) {
    for (ll j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }

  ll n;
  cin >> n;

  vector<ll> b(n);
  for (ll i = 0; i < n; ++i) {
    cin >> b[i];
  }

  for (ll i = 0; i < 3; ++i) {
    for (ll j = 0; j < 3; ++j) {
      for (ll k = 0; k < n; ++k) {
        if (a[i][j] == b[k]) {
          a[i][j] = 200;
        }
      }
    }
  }

  bool bingo = false;
  for (ll i = 0; i < 3; ++i) {
    if (a[i][0] == 200 && a[i][1] == 200 && a[i][2] == 200) {
      bingo = true;
    }
  }
  for (ll i = 0; i < 3; ++i) {
    if (a[0][i] == 200 && a[1][i] == 200 && a[2][i] == 200) {
      bingo = true;
    }
  }
  if (a[0][0] == 200 && a[1][1] == 200 && a[2][2] == 200) {
      bingo = true;
  }
  if (a[0][2] == 200 && a[1][1] == 200 && a[2][0] == 200) {
      bingo = true;
  }

  if (bingo) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    Integer result = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        if (count % 2 == 0) {
            System.out.println(count / 2);
        } else {
            System.out.println((count / 2) + 1);
        }
    }

}

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

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split("");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);
			System.out.println(a+b+c);

		}
	}
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	vector<bool> dp(n+1,false);
	vector<int> va={100,101,102,103,104,105};
	for(int i=0;i<va.size();i++){
		dp[va[i]]=true;
	}
	for(int i=106;i<=n;i++){
		for(int j=0;j<va.size();j++){
			if(dp[i-va[j]]) dp[i]=true;
		}
	}
	if(dp[n]) cout << 1 << "\n";
	else cout << 0 << "\n";
	return 0;
}

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

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<int> rec(n+1, 0);
    for(int i=1; i<=n; i++) {
        if(i==1) continue;
        int ai; cin >> ai;
        rec[ai]++;
    }
    for(int i=1; i<=n; i++) cout << rec[i] << endl;

    return 0;
}

Measured memory_bytes: 3992
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5+10;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n;
int val[maxn];
int ans[maxn];

void solve()
{
	sa(n);
	repp(i,1,n)
	{
		sa(val[i]);
	}
	int left=1;
	int right=n;
	int cnt=n;
	repp(i,1,n)
	{
		if(i&1)
		{
			ans[left]=val[cnt];
			left++;
		}
		else
		{
			ans[right]=val[cnt];
			right--;
		}
		cnt--;
	}


	repp(i,1,n)
	{
		if(i>1)printf(" ");
		printf("%d", ans[i]);
	}
	puts("");
}

int main()
{
	solve();
	//system("pause");
	return 0;
}







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


int main(){
    int S,A,B,C,D;


    cin >> S;

    A = S/1000;
    B = S/100 - A*10;
    C = S/10 - A*100 - B*10;
    D = S - A*1000 - B*100 - C*10;

    if(A+B+C+D == 7)      cout << A <<'+'<< B <<'+'<<  C <<'+'<< D << "=7"<<"\n";
    else if(A-B+C+D == 7) cout << A <<'-'<< B <<'+'<<  C <<'+'<< D << "=7"<<"\n";
    else if(A+B-C+D == 7) cout << A <<'+'<< B <<'-'<<  C <<'+'<< D << "=7"<<"\n";
    else if(A-B-C+D == 7) cout << A <<'-'<< B <<'-'<<  C <<'+'<< D << "=7"<<"\n";
    else if(A+B+C-D == 7) cout << A <<'+'<< B <<'+'<<  C <<'-'<< D << "=7"<<"\n";
    else if(A-B+C-D == 7) cout << A <<'-'<< B <<'+'<<  C <<'-'<< D << "=7"<<"\n";
    else if(A+B-C-D == 7) cout << A <<'+'<< B <<'-'<<  C <<'-'<< D << "=7"<<"\n";
    else if(A-B-C-D == 7) cout << A <<'-'<< B <<'-'<<  C <<'-'<< D << "=7"<<"\n";




    

    return 0;
}

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



void solve()
{
	int n,x,t;
	cin >> n >> x >> t;
	cout << (int)(t*ceil((float)n/x));
	return;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("ouput.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 3608
S=input()
word=["dream", "dreamer", "erase", "eraser"]
dp=[0]*(len(S)+1)
dp[0]=1
done="NO"

for i in range(len(S)+1):
  if dp[i]==0:
    continue
   
  for w in word:
    if S[i:i+len(w)]== w:
      dp[i+len(w)]=1
      
if (dp[len(S)]==1):
  done= "YES"

print(done)
    

Measured memory_bytes: 3956
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int mod = 1000000007;
struct mint {
	lint x;
	mint(lint x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(lint t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

int main() {	
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	int a[n];
	int sum = 0;
	forn(i, n)cin >> a[i], sum += a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int i = 0, x = m;
	while(m--){
		if(a[i] * 4 * x < sum){
			cout << "No";
			return 0;
		}
		i++;
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
    double x1,y1,x2,y2,t=0;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    if(x1>x2){
        t+=pow(x1-x2,2.0);
    }else{
        t+=pow(x2-x1,2.0);
    }
    if(y1>y2){
        t+=pow(y1-y2,2.0);
    }else{
        t+=pow(y2-y1,2.0);
    }
    printf("%f\n",pow(t,0.5));
    return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <time.h>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;

int main()
{
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll ans=max(a*c,max(a*d,max(b*c,b*d)));
	cout << ans << endl;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    for(int i = 1 ; i <= n ; i++){
        if(floor(0.08 * i) == n - i){
            cout<<i<<endl;
            return;
        }
    }
    cout<<":("<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

#define pb push_back
#define y23oijdwnskd

using namespace std;

const int N = int(1e6 + 5);
const int INF = 1e9 + 7;

typedef long long ll;

int n;
int main (){
  scanf ("%d", &n);
  int l = 1, r = n, ans = INF;
  while (l <= r){
    int mid = l + r >> 1;
    int l2 = 1, r2 = n, f = 0;
    while (l2 <= r2){
      int mid2 = l2 + r2 >> 1;
      if (mid + mid2 > n){
        r2 = mid2 - 1;
      }
      else if (mid + mid2 < n){
        l2 = mid2 + 1;
      }
      else if (mid + mid2 == n){
        int a = mid, b = mid2, sum = 0;
        while (a){
          sum += (a % 10);
          a /= 10;
        }
        while (b){
          sum += (b % 10);
          b /= 10;
        }
        ans = min(ans, sum);
        f = 1;
        break;
      }
    }
    l = mid + 1;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_9_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int p = int.Parse(Console.ReadLine());
            List<string> answerList = new List<string>();

            for (int i = 0; i < p; i++)
            {
                string command = Console.ReadLine();
                string[] strList = command.Split(' ');
                int a = int.Parse(strList[1]);
                int b = int.Parse(strList[2]);
                string strAnswer;
                if (command.Contains("print") == true)
                {
                    strAnswer = str.Substring(a, b - a + 1);
                    answerList.Add(strAnswer);
                }
                else if (command.Contains("reverse") == true)
                {
                    string strab = str.Substring(a, b - a + 1);
                    string[] str0 = new string[strab.Length];
                    string str1 = null;
                    for (int j = 0; j < strab.Length; j++)
                    {
                        str0[j] = strab.Substring(j, 1);
                    }
                    for (int j = b - a ; j >= 0; j--)
                    {
                        str1 =str1 + str0[j];
                    }
                    str = str.Substring(0, a) + str1 + str.Substring(b+1);
                }
                else if (command.Contains("replace") == true)
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder(str);
                    sb.Replace(str.Substring(a, b - a + 1), strList[3],a,b-a+1);
                    str = sb.ToString();
                }
            }
            for (int i = 0; i < answerList.Count; i++)
            {
                Console.WriteLine(answerList[i]);
            }
        }
    }
}



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

using namespace std;

void insertionSort(int A[], int N) { // N個の要素を含む0-オリジンの配列A
        int j, v;
        for(int i = 0; i < N; i++) {
                v = A[i];
                j = i - 1;
                while (j >= 0 &&  A[j] > v) {
                        A[j+1] = A[j];
                        j--;
                        A[j+1] = v;
                }
                for(int k = 0; k < N; k++) {
                        if(k != N-1) {
                                printf("%d ", A[k]);
                        }else{
                                printf("%d\n", A[k]);
                        }
                }
        }
}

int main(int argc, char const *argv[]) {
        int N;
        cin >> N;
        int a[N];
        for(int i = 0; i < N; i++ ) cin >> a[i];
        insertionSort(a, N);
        return 0;
}



Measured memory_bytes: 3224
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()


def win(h):
    if h == 'r':
        return P
    elif h == 's':
        return R
    else:
        return S


score = []
for i in range(N):
    if i < K:
        score.append(win(T[i]))
    elif T[i] != T[i - K]:
        s = win(T[i])
        score.append(s)
    else:
        s = win(T[i])
        if s != score[i - K]:
            score.append(s)
        else:
            score.append(0)


print(sum(score))

Measured memory_bytes: 4212
MOD = 10**9 + 7

n,m = map(int,input().split())

ban = [False] * (n + 1)

for i in range(m):
    a = int(input())
    ban[a] = True

dp = [0] * (n + 1)
dp[0] = 1

for i in range(n):
    dp[i] %= MOD
    if ban[i]:dp[i] = 0
    #print(i, dp[i])
    if i + 1 <= n:
        dp[i + 1] += dp[i]
    if i + 2 <= n:
        dp[i + 2] += dp[i]

print(dp[n] % MOD)


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


int keta(ll x) {
    if (x == 0) return 1;
    int k = 0;
    while (x) {
        x /= 10;
        ++k;
    }
    return k;
}

ll solve(ll N){
    int best = keta(N);
    int sq = ceil(sqrt(N));
    for (int a=1; a<=sq; ++a) {
        if (N % a == 0) {
            ll b = N / a;
            // fprintf(stderr, "%lld = %d x %lld\n", N, a, b);
            int score = max(keta(a), keta(b));
            best = min(best, score);
        }
    }
    return best;
}

int main() {
    ll N; cin >> N;
    cout << solve(N) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class D
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		Console.WriteLine(((MInt)2).Pow(h[0]) - MInt.MNcr(h[0], h[1]) - MInt.MNcr(h[0], h[2]) - 1);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x) => x;
	public static MInt operator -(MInt x) => -x.V;
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Pow(int i) => MPow(V, i);
	public MInt Inv() => MPow(V, M - 2);
	public override string ToString() => $"{V}";

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}

	public static long MFactorial(int n) { for (long x = 1, i = 1; ; x = x * ++i % M) if (i >= n) return x; }
	public static long MNpr(int n, int r)
	{
		if (n < r) return 0;
		for (long x = 1, i = n - r; ; x = x * ++i % M) if (i >= n) return x;
	}
	public static MInt MNcr(int n, int r) => n < r ? 0 : n - r < r ? MNcr(n, n - r) : (MInt)MNpr(n, r) / MFactorial(r);
}


Measured memory_bytes: 27512
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int r[100010], t[100010], A[100010];
signed main(void)
{
  int x, k;
  cin >> x >> k;
  REP(i, k) cin >> r[i];
  int q;
  cin >> q;
  REP(i, q) cin >> t[i] >> A[i];

  int idx = 0, b = 0, c = x, pre = 0, p = 0, L = 0, R = x;
  REP(i, q) {
    while(idx < k && r[idx] <= t[i]) {
      if(idx%2==0) {
        int tmp = r[idx]-pre;
        p += tmp;
        b = max(b-tmp, 0);
        c = max(c-tmp, 0);
      }
      else {
        int tmp = r[idx]-pre;
        p -= tmp;
        b = min(b+tmp, x);
        c = min(c+tmp, x);
      }
      chmax(L, p);
      chmin(R, x+p);
      pre = r[idx];
      idx++;
    }
    // cout << "idx:" << idx << " b:" << b << " c:" << c << endl;
    // cout << "L:" << L << " R:" << R << " A[i]:" << A[i] << endl;
    int tmp = A[i] - p;
    if(A[i]<L) tmp = b;
    if(R<A[i]) tmp = c;
    // cout << tmp << endl;
    int dif = t[i]-pre;
    if(idx%2) tmp = min(tmp+dif, x);
    else tmp = max(tmp-dif, 0);
    cout << tmp << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x - r < 0 or y - r < 0 or x + r > W or y + r > H){
        puts("No");
    }else{
        puts("Yes");
    }
}


Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = ReadInt();
            var t = ReadIntArray();
            var sum = t.Sum();
            var m = ReadInt();
            for (int i = 0; i < m; i++)
            {
                var px = ReadIntArray();
                var p = px[0] - 1;
                var x = px[1];
                Console.WriteLine(sum - t[p] + x);
            }
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    map<string, int> ma;
    int most = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (ma.find(s) == ma.end())ma[s] = 0;
        ma[s]++;
        most = max(most, ma[s]);
    }

    vector<string> ret;
    for (auto x:ma) {
        if (x.second == most)ret.push_back(x.first);
    }
    sort(ret.begin(), ret.end());

    for (auto x:ret)cout << x << endl;
    return 0;
}

Measured memory_bytes: 26868
#include <iostream>

int main(){
	std::string S;
	std::cin>>S;

	int i=0;
	while(i < S.size()){
		std::string word = "";
		word = S.substr(i,5);
		if(i+5 < S.size() && S[i+5] == 'r'){
			word += "r";
			i += 1;
		}
		if(i+6 < S.size() &&
				S.substr(i+5,2) == "er" && S.substr(i+5,5) != "erase"){
			word += "er";
			i += 2;
		}
		i += 5;

		if(word != "dream" && word != "dreamer" &&
				word != "erase" && word != "eraser"){
				std::cout<<"NO";
				return 0;
		}	
	}
	std::cout<<"YES";
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN];
int main()
{
    scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]);
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) puts("YES"); else puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
using namespace std;
int main(){
    int n,u,k,v;
    int M[100][100]={0};
    stack<int> S;

    cin >> n;
    for(int i=0;i<n;i++){
	cin >> u;
	u--;
	cin >> k;
	for(int j=0;j<k;j++){
	    cin >> v;
	    v--;
	    M[u][v]=1;
	}
    }

    int time=0;
    int d[100]={0},f[100]={0};
    bool found;
    int i;

	for(int k=0;k<n;k++){
	    if(d[k]==0) S.push(k);
	    while(!S.empty()){
		if(d[S.top()]==0) d[S.top()]=++time;
		found=false;
		for(i=0;i<n;i++){
		    if(d[i]==0 && M[S.top()][i]==1){
			found=true;
			break;
		    }
		}
		if(found) S.push(i);
		else {
		    f[S.top()]=++time;
		    S.pop();
		}
	    }
	}

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

    return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1LL<<62

ll n, a[100010];

int main() {
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(int i=1;i<100002;i++){
		if(a[i]==i){
			swap(a[i],a[i+1]);
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int top, s1[1000];
void push(int x)
{
    s1[++top] = x;
}
int pop()
{
    top--;
    return s1[top+1];
}
int main()
{
    int b, c;
    top = 0;
    char s[200];
    while(scanf("%s",s))
    {
        if(s[0] == '+')
        {
            c = pop();
            b = pop();
            push(c+b);
        }
        else if(s[0] == '-')
        {
            b = pop();
            c = pop();
            push(c-b);
        }
        else if(s[0] == '*')
        {
            c = pop();
            b = pop();
            push(c*b);
        }
        else
        {
            push(atoi(s));
        }
        int a = getchar();
        if(a == 0xa)   break;
    }
    printf("%d\n",pop());
    return 0;
}

Measured memory_bytes: 2728
/**
 *    author:  zjsdut
 *    created: 2020/01/18 20:01:06
**/
#include <bits/stdc++.h>

using namespace std;

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

template<typename A, typename B>
bool chkmin(A &a, const B &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<typename A, typename B>
bool chkmax(A &a, const B &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
istream &operator>>(istream &stream, vector<T> &vec) {
    for (auto &x : vec) stream >> x;
    return stream;
}

void scan() {}

template<class T, class ...Args>
void scan(T &a, Args &...rest) {
    cin >> a;
    scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template<typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n) for(int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x: cont)
#define For(x, cont) for (auto &x: cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template<typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
    if (!vec.empty()) {
        stream << vec[0];
        for (size_t i = 1; i != vec.size(); ++i)
            stream << ' ' << vec[i];
    }
    return stream;
}

template<typename T>
void print(const vector<T> &t) { cout << t << '\n'; }

template<typename T>
void print(const vector<vector<T>> &t) {
    for (const auto &row : t) {
        print(row);
    }
}

template<typename T>
void print(const T &t) { cout << t << ' '; }

template<typename T, typename ...Args>
void print(const T &t, const Args &...rest) {
    print(t);
    print(rest...);
}

template<typename T>
void println(const T &t) { cout << t << '\n'; }

template<typename T, typename ...Args>
void println(const T &t, const Args &...rest) {
    print(t);
    println(rest...);
}


template<typename T1, typename T2>
T1 ceil(T1 x, T2 y) { // y >= 1，是整数。需要注意 x + y - 1 是否会溢出
    return (x + y - 1) / y;
}
int main() {
#if defined LOCAL
    ifstream in("in.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int h, w, n;
    scan(h, w, n);
    println(ceil(n, max(h, w)));

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        ios_base::sync_with_stdio(false);
        long int A[100002]={0} , N , i ;
        long long int ans = 0;
        cin >> N;
        for(i=1;i<=N;i++)
        {
            cin >> A[i];
            ans = ans + A[i]/2;
            if(A[i]%2 == 1) A[i] =1;
            else if(A[i] > 0) {
                A[i] = 2;
                ans--;
            }
        }
        for(i=1;i<=N;i++)
        {
            if(A[i] == 1)
            {
                if(A[i+1])
                {
                    A[i+1]--;
                    A[i]--;
                    ans++;
                }
            }
        }
        for(i=1;i<=N;i++)
        {
            if(A[i] == 2)
                ans++;
        }
        cout << ans ;
        return 0;
    }

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

using namespace std;

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

  int N, M; cin>>N>>M;

  vector<unsigned int> dp(1<<N, 0);
  for (int k = 0; k < M; k++) {
	int a, b; cin>>a>>b;
	int m = 0;
	for (int j = 0; j < b; j++) {
	  int c; cin>>c;
	  c--;
	  m |= 1 << c;
	}
    for (int i = 0; i < 1<<N; i++) {
      if (i > 0 and dp[i] == 0)
        continue;
      auto t = i | m;
      if (dp[t] == 0 or dp[t] > dp[i] + a)
      	dp[t] = dp[i] + a;
    }
  }
  if (dp[(1<<N)-1] == 0) {
    cout << -1 << endl;
  } else {
    cout << dp[(1<<N)-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define sp ' '
#define f first
#define s second
#define boost() cin.tie(0); cout.tie(0); cin.sync_with_stdio(0)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 402;
int N;
ll pre[MAXN], dp[MAXN][MAXN];
ll sum(int a, int b){
	return pre[b]-pre[a-1];
}
int main(){
	boost();
	memset(dp, 0x3f3f, sizeof(dp));
	cin >> N;
	for(int i = 1, a;i<=N;i++){
		cin >> a;
		pre[i] = pre[i-1]+a;
		dp[1][i] = 0;
	}
	for(int i = 1;i<=N;i++){
		for(int j = i;j<=N;j++){
			int l = j-i+1, r = j;
			if(l-1>=1){
				for(int k = 1;k<=l-1;k++){
					int l2 = l-k, r2 = l-1;
					dp[i+k][r] = min(sum(l2, r2)+dp[k][r2]+sum(l, r)+dp[i][r], dp[i+k][r]);	
				}
			}
			if(r+1<=N){
				for(int k = 1;k<=N-(r+1)+1;k++){
					int l2 = r+1, r2 = r+k;
					dp[i+k][r2] = min(sum(l, r)+dp[i][r]+sum(l2, r2)+dp[k][r2], dp[i+k][r2]);
				}
			}
		}
	}
	cout << dp[N][N] << nl;
}

Measured memory_bytes: 1536