akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void){
        string s, left = "", right = "";
        int q, count = 0;
        cin >> s >> q;
        for(int i = 0; i < q; i++){
                int query;
                cin >> query;
                if(query == 1){
                        count++;
                } else {
                        int f;
                        string c;
                        cin >> f >> c;
                        if(count % 2 == 0){
                                if(f == 1){
                                        left = left + c;
                                } else {
                                        right = right + c;
                                }
                        } else {
                                if(f == 1){
                                        right = right + c;
                                } else {
                                        left = left + c;
                                }
                        }
                }
        }
        reverse(left.begin(), left.end());
        string ans = left + s + right;
        if(count % 2 == 1){
                reverse(ans.begin(), ans.end());
        }
        cout << ans << endl;
        return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9+7;

template <typename T>
T pow_mod(T n, T p, T m)  // (n^p) % m
{
    if(p == 0) return 1;
    if(p%2 == 1) return pow_mod<T>(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod<T>(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

// nCk を O(n) で求めるクラス
template <typename T>
class Combination { private:
        int _mod;
        std::vector<T> factorial, factorial_inv;

    public:
        Combination(int n, int mod): _mod(mod), factorial(n+1, 1), factorial_inv(n+1)
        {
            for(int i = 1; i <= n; ++i) factorial[i] = (i*factorial[i-1]) % _mod;
            factorial_inv[n] = pow_mod<T>(factorial[n], _mod-2, _mod);  // 逆元を取る操作は重いので一回のみ行う
            for(int i = n; i >= 1; --i) factorial_inv[i-1] = (i*factorial_inv[i]) % _mod;
        } 

        T operator()(int n, int k)
        {
            if(n < 0 or k > n) return 0;
            return factorial[n] * factorial_inv[k] %_mod * factorial_inv[n-k] %_mod;
        }

        T P(int n, int k)
        {
            if(n < 0 or k > n) return 0;
            return factorial[n]*factorial_inv[n-k] % _mod;
        }
};


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

    Combination<long long> comb(M, MOD);

    long long ans = 0;
    REP(k, N+1){  // A[i] == B[i] となるものの個数
        long long cases = comb(N, k);
        cases = cases*comb.P(M, k) % MOD;
        cases = cases*comb.P(M-k, N-k) % MOD * comb.P(M-k, N-k) % MOD;
        ans += (k&1)? -cases: cases;
        ans %= MOD;
    }
    cout << (ans+MOD)%MOD << endl;

    return 0;
}

Measured memory_bytes: 11132
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr
#include <cstring>
#include <cmath>

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

#define _LIBCPP_DEBUG 0
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

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

	if (a > 0 && b > 0) cout << "Positive" << endl;
	else if (a <= 0 && b >= 0) cout << "Zero" << endl;
	else if (a < 0 && b < 0) {
		if ((abs(b)-abs(a)+1) % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
# numpy version

import numpy as np

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.zeros(n)

for i in range(1,n): 
    j = max(0, i-k)
    dp[i] = np.min(dp[j:i] + np.abs(h[i] - h[j:i]))

print(int(dp[-1]))


Measured memory_bytes: 22788
#include <vector>
#include <complex>
#include <cstdio>
#include <cassert>
#include <cmath>
using namespace std;

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

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P vec(const L& l) {
  return l[1]-l[0];
}

int main(){
	int T,x1,y1,x2,y2;
	for(scanf("%d",&T);T--;){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		L A(P(x1,y1),P(x2,y2));
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		L B(P(x1,y1),P(x2,y2));
		if(abs(dot(vec(A),vec(B)))<EPS)puts("1");
		else if(abs(cross(vec(A),vec(B)))<EPS)puts("2");
		else puts("0");
	}
}

Measured memory_bytes: 1020
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int[] A = new int[N];
	static int[] B = new int[N];
	static Pair[] D = new Pair[N];
	static class Pair{
		public int first;
		public int second;
		public Pair(int first, int second) {
			this.first = first;
			this.second = second;
		}
	}
	static class TheComparatorPair implements Comparator<Object> {
		public int compare(Object a0, Object b0) {
			Pair a = (Pair)a0;
			Pair b = (Pair)b0;

			if(a.first + a.second > b.first + b.second) {
				return -1;
			} else if(a.first + a.second < b.first + b.second) {
				return 1;
			} else {
				return 0;
			}
//			if(Math.abs(a.first - a.second) > Math.abs(b.first - b.second)) {
//				return 1;
//			} else if(Math.abs(a.first - a.second) < Math.abs(b.first - b.second)) {
//				return -1;
//			} else {
//				return 0;
//			}
		}
	}
	public static void main(String[] args) {
//		List<Pair<Integer, Integer>> list = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(sc.next());
			B[i] = Integer.parseInt(sc.next());
//			list.add(new Pair<Integer, Integer>(A[i], B[i]));
//			D[i] = A[i] - B[i];
			D[i] = new Pair(A[i], B[i]);
		}
//		list.stream().sorted(Comparator.comparingInt(i, ))
		TheComparatorPair c = new TheComparatorPair();
		long ans = 0;
		Arrays.sort(D, c);
		for (int i = 0; i < N; i++) {
			if (i%2 == 0) {
				ans += D[i].first;

			} else {
				ans -= D[i].second;
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;


vector<int> V;
int main(){
    int cnt=0;
    for(int i=2;i<=30000;++i){
        if(i%2==0 || i%3==0 ){
            if(i%6)
            V.push_back(i);
        }
    }
    int n;cin >> n;
    if(n>=15000){
        for(int i=2;i<=30000,V.size()<n;++i){
            if(i%6==0){
                V.push_back(i);
            }
        }
        for(int i=0;i<V.size();++i) cout << V[i] << " ";
        cout << endl;
    }
    else{
        if(n==3){
            cout << "2 5 63" << endl;return 0;
        }
        V.clear();
        V.push_back(3);V.push_back(9);
        for(int i=2;i<=30000;i+=6){
            if(V.size()+2>n){
                break;
            }
            V.push_back(i);V.push_back(i+2);
        }
        if(V.size()+1==n){
            V.push_back(6);
            for(int i=0;i<V.size();++i) cout << V[i] << " ";
            cout << endl;

        }
        else if(V.size()==n){
            for(int i=0;i<V.size();++i) cout << V[i] << " ";
            cout << endl;
        }
        else{
                int u=6;
            while(V.size()!=n){
                V.push_back(u);u+=6;
            }
            for(int i=0;i<V.size();++i) cout << V[i] << " ";
            cout << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 512
s = input()
K = int(input())

s_sub = list([''])
s_len = len(s)
for i in range(s_len):
    s_sub.append(s[i:])

s_sub.sort()

sum = 0
for j in range(1,s_len+2):
    
    current = s_sub[j]
    before = s_sub[j-1]

    z = 0
    for k in range(min(len(current),len(before))):
        if current[k] == before[k]:
            z+=1
        else:
            break  
            
    pre = sum +len(current) - z
    if pre >= K:
        print(current[:K-sum+z])
        break
    sum = pre



Measured memory_bytes: 15604
#include<bits/stdc++.h>
using namespace std;
char ss[20][1100];
int num[20][1100];
int c[20];
int main()
{
	int h,w,knum;
	cin>>h>>w>>knum;
	getchar();
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		scanf("%c",&ss[i][j]);
		getchar();
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			num[i][j]=num[i-1][j]+num[i][j-1]-num[i-1][j-1];
			if(ss[i][j]=='1')num[i][j]++;
		}
	}
	for(int i=1;i<=w;i++)
	num[h+1][i]=num[h][i];
		/*for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		cout<<num[i][j];
		cout<<endl;
	}*/
	int ans=h*w;
	for(int i=0;i<pow(2,h);i++)
	{
		int prinum=i;string s="";
		while(prinum)
		{
			s+=prinum%2+'0';
			prinum/=2;
		}
		reverse(s.begin(),s.end());
		string s1="";
		if(s.length()<h)
		for(int j=1;j<=h-s.length();j++)s1+='0';
		s=s1+s;
		//cout<<s<<endl;
		int cnt=0;c[cnt]=0;
		for(int j=0;j<s.length();j++)
		{
			if(s[j]=='1')cnt++,c[cnt]=j+1;
		}
		c[++cnt]=h+1;
	//	for(int j=0;j<=cnt;j++)cout<<c[j];
	//	cout<<endl;
		   int left=0;bool allflag=true;int cout=0;
              for(int j=1;j<=w;j++)
              {
              	bool f=true;
              	for(int k=1;k<=cnt;k++)
              	{
              		int x;int y=left;int x2=c[k];
              		int sumw=num[x2][j]-num[c[k-1]][j]-num[c[k]][left]+num[c[k-1]][left];
              		if(sumw>knum)f=false;
              		if(!f)break;
				  }			
				   if(!f)
				  {   
				  left=j-1;bool f2=true;
				  for(int k=1;k<=cnt;k++)
              	{
              		int x=c[k]-c[k-1];int y=left;
              		int sumw=num[c[k]][j]-num[c[k-1]][j]-num[c[k]][left]+num[c[k-1]][left];
              		if(sumw>knum)f2=false;
              		if(!f2)break;
				  }
				  if(!f2)
				  {
				  	allflag=false;
				  	break;
				  }
				  else
				  {cout++;
				  continue;}
			}
			  }
			  if(allflag)
			  {
			  	ans=min(ans,cout+cnt-2);
			  }		
	}
	cout<<ans+1<<endl;	
	return 0;
}

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

const int maxn = 1e2 + 5;
using namespace std;
char ss[maxn];

int main()
{
	cin >> ss;
	int s = 0;
	for (int i = 0; i < 3; i++)
		if (ss[i] == '1')
			s++;
	cout << s << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

ll MOD_N = 1e9 + 7;


int main() {
    int N, M;
    cin >> N >> M;
    int S[N];
    int T[M];
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> T[i];
    }
    ll sums[N][M];
    sums[0][0] = (S[0] == T[0]) ? 1 : 0;
    for (int i = 1; i < N; ++i) {
        ll c = (S[i] == T[0]) ? 1 : 0;
        sums[i][0] = sums[i-1][0] + c;
    }
    for (int j = 1; j < M; ++j) {
        ll c = (S[0] == T[j]) ? 1 : 0;
        sums[0][j] = sums[0][j-1] + c;
    }
    for (int i = 1; i < N; ++i) {
        for (int j = 1; j < M; ++j) {
            ll count, sum;
            if (S[i] == T[j]) {
                count = (sums[i-1][j-1] + 1) % MOD_N;
            } else {
                count = 0;
            }
            sum = sums[i-1][j] + sums[i][j-1] - sums[i-1][j-1] + count;
            sums[i][j] = (sum + MOD_N) % MOD_N;
        }
    }
    ll ans = (sums[N-1][M-1] + 1) % MOD_N;
    cout << ans << "\n";
    return 0;
}


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

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

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


Measured memory_bytes: 256
a,b,c = gets.split.map(&:to_i)
if a <= b && b <= c
  puts "#{a} #{b} #{c}"
elsif a <= c && c <= b
  puts "#{a} #{c} #{b}"
elsif b <= a && a <= c
  puts "#{b} #{a} #{c}"
elsif b <= c && c <= a
  puts "#{b} #{c} #{a}"
elsif c <= a && a <= b
  puts "#{c} #{a} #{b}"
elsif c <= b && b <= a
  puts "#{c} #{b} #{a}"
end

Measured memory_bytes: 8736
import scala.util.control.Breaks._

object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val y = sc.nextInt

    var ans = (-1, -1, -1)
    breakable {
      val r = 0 to n
      for (i <- r; j <- r;
           if i + j <= n && 10000*i + 5000*j + 1000*(n - i - j)  == y) {
        ans = (i, j, n - i - j)
        break
      }
    }
    println(ans match {case (i, j, k) => s"$i $j $k"})
  }
}


Measured memory_bytes: 48896
using System;

namespace AOJ
{
    class Program
    {
        
        static void Main(string[] args)
        {
            string text,order;
            int order_value;

            //??????????????????????????????
            var read_text = Console.ReadLine();
            text = read_text;

            //????????°??????
            read_text = Console.ReadLine();
            order_value = int.Parse(read_text);


            for(int i=0;i<order_value;i++)
            {
                read_text = Console.ReadLine();
                var temp_arry = read_text.Split(' ');

                //????????????????????????
                int a = int.Parse(temp_arry[1]), b = int.Parse(temp_arry[2]);

                order=temp_arry[0];
                switch(order)
                {
                    case "print":
                        {
                            Console.WriteLine(rang_Extraction(text,a,b));
                            break;
                        }
                    case"reverse":
                        {

                            var char_arry =rang_Extraction(text,a,b).ToCharArray();
                            Array.Reverse(char_arry);
                            text=text.Remove(text.IndexOf(rang_Extraction(text, a, b), a),char_arry.Length);
                            text=text.Insert(a ,new string(char_arry));

                            break;
                        }
                    case "replace":
                        {
                            string temp= rang_Extraction(text, a, b);

                            text = text.Remove(text.IndexOf(temp, a),temp.Length);
                            text = text.Insert(a, temp_arry[3]);
                            break;
                        }

                }
            }
        }

        static string rang_Extraction(string s, int a, int b)
        {
            string temp = "";

            for (int j = a; j < b + 1; j++)
            {
                temp += s.Substring(j, 1);
            }

            return temp;
        }
    }
}

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

int main() {
  int n;
  cin >>n;
  ll total = 0;
  vector<ll> a(n);
  rep(i,n) {
    cin>>a[i];
    total += a[i];
  }
  ll minx = total, sum = 0;
  rep(i,n){
    sum += a[i];
    minx = min(minx, abs(sum-(total-sum)));
  }
  cout << minx << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9



int main(){ 
  int N;
  cin >> N;
  int x = 0;
  bool flag = false;
  while(x*(x+1) <= 2*N){
    if(x*(x+1) == 2*N){
      flag = true;
      break;
    }
    x++;
  }
  if(!flag){
    cout << "No" << endl;
    // assert(0);
    return 0;
  }
  vector<vector<int>> ans(x+1);
  int begin = 0;
  REP(i, x){
    // cout << "begin:" << begin << endl;
    REP(j, x-i){
      ans[i].push_back(begin +j+1);
      ans[i+j+1].push_back(begin + j+ 1);
    }
    begin += x-i;
  }
  cout << "Yes" << endl;
  cout << x+1 << endl;
  REP(i, x+1){
    cout << x;
    REP(j, x){
      cout << " " << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 2304
def left_p(i)
  2 * i
end
def right_p(i)
  2 * i + 1
end
def parent_p(i)
  i / 2
end

def max_heapfy(arr, i)
  l = left_p(i)
  r = right_p(i)

  if l <= arr.size && arr[l - 1] > arr[i - 1]
    largest = l
  else
    largest = i
  end

  if r <= arr.size && arr[r - 1] > arr[largest - 1]
    largest = r
  end

  if largest != i
    tmp = arr[largest - 1]
    arr[largest - 1] = arr[i - 1]
    arr[i - 1] = tmp
    max_heapfy(arr, largest)
  end
end

def build_max_heap(arr)
  i = arr.size / 2 + 1
  while i > 0
    max_heapfy(arr, i)
    i = i - 1
  end
end


n = STDIN.gets.to_i
arr = STDIN.gets.split(' ').map { |x| x.to_i }

build_max_heap(arr)
puts ' ' + arr.join(' ')

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

vector<vector<ll> >V;
ll c=0;
vector<vector<ll> >ans;
void dfs(ll x){
  if(ans[x].size()!=0)return;
  c++;
  ans[x].push_back(c);

  rep(i,0,V[x].size()){
    dfs(V[x][i]);
  }
  c++;
  ans[x].push_back(c);
}

int main(){

  ll n;cin>>n;
  V.resize(n);
  ans.resize(n);
  rep(i,0,n){
    ll u;cin>>u;
    --u;
    ll k;cin>>k;
    rep(j,0,k){
      ll a;cin>>a;
      --a;
      V[u].push_back(a);

    }
  }
  rep(i,0,n){
    dfs(i);
  }

  rep(i,0,n)out(i+1<<" "<<ans[i][0]<<" "<<ans[i][1]);






  return 0;
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define w(x)            int x; cin>>x; while(x--)
#define fr(i,a,b)       for(int i = a; i < b; i++)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void frog(int *arr, int n, int k)
{
	int dp[n] = {};

	fr(i, 1, n)
	{
		dp[i] = INT_MAX;
		for (int j = i - 1; j >= 0 and (i - j) <= k; j--)
		{
			dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);
		}
	}

	cout << dp[n - 1] << endl;
	return;
}

void solve()
{
	int n, k;
	cin >> n >> k;
	int arr[n] = {};
	fr(i, 0, n)
	cin >> arr[i];

	frog(arr, n, k);
	return;
}

int32_t main()
{
	c_p_c();
	solve();
	return 0;
}

Measured memory_bytes: 5172
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>


using namespace std;

const int N = 5000 + 5;
long long dp[N][N];
int p[N];
int a;
int b;
int n;
 
int main () 
{
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i];
    }
    memset(dp, 127, sizeof dp);
    dp[0][0] = 0;
    for (int i = 1;i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            if(p[i] > j)
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + a);
                dp[i][p[i]] = min(dp[i][p[i]],dp[i-1][j]);
            }
            else
            {
                dp[i][j] = min(dp[i][j],dp[i-1][j] + b);
            }
        }
    }
    long long ans = dp[n][1];
    for (int i = 1; i <= n; i++)
    {
        ans = min(ans, dp[n][i]);
    }
    cout << ans << endl;
}




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

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}

int main()
{
    stringstream ss;
    // 入力
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(abs(a-c)<=d) cout<<"Yes"<<endl;
    else if(abs(a-b)<=d && abs(b-c)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using std::cin,std::cout;
using std::string;
int count(string p0,char p1){
  return std::count(p0.begin(),p0.end(),p1);
}

int main(){
  int n,r=0,m=0;
  string s;
  cin>>n>>s;
  cout<<count(
    s.substr(0,count(s,'R')),
    'W'
  );
  return 0;
}

Measured memory_bytes: 3900
using System;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var ans = 20;

            for(long a = 1; a <= Math.Sqrt(n); a++)
            {
                if (n % a != 0)
                {
                    continue;
                }
                else
                {
                    var b = n / a;
                    if(F(a,b) < ans)
                    {
                        ans = F(a, b);
                    }
                }
            }
            Console.WriteLine(ans);
        }

        public static int F(long a, long b)
        {
            return Math.Max(DigitFinder(a), DigitFinder(b));
        } 

        public static int DigitFinder(long x)
        {
            var digit = 0;
            while(x > 0)
            {
                x /= 10;
                digit++;
            }

            return digit;
        }
    }
}

Measured memory_bytes: 27428
import java.util.Scanner;

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

    int D = scanner.nextInt();
    int N = scanner.nextInt();
    int cnt = 0;
    for (int i = 1; i <= 2000000; i++) {
      if (count(i) == D) cnt++;
      if (cnt == N) {
        System.out.println(i);
        return;
      }
    }
  }

  private static int count(int n) {
    int cnt = 0;
    while (n % 100 == 0) {
      cnt++;
      n /= 100;
    }
    return cnt;
  }
}


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

int main(){
	long long q,h,s,d,n;
	cin >> q >> h >> s >> d >> n;
	
	int twoliter = min(min(8*q,4*h),min(2*s,d));
	int liter = min(min(4*q,2*h),s);
	if ( n == 1) cout << liter;
	else {
		if (liter*2 < twoliter){
			cout << n * liter;
		}
		else{
			if (n%2==1){
				cout << n/2*twoliter + liter;
			}
			else cout << n/2*twoliter;
		}
	}
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  vc c(4);
  cin >> c[0] >> c[1] >> c[2] >> c[3];
  vi a = {c[0] - '0', c[1] - '0', c[2] - '0', c[3] - '0'};
  rep(i, 1 << 3) {
    int sum = a[0];
    string ans = "";
    ans += c[0];
    rep(j, 3) {
      if(i >> j & 1) {
        sum += a[j + 1];
        ans += "+";
        ans += c[j + 1];
      } else {
        sum -= a[j + 1];
        ans += "-";
        ans += c[j + 1];
      }
    }
    if(sum == 7) {
      cout << ans << "=7" << endl;
      return 0;
    }
  }
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

typedef pair<int, int> P;
typedef pair<P, P> Beni;

int w, h, n;
vector<Beni> benis;
map<int, int> zip_x, zip_y;
int unzip_x[1000001];
int unzip_y[1000001];

pii compress() {
  vector<int> x, y;

  int benis_size = benis.size();
  for (int i = 0; i < benis_size; i++) {
    x.push_back(benis[i].first.first);
    x.push_back(benis[i].second.first);
    y.push_back(benis[i].first.second);
    y.push_back(benis[i].second.second);
  }

  x.push_back(0);
  x.push_back(w);

  y.push_back(0);
  y.push_back(h);

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  x.erase(unique(x.begin(), x.end()), x.end());
  y.erase(unique(y.begin(), y.end()), y.end());

  int x_size = x.size();
  int y_size = y.size();

  for (int i = 0; i < x_size; i++) {
    zip_x[x[i]] = i;
    unzip_x[i] = x[i];
  }

  for (int i = 0; i < y_size; i++) {
    zip_y[y[i]] = i;
    unzip_y[i] = y[i];
  }

  return pii(x_size, y_size);
}

void dfs(int x, int y, int x_size, int y_size, vector<vector<char>> &mp) {
  mp[y][x] = 1;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (0 <= nx && nx < x_size && 0 <= ny && ny < y_size && mp[ny][nx] == 0)
      dfs(nx, ny, x_size, y_size, mp);
  }
}

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

  while (cin >> w >> h, w || h) {
    cin >> n;
    benis.clear();

    for (int i = 0; i < n; i++) {
      P bl, tr;
      cin >> bl.first >> bl.second >> tr.first >> tr.second;
      benis.push_back(Beni(bl, tr));
    }

    pii res = compress();

    // from coordinate to cell
    int x_size = res.first - 1;
    int y_size = res.second - 1;

    vector<vector<char>> mp(y_size, vector<char>(x_size, 0));

    for (auto beni : benis) {
      P bl = beni.first;
      P tr = beni.second;
      for (int x = zip_x[bl.first]; x <= zip_x[tr.first] - 1; x++) {
        for (int y = zip_y[bl.second]; y <= zip_y[tr.second] - 1; y++) {
          mp[y][x] = 1;
        }
      }
    }

    int ans = 0;
    for (int x = 0; x < x_size; x++) {
      for (int y = 0; y < y_size; y++) {
        if (mp[y][x] == 1) continue;
        dfs(x, y, x_size, y_size, mp);
        ans++;
      }
    }

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

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

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
          
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  5e5+5;
const ll   mod   =  998244353;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n, q, a[N], s = 0;

void solve(){
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i], s ^= a[i];
    for(int i = 0; i < n; i++) cout<<(a[i]^s)<<" ";
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

Measured memory_bytes: 5152
N, M = map(int, input().split())
LR = [tuple(map(int, input().split())) for _ in range(M)]

L = 1
R = 10**5

for i in range (M):
    l = LR[i][0]
    r = LR[i][1]

    if l > L:
        L = l
    if r < R:
        R = r

print(len(range(L, R+1)))

Measured memory_bytes: 22320
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

ll MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  map<ll, ll> map;
  // N!の素因数分解
  map[2] = 1;
  map[3] = 1;
  for (ll i = 4; i <= N; i++) {
    ll remaining = i;
    for (ll j = 2; j <= i; j++) {
      if (remaining % j == 0) {
        // 指数を求める
        ll n = 0;
        while (remaining % j == 0) {
          n++;
          remaining /= j;
        }
        // cout << j << '^' << n << endl;
        map[j] += n;
      }
    }
    // cout << "---" << endl;
  }
  vector<ll> counter(5, 0);
  // 74 24 14 4 2
  for (auto it = map.begin(); it != map.end(); ++it) {
    // cout << it->first << ' ' << it->second << endl;
    if (it->second >= 74) {
      counter[0]++;
    }
    if (it->second >= 24) {
      counter[1]++;
    }
    if (it->second >= 14) {
      counter[2]++;
    }
    if (it->second >= 4) {
      counter[3]++;
    }
    if (it->second >= 2) {
      counter[4]++;
    }
  }

  // p^74
  ll ans = counter[0];
  // p^14q^4
  ans += counter[2] * (counter[3]-1);
  // p^24q^2
  ans += counter[1] * (counter[4] - 1);
  // p^2p^4r^4
  ans += (counter[3] * (counter[3] - 1) / 2) * (counter[4] - 2);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define loop(var,time) for (var = 0; var < (time); var++)
int balls[10];

bool dfs(int right, int left, int index) {\
    if (index == 10) { return true; }
    if (balls[index] > right) {
        if (dfs(balls[index], left, index + 1)) { return true; }
    }
    if (balls[index] > left) {
        if (dfs(right, balls[index], index + 1)) { return true; }
    }
    return false;
}

int main() {
    int n;
    int tmp,i;
    scanf("%d", &n);
    loop(tmp, n) {
        loop(i,10) {
            scanf("%d", &balls[i]);
        }
        if (dfs(0,0,0)) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
}

Measured memory_bytes: 1008
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
#define int long long

typedef vector<int> vi;		typedef vector<ll> vl;
typedef pair<int, int> ii; 	typedef vector<ii> vii;

// code start here //



signed main() {
	fastio;
	int n; cin >> n;
	int up[n], down[n];
	rep(i, 0, n) cin >> up[i];
	rep(i, 0, n) cin >> down[i];
	int pre[n + 1], suf[n + 1];
	pre[0] = 0; suf[0] = 0;
	rep(i, 1, n + 1) {
		pre[i] = pre[i - 1] + up[i - 1];
		suf[i] = suf[i - 1] + down[n - i];
	} 
	int Max = 0;
	rep(i, 1, n + 1) {
		Max = max(Max, pre[i] + suf[n + 1 - i]);
	}
	cout << Max << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;

int n, k;
vector<vector<int>> g;

int cnt(int cur, int prev)
{
    // cout << cur << ", " << prev << endl;

    int ret = 1;
    for (auto &n: g[cur]) {
        if (n == prev) continue;
        ret += cnt(n, cur);
    }
    return ret;
}

int solve(int cur, int prev, int dep)
{
    // cout << cur << ", " << prev << ", " << dep << endl;

    if (dep <= 0) {
        return cnt(cur, prev);
    }

    int ans = 0;

    for (int i = 0; i < g[cur].size(); i++) {
        if (g[cur][i] == prev) continue;
        ans += solve(g[cur][i], cur, dep - 1);
    }

    return ans;
}

int main()
{
    cin >> n >> k;
    g.resize(n);

    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        a--, b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = n + 1;

    for (int center = 0; center < n; center++) {
        for (auto lng: g[center]) {
            int tmp = 0;
            for (auto root: g[center]) {
                tmp += solve(root, center, k / 2 + ((k % 2 == 1 && lng == root) ? 1 : 0));
            }
            // cout << center + 1 << " -> " << lng + 1 << ": " << tmp << endl;
            ans = min(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

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

    int D[C+10][C+10];
    rep(i,C) rep(j,C) cin >> D[i][j];

    int c[N+10][N+10];
    rep(i,N) rep(j,N)
    {
        cin >> c[i][j];
        c[i][j]--;
    }

    int A[3][C+10];
    rep(i,3) rep(j,C) A[i][j] = 0;

    rep(i,N) rep(j,N) A[(i+j)%3][c[i][j]]++;

    ll ans = INF;
    rep(i,C) rep(j,C) rep(k,C)
    {
        if (i==j || j==k || k==i) continue;

        ll nans = 0;

        rep(d,C) nans += A[0][d] * D[d][i];
        rep(d,C) nans += A[1][d] * D[d][j];
        rep(d,C) nans += A[2][d] * D[d][k];

        ans = min(ans,nans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <cctype>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    int N;
    int W[110];
    cin >> N;
    rep(i, 0, N)
    {
        cin >> W[i];
    }
    int min = 1000000;
    rep(t, 1, N + 1)
    {
        int ika = 0;
        int yori = 0;
        rep(i, 0, N)
        {
            if (i + 1 > t)
            {
                yori += W[i];
            }
            else
            {
                ika += W[i];
            }
        }
        if (min > abs(yori - ika))
        {
            min = abs(yori - ika);
        }
    }
    cout << min << endl;
}

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

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int x[N + 1];
	x[N] = X;
	for(int i = 0; i < N; i++) cin >> x[i];
	int y[M + 1];
	y[M] = Y;
	for(int i = 0; i < M; i++) cin >> y[i];
	int xmax, ymin;
	for(int i = 0; i < N + 1; i++) if(i == 0 || x[i] > xmax) xmax = x[i];
	for(int i = 0; i < M + 1; i++) if(i == 0 || y[i] < ymin) ymin = y[i];
	if(xmax < ymin) cout << "No War";
	else cout << "War";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i / 60 - h * 60;
   s = i % 60;
   
   cout << h << ":" << m << ":" << s <<  endl; 
   
   return 0;
}


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

const bool DEBUG = false;

vector<long long> trial_division(const long long& num) {
  if (num == 1) {
    return vector<long long>();
  }
  long long result = num;
  for (long long i = 2, m = (long long)sqrt(num); i <= m; ++i) {
    if (num % i == 0) {
      result = i;
      break;
    }
  }
  if (result == num) {
    return {num};
  } else {
    vector<long long> primes_1 = {result};
    vector<long long> primes_2 = trial_division(num / result);
    primes_1.insert(primes_1.end(), primes_2.begin(), primes_2.end());
    return primes_1;
  }
}

long long get_maximum(const long long num) {
  long long result = num;
  for (long long i = 2, m = (long long)sqrt(num); i <= m; ++i) {
    if (num % i == 0) {
      result = i;
    }
  }
  return result;
}

int main(int argc, char const* argv[]) {
  long long N;
  cin >> N;

  long long maximum_val = get_maximum(N);
  cout << maximum_val + N / maximum_val - 2 << endl;

  // vector<long long> factors = trial_division(N);

  // if (factors.size() == 1) {
  //   cout << factors[0] - 1 << endl;
  //   return 0;
  // }

  // // reverse(factors.begin(), factors.end());

  // long long left = 1, right = 1;
  // for (auto&& elem : factors) {
  //   if (left < right)
  //     left *= elem;
  //   else
  //     right *= elem;
  // }

  // cout << left + right - 2 << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit(0)
ans = 1
for i in range(N):
   ans = ans*A[i]
   if 10**18 < ans:
    print(-1)    
    exit(0)

print(ans)

Measured memory_bytes: 21640
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int x,y;
    R(x,y);
    W(x*y/2);
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

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

struct edge {int from, to, cost; };

void solve(){
    int n;
    ll res[5], cc=0;
    rep(i, 5) res[i] = 0;
    cin >> n;
    string s[n];
    rep(i, n){
        cin >> s[i];
        if(s[i][0] == 'M'){
            res[0]++;
        }else if(s[i][0] == 'A'){
            res[1]++;
        }else if(s[i][0] == 'R'){
            res[2]++;
        }else if(s[i][0] == 'C'){
            res[3]++;
        }else if(s[i][0] == 'H'){
            res[4]++;
        }
    }
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            for(int k = j+1; k < 5; k++){
                cc += res[i]*res[j]*res[k];
            }
        }
    }
    cout << cc << endl;
}

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


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
string S;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> S;
	for (int i = 0; i < S.length(); i++)
	{
		cout << "x";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){

  int q;
  vector <int> a;
  cin>>q;
  for(int i=0;i<q;i++){
    int b;
    cin>>b;
    if(b==2) a.pop_back();
    else if (b){
      int p;
      cin>>p;
      cout<<a[p]<<endl;
    }
    else{
      int x;
      cin>>x;
      a.push_back(x);
    }
  }
  return 0;

}



Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}

void chmin(int &a, int &b){if (a>b){a = b; return;}return;}
void chmax(int &a, int &b){if (a<b){a = b; return;}return;}


const ll MOD = 1000000007;
const ll INF = 9999999999;

int main() {
  int n; cin >>n;
  vector<int> h(n);
  for (int i=0; i<n; i++) cin >>h.at(i);
  vector<int> dp(n+2, 1500000000);
  dp.at(0) = 0;
  for (int i=0; i<n-1; i++){
    chmin(dp.at(i+1), dp.at(i) + abs(h.at(i) - h.at(i+1)));
    if (i==n-2) break;
    chmin(dp.at(i+2), dp.at(i) + abs(h.at(i) - h.at(i+2)));
  }
  cout <<dp.at(n-1) <<endl;
}

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

using namespace std;

struct Dice
{
    int s[7];
    void roll(char c)
    {
        int tmp;
        if (c == 'E')
        {
            tmp = s[1];
            s[1] = s[4];
            s[4] = s[6];
            s[6] = s[3];
            s[3] = tmp;
        }
        if (c == 'W')
        {
            tmp = s[1];
            s[1] = s[3];
            s[3] = s[6];
            s[6] = s[4];
            s[4] = tmp;
        }
        if (c == 'N')
        {
            tmp = s[1];
            s[1] = s[2];
            s[2] = s[6];
            s[6] = s[5];
            s[5] = tmp;
        }
        if (c == 'S')
        {
            tmp = s[1];
            s[1] = s[5];
            s[5] = s[6];
            s[6] = s[2];
            s[2] = tmp;
        }
        if (c == 'R')
        {
            tmp = s[3];
            s[3] = s[2];
            s[2] = s[4];
            s[4] = s[5];
            s[5] = tmp;
        }
    }
};

bool same(Dice d1, Dice d2)
{
    for (int i = 1; i < 7; i++)
    {
        if (d1.s[i] != d2.s[i])
            return false;
    }
    return true;
}
int main()
{
    Dice d[1000];
    bool f[1000];

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        f[i] = false;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= 6; j++)
        {
            scanf("%d", &d[i].s[j]);
        }
    }
    for (int k = 1; k < n; k++)
    {
        for (int i = 0; i < 4; i++)
        {
            d[k].roll('N');
            for (int j = 0; j < 4; j++)
            {
                d[k].roll('R');
                if (same(d[0], d[k]))
                {
                    f[k] = true;
                }
            }
        }
    }
    for (int k = 1; k < n; k++)
    {
        d[k].roll('E');
    }
    for (int k = 1; k < n; k++)
    {
        for (int i = 0; i < 4; i++)
        {
            d[k].roll('R');
            if (same(d[0], d[k]))
            {
                f[k] = true;
            }
        }
    }
    for (int k = 1; k < n; k++)
    {
        d[k].roll('W');
        d[k].roll('W');
    }
    for (int k = 1; k < n; k++)
    {
        for (int i = 0; i < 4; i++)
        {
            d[k].roll('R');
            if (same(d[0], d[k]))
            {
                f[k] = true;
            }
        }
    }
    for(int k =1;k<n;k++){
        if(f[k]==true){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
}


Measured memory_bytes: 3172
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ar = new int[n];
        int cnt = 0;
        boolean f = true;
        for (int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
            if((ar[i]- 1) != i){
                cnt++;
            }
        }
        if(cnt == 0 || cnt == 2){
            f = true;
        }else{
            f = false;
        }
        io.YESNO(f);
    }
}

class io{

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }
}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<fstream>
#include<queue>
#include<vector>
#include<cstring>
#define MAX 20
#define INF 10000000

using namespace std;



int main(){
	int A[MAX];
	int B = 0;
	int C = 0;
	int n;
	cin >> n;
	while(n--){
		int i;
		B = 0;
		C = 0;
		for(i=0; i<10; i++)
			cin >> A[i];
		for(i=0; i<10; i++){
			if(A[i] > B){
				B = A[i];
				continue;
			}
			if(A[i] > C){
				C = A[i];
				continue;
			}
			else{
				cout << "NO" << endl;
				break;
			}
		}
		if(i == 10)
			cout << "YES" << endl;
	}
	return 0;
} 


Measured memory_bytes: 3096
import sys


def main(S):
    pass


if __name__ == '__main__':
    #n, r = map(int, input().split())
    n = int(input())
    x = list(map(int, input().split()))

    m = int(sum(x) / n)

    ans = 10000000000
    for i in range(4):
        tmp = 0
        for j in range(n):
            tmp += pow((x[j] - (m - 1 + i)), 2)
        ans = min(ans, tmp)

    print(ans)


Measured memory_bytes: 3060
import math

while True:
    n = int(input())
    if n == 0 :
        break
    nums = [int(x) for x in input().split(" ")]
    mean = sum(nums) / n

    variance = sum([(x - mean) ** 2 for x in nums]) / n
    std = math.sqrt(variance)
    print(std)

Measured memory_bytes: 7760
n = int(input())
a_l = list(map(int,input().split()))

a_l_dict = {}
for val in a_l:
    a_l_dict[val] = 0
for val in a_l:
    a_l_dict[val] += 1

ans = 0
for key in a_l_dict.keys():
    ans = max(ans, a_l_dict[key] + a_l_dict.get(key-1,0) + a_l_dict.get(key+1,0))

print(ans)

Measured memory_bytes: 14180
#input
N = int(input())
a = list(map(int, input().split()))

#output
import numpy as np
a = np.array(a)
a = a[a % 2 == 0]

def square_power(n, p):
    if n % 2**p == 0:
        return True
    else:
        return False

def is_possible(n):
    left = -1
    right = 30
    while left + 1 < right:
        mid = (left+right)//2
        if square_power(n, mid):
            left = mid
        else:
            right = mid
    return left

answer = 0
for b in a:
    answer += is_possible(b)

print(answer)

Measured memory_bytes: 14352