akhauriyash/Code-Regression huggingface dataset:
def N(Dice):
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E(Dice):
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W(Dice):
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S(Dice):
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
def DICE(Dice,Dice2):
    if (Dice[0] in Dice2)==False:
        """print('No')"""
        return 0
    else:
        for j in range(6):
            if j%2==0:
                N(Dice2)
            else:
                W(Dice2)
            for i in range(4):
                N(Dice2)
                W(Dice2)
                S(Dice2)
                if Dice==Dice2:
                    break
            if Dice==Dice2:
                break
    if Dice==Dice2:
        """print('Yes')"""
        return 1
    else:
        """print('No')"""
        return 0
cnt=0             
a=int(input())
Dice=[i for i in range(a)]
for i in range(a):
     Dice[i]=[int(i) for i in input().split()]
for i in range(a-1):
    for j in range(i+1,a):
        cnt+=DICE(Dice[i],Dice[j])
if cnt==0:
    print("Yes")
else:
    print("No")
        

Measured memory_bytes: 7832
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef unsigned long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n; cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  for (int &z : a) cin >> z, --z;
  for (int &z : b) cin >> z;
  for (int &z : c) cin >> z;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i + 1 < n && a[i + 1] == a[i] + 1) {
      ans += c[a[i]];
    }
    ans += b[a[i]];
  }
  kek(ans);
  
}


Measured memory_bytes: 256
class Tree
  AND, OR, XOR = (0..2).to_a
  ALL = "1111".to_i(2)

  def initialize(exp, sweet)
    @size = 0
    @root = parse(exp, sweet)
  end

  class Node
    attr_accessor :left, :right, :value
    def print
      p @value
      return unless @left
      p "left"
      @left.print
      p "right"
      p @right.print
    end
  end

  def parse(exp, sweet)
    node = Node.new
    case exp.chr
      when "("
        @size += 1
        exp.slice!(0) # "("
        node.left = parse(exp, sweet)
        exp.slice!(0) # " "
        node.right = parse(exp, sweet)
        exp.slice!(0) # ")"
      else
        node.value = sweet[exp.slice!(0).to_i - 1]
    end
    node
  end

  def solve(depth = 0, operator = Array.new)
    return (calculate(operator.dup) == ALL ? 1 : 0) if(depth == @size)
    [AND, OR, XOR].map{|op|
      operator[depth] = op
      solve(depth + 1, operator)
    }.inject(&:+)
  end

  def calculate(operator, node = @root)
    return node.value if node.value
    case operator.shift
      when AND
        calculate(operator, node.left) & calculate(operator, node.right)
      when OR
        calculate(operator, node.left) | calculate(operator, node.right)
      when XOR
        calculate(operator, node.left) ^ calculate(operator, node.right)
    end
  end
end

until (exp = gets.chomp) == "END"
  p Tree.new(exp, gets.to_i.times.map{gets.delete(" ").to_i(2)}).solve
end

Measured memory_bytes: 6160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int s,w;
    cin >> s >> w;
    if(s<=w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }

return 0;
}


Measured memory_bytes: 3636
# 2n = n * 2 pairs optimal greedy contradiction 1 is paired with k 2 is with j if we move 1 to 2 and k to j
def main():
    n = int(input())

    arr = [int(x) for x in input().split(" ")]

    arr.sort()

    ans = 0

    for i in range(2*n):

        if (i % 2) == 0:
            ans += arr[i]

    print(ans)

main()


Measured memory_bytes: 2940
#include<bits/stdc++.h> 
using namespace std; 
#define int long long 
void solve(); 
int32_t main() 
{ 
ios_base::sync_with_stdio(false);cin.tie(NULL); 

#ifndef ONLINE_JUDGE 
freopen("input.txt", "r", stdin); 
freopen("error.txt", "w", stderr); 
freopen("output.txt", "w", stdout); 
#endif 

int t=1; 
/*is Single Test case?*/
while(t--) 
{ 
	solve(); 
	cout<<"\n"; 
} 

cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
return 0; 
} 
void solve() 
{ 
	int d,t,s;
	cin>>d>>t>>s;
 	int dis=s*t;
	if(dis>=d) cout<<"Yes";
	else cout<<"No";
} 


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

int a[12][12];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, x;

    cin >> n >> m >> x;

    vector<int> c(n);

    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }

    int ans = INF;
    for(int s = 0; s < (1 << n); s++){
        int cost = 0;
        vector<int> rikai(n,0);
//        rep(i,n) rikai[i] = 0;
        rep(t,n){
            if(s >> t & 1){
                cost += c[t];
                rep(j,m) rikai[j] += a[t][j];
            }
        }
        int rikai_ok = 1;
        rep(j,m) if(rikai[j] < x) rikai_ok = 0;
        if(rikai_ok) ans = min(ans, cost); 
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, h, w;
  cin >> h >> w >> n;
  int k = max(h, w);
  cout << (n+k-1)/k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//BEGIN CUT HERE
template<typename T>
struct BellmanFord{
  struct edge{
    int u,v;
    T w;
    edge(){}
    edge(int u,int v,T w):u(u),v(v),w(w){}
  };

  int n;
  vector< vector<int> > G;
  vector<int> used,reach;
  BellmanFord(int n):n(n),G(n),used(n,0),reach(n,0){}

  vector<edge> es;
  void add_edge(int u,int v,T c){
    es.emplace_back(u,v,c);
    G[u].emplace_back(v);
  }

  void dfs(int v){
    if(used[v]) return;
    used[v]=1;
    for(int u:G[v]) dfs(u);
  }

  T build(int from,int to,int &neg_loop){
    for(int i=0;i<n;i++){
      fill(used.begin(),used.end(),0);
      dfs(i);
      reach[i]=used[to];
    }
    const T INF = numeric_limits<T>::max();
    vector<T> ds(n,INF);
    ds[from]=0;
    for(int j=0;j<n;j++){
      bool update=0;
      for(auto e:es){
        if(!reach[e.u]||!reach[e.v]||ds[e.u]==INF) continue;
        if(ds[e.v]>ds[e.u]+e.w){
          ds[e.v]=ds[e.u]+e.w;
          update=1;
        }
      }
      if(!update) break;
      if(j==n-1){
        neg_loop=1;
        return INF;
      }
    }
    neg_loop=0;
    return ds[to];
  }
};
//END CUT HERE
//INSERT ABOVE HERE

signed main(){
  int n,m,p;
  cin>>n>>m>>p;
  BellmanFord<int> G(n);
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G.add_edge(a,b,p-c);
  }
  int neg_loop;
  int res=G.build(0,n-1,neg_loop);
  if(neg_loop){
    cout<<-1<<endl;
    return 0;
  }
  cout<<max(-res,0)<<endl;
  return 0;
}
/*
  verified on 2019/08/10
  https://atcoder.jp/contests/abc137/tasks/abc137_e
*/


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

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

int main(){
    int N, K;
    cin >> N >> K;
    int nmax = 0;
    int g;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        nmax = max(nmax, a);
        if (i == 0) g = a;
        else g = gcd(g, a);
    }
    if (K % g == 0 && K <= nmax) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N, A[2020];

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

	cin >> N;
	int sm = 0;
	for (int i = 0; i < N; i++) { cin >> A[i]; sm += A[i]; }
	bitset<4040404>dp;
	dp[0] = 1;
	for (int i = 0; i < N; i++)dp |= (dp << A[i]);
	for (int i = (sm + 1) / 2; i <= sm; i++)if (dp[i]) { puts(i); break; }
	

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	string n;
	cin >> n;
	rep(i, n.size()) {
		if(n[i] == '7') {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

int main() {
    int H, W, K, ans = INF;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    rep(div, 1 << (H - 1)) {
        int g = 0;
        vector<int> id(H);
        rep(i, H) {
            id[i] = g;
            if (div >> i & 1)
                ++g;
        }
        ++g;

        vector<vector<int>> c(g, vector<int>(W));
        rep(i, H) rep(j, W) c[id[i]][j] += (S[i][j] - '0');

        int num = g - 1;
        vector<int> now(g);
        auto add = [&](int j) {
            rep(i, g) now[i] += c[i][j];
            rep(i, g) if (now[i] > K) return false;
            return true;
        };

        rep(j, W) {
            if (!add(j)) {
                ++num;
                now = vector<int>(g);
                if(!add(j)){
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  string s;
  cin>>s;
  string t="";
  rep(i,s.size()){
    if(s[i]=='0')t+='0';
    if(s[i]=='1')t+='1';
    if(s[i]=='B' && t.size()>=1)t=t.erase(t.size()-1,1);
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256
n,m,X,Y=map(int,input().split())
x=sorted(list(map(int,input().split())))
y=sorted(list(map(int,input().split())))
if X>=Y:
    print("War")
else:
    if x[-1]<y[0] and x[-1]<Y and X<y[0]:
        print("No War")
    else:
        print("War")


Measured memory_bytes: 3060
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e7+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

ll ans[INIT];

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    FORI(i,1,N+1)
    {
        for (ll j = 1; j*i <= N; j++)
        {
            ans[i*j]++;
        }
    }
    ll tot=0;
    FORI(i,1,N+1)
    {
        tot+=(i*ans[i]);
    }
    cout<<tot<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 81944
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
//#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 1e9, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int a[N], p[N], n;
bool mark[N];

vector <int> dfs(int x) {
	vector <int> cnt;
	mark[x] = true;
	for(int i = 1; i < n; i++) {
		if(mark[i] || (x != 0 && __gcd(a[i], a[x]) == 1))
			continue;
		vector <int> cmp = dfs(i);
		int l = 0, r = 0, len = (int)cnt.size() + (int)cmp.size();
		for(int i = 0; i < len; i++) {
			if(l == (int)cnt.size())
				p[i] = cmp[r++];
			else if(r == (int)cmp.size())
				p[i] = cnt[l++];
			else if(cnt[l] < cmp[r])
				p[i] = cmp[r++];
			else
				p[i] = cnt[l++];
		}
		cnt.resize(len);
		for(int i = 0; i < len; i++)
			cnt[i] = p[i];
	}
	vector <int> en = {a[x]};
	for(auto u : cnt)
		en.pb(u);
	return en;
}

int32_t main() {
	use_fast;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	n++;
	sort(a, a + n);
	vector <int> ans = dfs(0);
	for(auto u : ans)
		if(u != 0)
			cout << u << " ";
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 4048
n=int(input())
l=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(l[0]-l[1])
for i in range(2,n):
    dp[i]=min(abs(l[i-1]-l[i])+dp[i-1], abs(l[i-2]-l[i])+dp[i-2])

print(dp[n-1])


Measured memory_bytes: 13980
import sys

N=input()
H=map(int, sys.stdin.readline().split())

H=H[::-1]
L=[]
for i,a in enumerate(H):
	if i==0:
		L.append(0)
		prev=a
	else:
		if prev<=a:
			L.append(L[-1]+1)
		else:
			L.append(0)	
		prev=a

print max(L)

Measured memory_bytes: 46764
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[5];scanf("%s",s);
	int w=0,ans=0;
	for(int i=0;s[i];i++){
		if(s[i]=='R')w++;
		else w=0;
		ans=max(ans,w);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
#include<map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 200010
#define endl '\n'
#define mp make_pair
#define INF 10000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define pii pair<long long int,long int>
#define mii map<long long int,long long int>
#define w(t) 	int t; cin>>t; while(t--)
#define coutyes cout<<"YES"
#define coutno cout<<"NO"

using namespace std;


int main() {
	//ll n,m,p,a,b,c,d,sum=0,cnt=0;
	string s,t;
	cin>>s>>t;
	bool flag=1;
	if(s.length()>t.length())	flag=0;
	else{
		forn(i,s.length()){
			if(s[i]!=t[i]){
				flag=0;
				break;
			}
		}
	}
	if(flag)	cout<<"Yes";
	else	cout<<"No";
}
 

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int N;
string s;

char func(char c,bool rev1,bool rev2){
  if(rev1^rev2){
    if(c=='S'){ return 'W';}
    if(c=='W'){ return 'S';}
    return 'E';
  }else{
    return c;
  }
}

string solve(string t){
  //構成
  for(int i=1;i<N-1;++i){
    bool isW = (t[i]=='W');
    bool isX = (s[i]=='x');
    t += string(1,func(t[i-1],isW,isX));
  }
  //検証
  bool ok = true;
  for(int idx:{0,N-1}){
    bool isW = (t[idx]=='W');
    bool isX = (s[idx]=='x');
    ok *= (t[(idx+1)%N]==t[(idx-1+N)%N])^isW^isX;
  }  
  dprint(t);
  return (ok?t:"-1");
}


int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  cin>>N;
  cin>>s;
  string ans = "-1";
  for(string first:{"S","W"}){
    for(string second:{"S","W"}){
      if(ans=="-1"){
        ans = solve(first+second);
      }
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,t,x,y,i;
	cin >> n;
	for(i=0;i<n;i++){
	    cin >> t >> x >> y;
	    if(abs(-x)+abs(-y)>t || abs(-x)+abs(-y)<=t && (abs(-x)+abs(-y))%2!=t%2){
	        cout << "No" << endl;
	        return 0;
	    }
	}
	cout << "Yes" << endl;
	return 0;
} 

Measured memory_bytes: 256
n, k, s = [int(s) for s in input().strip().split()]

if s == 10 ** 9:
    result = [s] * k + [1] * (n - k)
else:
    result = [s] * k + [10 ** 9] * (n - k)
print(" ".join(str(x) for x in result))

Measured memory_bytes: 65596
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long

int main(void)
{
  ll n, a, def, count = 0;
  scanf("%lld", &n);
  scanf("%lld", &a);
  def = a;
  for (ll i = 0; i < n - 1; i++)
  {
    scanf("%lld", &a);
    if (a <= def)
    {
      count += def - a;
    }
    else
    {
      def = a;
    }
  }
  printf("%lld\n", count);
  return 0;
}


Measured memory_bytes: 1732
def main():
    S = input()
    size = [[[[0, 0]], []], [[], []]]
    length = 0

    for s in S:
        size2 = [[[], []], [[], []], [[], []]]
        if s != "0":
            for i in range(2):
                for j in range(2):
                    if size[i][j]:
                        for x, y in size[i][j]:
                            if y == length+i:
                                size2[i+1][j ^ 1].append([y+1, y+1])
                                if x != y:
                                    size2[i][j ^ 1].append([x+1, y-1])
                            else:
                                size2[i][j ^ 1].append([x+1, y+1])
        if s != "1":
            for i in range(2):
                for j in range(2):
                    if size[i][j]:
                        for x, y in size[i][j]:
                            if x == 0:
                                size2[i+1][j].append([0, 0])
                                if x != y:
                                    size2[i][j ^ 1].append([x+1, y-1])
                            else:
                                size2[i][j ^ 1].append([x-1, y-1])
        if len(size2[0][0]+size2[0][1]) == 0:
            size2 = size2[1:]
            length += 1
        else:
            size2.pop()
        for i in range(2):
            for j in range(2):
                size2[i][j] = sorted(size2[i][j])
        size = [[[], []], [[], []]]
        for i in range(2):
            for j in range(2):
                if len(size2[i][j]) == 0:
                    continue
                elif len(size2[i][j]) == 1:
                    size[i][j] = size2[i][j]
                    continue
                size[i][j] = [size2[i][j][0]]
                for x, y in size2[i][j][1:]:
                    p, q = size[i][j][-1]
                    if y <= q:
                        continue
                    if x <= q+2:
                        size[i][j][-1][1] = y
                    else:
                        size[i][j].append([x, y])
    print(length)


main()


Measured memory_bytes: 74496
import sys
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1-i):
        if N-i-j == (Y-(10000*i)-(5000*j))//1000:
            print(i,j,N-i-j)
            sys.exit()
print(-1,-1,-1)

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const ll INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

// 0:a/ 1:ab/ 2:abc/ 3:総数
ll dp[MAX_N][4];
string S;

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

  dp[0][3] = 1;
  cin >> S;
  REP(i, S.size()) {
    switch(S[i]) {
    case 'A':
      dp[i + 1][0] = dp[i][0] + dp[i][3];
      dp[i + 1][1] = dp[i][1];
      dp[i + 1][2] = dp[i][2];
      dp[i + 1][3] = dp[i][3];
      break;
    case 'B':
      dp[i + 1][0] = dp[i][0];
      dp[i + 1][1] = dp[i][1] + dp[i][0];
      dp[i + 1][2] = dp[i][2];
      dp[i + 1][3] = dp[i][3];
      break;
    case 'C':
      dp[i + 1][0] = dp[i][0];
      dp[i + 1][1] = dp[i][1];
      dp[i + 1][2] = dp[i][2] + dp[i][1];
      dp[i + 1][3] = dp[i][3];
      break;
    case '?':
      dp[i + 1][2] = dp[i][2] * 3 + dp[i][1];
      dp[i + 1][1] = dp[i][1] * 3 + dp[i][0];
      dp[i + 1][0] = dp[i][0] * 3 + dp[i][3];
      dp[i + 1][3] = dp[i][3] * 3;
      break;
    }
    REP(j, 4) {
      dp[i + 1][j] %= MOD;
    }
  }

  cout << dp[S.size()][2] << endl;
  
  return 0;
}



Measured memory_bytes: 3664
a,b,k = map(int,input().split())
if b-a+1 >= k:
    hidari = [i for i in range(a,a+k)]
    migi = [j for j in range(b,b-k,-1)]
    for i in migi:
        if i not in hidari:
            hidari.append(i)
    hidari.sort()
    for k in hidari:
        print(k)
else:
    for h in range(a,b+1):
        print(h)

Measured memory_bytes: 3064
MOD = 998244353

def getDivisors(x):
    anss = set()
    for d in range(1, int(x**0.5)+1):
        if x%d == 0:
            anss.add(d)
            anss.add(x//d)
    return sorted(anss)

N = int(input())
X = input()

divisors = getDivisors(2*N)

periods = [d for d in divisors if d%2 == 0 and (2*N//d)%2]
numP = len(periods)

anss = dict(zip(periods, [0]*numP))
for p in periods:
    lenPtn = p//2
    anss[p] += int(X[:lenPtn], 2) % MOD
    Ts = X[:lenPtn]
    notTs = ''.join(['1' if T == '0' else '0' for T in Ts])
    T2s = (Ts+notTs)*(N//p) + Ts
    if T2s <= X:
        anss[p] += 1
    anss[p] %= MOD
    for p2 in periods:
        if p == p2: continue
        if p2%p == 0:
            anss[p2] -= anss[p]

ans = sum([k*v for k, v in anss.items()])
print(ans % MOD)


Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

string s, t;

ll dp[212345][30];

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

    s += s;
    
    rep(i, 26) dp[s.size()][i] = -1; //last
    
    for(int i = s.size()-1; i >= 0; i--){
        rep(j, 26) dp[i][j] = dp[i+1][j]; // 基本i+1文字目の情報をそのまま記録
        dp[i][s[i] - 'a'] = i+1;// i+1文字目のもidx更新
    }
    
    ll ans = 0 ;
    
    rep(i, t.size()){
        ll nxt = dp[ans % (s.size()/2)][t[i] - 'a'];
        if(nxt == -1) {
            cout << -1 << endl;
            return 0;
        }
        nxt -= ans % (s.size()/2);
        ans += nxt;
    }

    cout << ans  << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 47724
#include<stdio.h>
#include<stdlib.h>
struct node{
  int key;
  struct node *l, *r, *p;
};
typedef struct node *Node;
Node NIL, root;

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->l;
    else x=x->r;
  }
  z->p=y;

  if(y==NIL) root =z;
  else if(z->key < y->key) y->l=z;
  else y->r=z;
}
void inorder(Node u){
  if(u->l!=NIL)inorder(u->l);
  printf(" %d",u->key);
  if(u->r!=NIL)inorder(u->r);
}

void preorder(Node u){
  if(u!=NIL)
    printf(" %d",u->key);
  if(u->l!=NIL)preorder(u->l);
  if(u->r!=NIL)preorder(u->r);
}

int main(){
  int m,i,x;
  char str[20];
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(str[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[100000],sum[100001] = {},res = 0;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	sort(a,a + n);
	for(int i = 0;i < n;i++) sum[i + 1] = sum[i] + a[i];
	for(int i = n - 2;i >= 0;i--){
		if(sum[i + 1] * 2 >= a[i + 1]) res++;
		else break;
	}
	cout << res + 1 << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}


void solve()
{ 
  int n;cin >> n;int A[n+5],i,p=1000000000000000000,flag=0;
  for(i=1;i<=n;i++)
  {
      cin >> A[i];
      if(A[i]!=0)
      p=p/A[i];
      else flag=1;
  }
  if(flag==1)cout<<"0";
  else if(p==0)cout<<"-1";
  else
  {
      p=1;
      for(i=1;i<=n;i++)
      p=p*A[i];
      cout<<p;
  }
}

signed main()
{ boost
  int test=0,t;
    //cin >> t ;
    t=1;
   while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

Measured memory_bytes: 4436
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

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

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

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> bfs(int s, int N, vector<vector<int>> &graph){
  vector<int> dist(N, INF);
  dist[s] = 0;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(auto v : graph[p]){
      if(dist[v] != INF) continue;
      dist[v] = dist[p]+1;
      q.push(v);
    }
  }
  return dist;
}

int diameter(int N, vector<vector<int>> &graph){
  auto dist = bfs(0, N, graph);
  int root, ret = 0;
  REP(i, N){
    if(chmax(ret, dist[i])) root = i;
  }
  dist = bfs(root, N, graph);
  REP(i, N) chmax(ret, dist[i]);
  return ret;
}

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

  if(N == 1){
    cout << "First" << "\n";
    return 0;
  }

  vector<vector<int>> graph(N);
  REP(i, N-1){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }

  if(diameter(N, graph)%3 == 1) cout << "Second" << "\n";
  else cout << "First" << "\n";

  return 0;
}

Measured memory_bytes: 17520
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		n: usize,
		mut cs: Chars,
	}

	let mut ans = 0;
	for i in 1..n {
		let mut x = cs.clone();
		let mut y = x.split_off(i);
		x.sort();
		x.dedup();
		y.sort();
		y.dedup();
//		println!("{:?}", x);
//		println!("{:?}", y);
		let mut count = 0;
		for j in 0..x.len() {
			for k in 0..y.len() {
				if x[j] == y[k] {
					count += 1;
					break;
				}
			} 
		}
//		println!("{}", count);
//		println!("");
		ans = max(ans, count);
	}

	println!("{}", ans);
}


Measured memory_bytes: 2180
N = int(input())
As = input().split(' ')
As = [int(As[i]) for i in range(N)]
EVEN = 0
for i in range(N):
  if As[i]%2 == 0:
    while As[i]%2 == 0:
      As[i] /= 2
      EVEN += 1
print(EVEN)

Measured memory_bytes: 10156
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;
#define inf 10000000000000LL
#define N 820000 
long long n,q,l,r,x[N];
namespace seg{
	long long t_l[N],t_r[N],tag[N];
	long long build(long long i,long long l,long long r){
		if(l==r){
			t_l[i]=inf;
			t_r[i]=inf;
			return 0;
		}
		long long mid=(l+r)/2;
		build(i*2,l,mid);
		build(i*2+1,mid+1,r);
		t_l[i]=min(t_l[i*2],t_l[i*2+1]);
		t_r[i]=min(t_r[i*2],t_r[i*2+1]);
	}
	long long insert(long long i,long long l,long long r,long long x,long long a){
		a-=tag[i];
		if(l==r){
			t_l[i]=min(t_l[i],a+x);
			t_r[i]=min(t_r[i],a+n-x);
			return 0;
		}
		long long mid=(l+r)/2;
		if(x<=mid)insert(i*2,l,mid,x,a);
		else insert(i*2+1,mid+1,r,x,a);
		t_l[i]=min(t_l[i*2],t_l[i*2+1]);
		t_r[i]=min(t_r[i*2],t_r[i*2+1]);
	}
	long long add(long long x){tag[1]+=x;}
	long long query_L(long long i,long long l,long long r,long long x,long long y){
		if(x<=l&&y>=r)return t_l[i]+tag[i];
		long long mid=(l+r)/2,ans=inf;
		if(x<=mid)ans=min(ans,query_L(i*2,l,mid,x,y));
		if(y>mid)ans=min(ans,query_L(i*2+1,mid+1,r,x,y));
		return ans+tag[i]; 
	}
	long long query_R(long long i,long long l,long long r,long long x,long long y){
		if(x<=l&&y>=r)return t_r[i]+tag[i];
		long long mid=(l+r)/2,ans=inf;
		if(x<=mid)ans=min(ans,query_R(i*2,l,mid,x,y));
		if(y>mid)ans=min(ans,query_R(i*2+1,mid+1,r,x,y));
		return ans+tag[i]; 
	}
}
int main(){
	scanf("%lld%d%d%d",&n,&q,&l,&r);
	seg::build(1,1,n);
	scanf("%lld",&x[1]);
	seg::insert(1,1,n,l,fabs(x[1]-r));
	seg::insert(1,1,n,r,fabs(x[1]-l));
	for(long long i=2;i<=q;i++){
//		for(long long i=1;i<=n;i++)printf("%lld ",seg::query_L(1,1,n,i,i)-i);
//		printf("\n");
		scanf("%lld",&x[i]);
		long long o=seg::query_L(1,1,n,x[i],n)-x[i];
		o=min(o,seg::query_R(1,1,n,1,x[i])-(n-x[i]));
		seg::add(fabs(x[i]-x[i-1]));
		seg::insert(1,1,n,x[i-1],o);
	}
//		for(long long i=1;i<=n;i++)printf("%lld ",seg::query_L(1,1,n,i,i)-i);
//		printf("\n");
	long long ans=inf;
	for(long long i=1;i<=n;i++)ans=min(ans,seg::query_L(1,1,n,i,i)-i);
	printf("%lld\n",ans); 
}

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

int main(void)
{

	int N,i,ans=0;

	cin >> N;

	int A[N];
	int B[N-1];

	for(i=0;i<N-1;i++)
	{

		cin >> B[i];

	}

	for(i=0;i<N;i++)
	{
		
		if(i==0)
			A[i]=B[i];

		else if(i==N-1)
			A[i]=B[i-1];
		
		else
			A[i]=min(B[i-1],B[i]);
	}

	for(i=0;i<N;i++)
	{
		
		ans=ans+A[i];

	}

	cout << ans << endl;	
}


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int A, B, C;
  cin >> A >> B >> C;
  print((A + B + C >= 22) ? "bust" : "win");
  return 0;
}

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

int main() {
	int way[5] = {0};
	int f = true;
	for (int i = 0; i < 3; i++) {
		int a, b;
		cin >> a >> b;
		way[a]++;
		way[b]++;
	}
	for (int i = 1; i <= 4; i++) {
		if (way[i] >= 3 || !way[i]) {
			f = false;
		}
	}
	if (f) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN maxn

using namespace std;

long long a, b, c, d;

signed main()
{
	IO;
	cin >> a >> b >> c >> d;
	if (a <= 0 && 0 <= b || c <= 0 && 0 <= d) {
		cout << max({a * c, a * d, b * c, b * d, 0LL}) << endl;
	} else {
		cout << max({a * c, a * d, b * c, b * d}) << endl;
	}
	return 0;
}



Measured memory_bytes: 3604
#include<stdio.h>
#define pi 3.141592653589

int main()
{
  double n;
  double temp1;
  double temp2;
  scanf("%lf",&n);

  temp1 = (double)n*n*pi;
  temp2 = (double)n*2*pi;
  printf("%f %f", temp1, temp2);
}



Measured memory_bytes: 2124
def sieve(n):
    p = 0
    prime = [0] * n
    is_prime = [True] * (n + 1)
    is_prime[0], is_prime[1] = False, False
    for i in range(2, n + 1):
        if is_prime[i]:
            prime[p] = i
            p += 1
            for j in range(2 * i, n + 1, i):
                is_prime[j] = False
            
    return prime[:p]

N = 10 ** 5
pn = sieve(N + 1)

dp = [0] * (N + 1)
for i in pn:
    if (i + 1) // 2 in pn:
        dp[i] += 1
        
for i in range(1, N + 1):
    dp[i] += dp[i - 1] 
        
Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(dp[r] - dp[l - 1])

Measured memory_bytes: 6712
H, W = map(int, raw_input().split())
N = input()
a = map(int, raw_input().split())
x = 0
B = [[-1 for x in range(W)] for y in range(H)]
z = 0
for i in range(N):
    for j in range(a[i]):
        x, y = z % W, z / W
        if y % 2 == 1:
            x = W - x - 1
        B[y][x] = i+1
        z += 1

for y in range(H):
    for x in range(W):
        print B[y][x],
    print

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


int main() {
    int n;
    cin >> n;
    double res;
    int i = 0;
    for(i = 1;i <= n;i++) {
       res = i * 1.08;
       if(int(res) == n) {
           cout << i << '\n';
           return 0;
       }
    }
    cout << ":(" << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int p_min = Integer.MAX_VALUE;
		for(int i = 0; i < 3; i++){
			p_min = Math.min(p_min, sc.nextInt());
		}

		int d_min = Integer.MAX_VALUE;
		for(int i = 0; i < 2; i++){
			d_min = Math.min(d_min, sc.nextInt());
		}

		System.out.println((p_min + d_min - 50));
	}

}


Measured memory_bytes: 26120
#include"bits/stdc++.h"

void Main() {
  long int n;
  std::cin >> n;
  std::cout << n * (n - 1) / 2 << std::endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let mut cv = vec![vec![0i32; 3]; 3];
    for y in 0..3 {
        for x in 0..3 - 1 {
            cv[y][x] = read(&mut stdin_lock, &mut buf, b' ');
        }
        cv[y][3 - 1] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let mut ans = false;
    for a1 in -100..100 + 1 {
        let b1 = cv[0][0] - a1;
        let b2 = cv[0][1] - a1;
        let b3 = cv[0][2] - a1;
        let a2 = cv[1][0] - b1;
        let a3 = cv[2][0] - b1;
        if a2 == cv[1][1] - b2 && a2 == cv[1][2] - b3 && a3 == cv[2][1] - b2 && a3 == cv[2][2] - b3
        {
            ans = true;
            break;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 4352