akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mx 1000000007
#define ll long long int

using namespace std;

double dp[3000][3000]={0},one=1,two=2;
ll nn;

double solve(double p[],ll n,ll h){
	if(dp[n][h]>=0)
		return dp[n][h] ;
    if(n==0 && h<(nn+1)/2){
        return dp[n][h]=0;
    }
    if(n==0)
        return dp[n][h]=1;
    dp[n][h]= p[n]*solve(p,n-1,h+1)+ (1-p[n])*solve(p,n-1,h);
    return dp[n][h];
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	memset(dp,-1,sizeof(dp));
	cin>> nn;
	double p[nn+1];
	for(ll i=1;i<=nn;++i)
        cin>> p[i] ;
    double ans=solve(p,nn,0);
    cout<< fixed << setprecision(12) <<  ans ;
	return 0;
}


Measured memory_bytes: 74360
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

    vector<int> A;
    for (int i = 0; i < M; ++i) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    int cost0 = 0;
    for (int i = 0; i < A.size(); ++i) {
        if (A[i] >= X) break;
        cost0 += 1;
    }
    int costn = 0;
    for (int i = 0; i < A.size(); ++i) {
        if (A[i] <= X) continue;
        ++costn;
    }
    cout << min(cost0, costn) << endl;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vector<double> p(N);
  REP(i,N) IN(p[i]);

  vector<double> dp(N+1, 0.0);
  vector<double> dp_copy;
  dp[0] = 1-p[0];
  dp[1] = p[0];

  FOR(i,1,N){
    dp_copy = dp;
    REP(j,N+1){
      dp[j] = dp_copy[j]*(1-p[i]);
       if(j) dp[j] += dp_copy[j-1]*p[i];
    }
  }

  double ans = 0.0;
  FOR(i,(N+2)/2,N+1) ans += dp[i];
  printf("%.12lf\n", ans);

  return 0;
}

Measured memory_bytes: 384
n=int(input())
dam=list(map(int,input().split()))
plus_mainas=-1
x=dam[0]
ans_list=[0]
for i in range(n-1,0,-1):
  x+=plus_mainas*dam[i]
  plus_mainas*=-1
ans_list.append(x)

for i in range(1,n):
  ans_list.append(dam[i]*2-ans_list[i])

print(*([ans_list[-1]]+ans_list[1:-1]))

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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back



vi delSpace(vi data){
    vi ret;
    
    rep(i,data.size()){
        if(data[i]!=0)ret.pb(data[i]);
    }
    return ret;
}


bool isOK(vi data){
    if(data[0]!=1)return false;
    for(int i=1;i<data.size();i++){
        if(data[i]!=data[i-1]+1)return false;
    }
    return true;
}


int main(){
    int n;
    while(cin>>n){
        int ans=0;
        vi data;

        if(n==0)break;
        
        rep(i,n){int a; cin>>a; data.pb(a);}
        
        while(true){
            if( isOK(data) || ans>10000 )break;
            
            rep(i,data.size()){
                data[i]--;
            }
            data.pb(data.size());
            
            data=delSpace(data);
            ans++;

        }
        
        if(ans>10000)cout<<"-1"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    char x, y;
    cin >>x>>y;
    if (x>y) cout << ">" << endl; 
    else if (x==y) cout << "=" << endl;
    else cout << "<" << endl;
    return 0;
}


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

void fnPrimeNumber(const vector<int>& cnrvnNum, int& rnPrmCnt)
{
  for (int i = 0; i < cnrvnNum.size(); i++)
  {
    bool bPrmNo = true;
    double dSqrt = sqrt((double)cnrvnNum[i]);
    int iMaxDiv = (int)dSqrt;

    for (int nDiv = 2; nDiv <= iMaxDiv; nDiv++)
    {
      if (cnrvnNum[i] % nDiv == 0)
      {
        bPrmNo = false;
        break;
      }
    }
    if (bPrmNo) rnPrmCnt++;
  }
}

int main()
{
  vector<int> vnNum;
  int nMaxSiz;
  int nPrmCnt = 0;
  
  cin >> nMaxSiz;
  for (int i = 0; i < nMaxSiz; i++)
  {
    int nNum;
    cin >> nNum;
    vnNum.push_back(nNum);
  }

  fnPrimeNumber(vnNum, nPrmCnt);
  cout << nPrmCnt << endl;

  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 10000000000
using namespace std;
using P = pair<long, long>;

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
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 first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
void test_case() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> pos(255);
  for (int i = 0; i < (int) s.size(); ++i) {
    pos[s[i]].emplace_back(i);
  }
  long long res = 0;
  int left = s.size(), ctr = -1;
  for (int i = 0; i < (int) t.size(); ++i) {
    if (pos[t[i]].size() == 0) {
      cout << "-1\n";
      return;
    }
    int ind = upper_bound(pos[t[i]].begin(), pos[t[i]].end(), ctr) - pos[t[i]].begin();
    if (ind == (int) pos[t[i]].size()) {
      res += s.size() - ctr - 1;
      ctr = pos[t[i]].front();
      res += ctr + 1;
    } else {
      res += pos[t[i]][ind] - ctr;
      ctr = pos[t[i]][ind];
    }
  }
  cout << res << "\n";
}
 
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int a = r * 100 + g * 10 + b;
    cout << (a % 4 == 0 ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
import static java.util.Arrays.*;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		String[] tokens = sc.nextLine().split(" ");
		double[] st = new double[100];
		int sp = 0;
		for (String token : tokens) {
			if (token.equals("+")) {
				double x = st[sp-2] + st[sp-1];
				sp-=2;
 				st[sp++] = x;
			} else if (token.equals("-")) {
				double x = st[sp-2] - st[sp-1];
				sp-=2;
				st[sp++] = x;

			} else if (token.equals("*")) {
				double x = st[sp-2] * st[sp-1];
				sp-=2;
				st[sp++] = x;

			} else if (token.equals("/")) {
				double x = st[sp-2] / st[sp-1];
				sp-=2;
				st[sp++] = x;
			} else {
				double x = Double.parseDouble(token);
				st[sp++] = x;
			}
		}
		double ans = st[0];
		out.printf("%.8f\n", ans);
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	Scanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

}

Measured memory_bytes: 17260
S = input()
if S == 'SSS':
  a = 0
if S == 'SSR':
  a = 1
if S == 'SRS':
  a = 1
if S == 'SRR':
  a = 2
if S == 'RSS':
  a = 1
if S == 'RSR':
  a = 1
if S == 'RRS':
  a = 2
if S == 'RRR':
  a = 3
print(a)

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    ll p;
    cin >> p;
    a[p - 1] = i;
  }
  ll s = 0;
  vector<ll> l(n, -1), r(n, -1);
  for (ll p = 1; p <= n; p++) {
    ll i = a[p - 1];
    l[i] = 0 <= i - 1 && l[i - 1] != -1 ? l[i - 1] : i;
    r[i] = i + 1 < n && r[i + 1] != -1 ? r[i + 1] : i;
    r[l[i]] = r[i];
    l[r[i]] = l[i];
    ll t = s;
    if (l[i] - 1 >= 0) {
      s += p * (abs(r[i] - i) + 1) * (l[i] - 2 >= 0 && l[l[i] - 2] != -1 ? abs(l[l[i] - 2] - l[i]) : 1);
    }
    if (r[i] + 1 < n) {
      s += p * (abs(l[i] - i) + 1) * (r[i] + 2 < n && r[r[i] + 2] != -1 ? abs(r[r[i] + 2] - r[i]) : 1);
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int d, n, m;
        cin >> d >> n >> m;
        if(d == 0)
            return 0;

        vector<int> store(n);
        store[0] = 0;
        for(int i=1; i<n; ++i)
            cin >> store[i];
        sort(store.begin(), store.end());

        int ret = 0;
        for(int i=0; i<m; ++i){
            int a;
            cin >> a;
            vector<int>::iterator it = lower_bound(store.begin(), store.end(), a);
            int cost = d - a;
            if(it != store.end())
                cost = min(cost, (*it) - a);
            if(it != store.begin()){
                -- it;
                cost = min(cost, a - (*it));
            }
            ret += cost;
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	int a;

	while (scanf("%d", &a) != EOF){
		printf("3C");
		if(a % 39 == 0){
			printf("39");
		}
		else if (a - (a / 39) * 39 < 10){
			printf("0%d", a - (a / 39) * 39);
		}
		else {
			printf("%d", a - (a / 39) * 39);
		}
		printf("\n");
	}

	return (0);
}

Measured memory_bytes: 600
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

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


int main()
{
	FAST;
	int arr[100];
	int n;
	cin >> n;

	for(int i=0 ; i<n ; i++)
		cin >> arr[i];

	sort(arr , arr+n);

	int sum = 0;
	int total = 0;
	for(int i=0 ; i<n ; i++)
	{
		if(i%2 == 0)
			sum += arr[i];
		total += arr[i];
	}

	cout << abs( (total-sum) - sum);
	return 0;
}

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

long long P[5010];
long long C[5010];

int main() {
  long long N, K;
  cin >> N >> K;
  for (long long i = 1; i <= N; i++) {
        cin >> P[i];
  }
  for (long long i = 1; i <= N; i++) {
        cin >> C[i];
  }
  
  long long nmax = -1000000000;//各Nについてのmax
  long long ntemp = 0;//各Nについての途中得点
  long long allmax = -1000000000;//全部の最大値
  int flag;
  int cnt;

  //全マスについて最大値を計算する
  for (int i = 1; i <= N; i++) {
    nmax = -1000000000;
    ntemp = 0;
    flag = 1;//サイクルを回ったかどうかのフラグ
    cnt = 1;//サイクルの数 最初の１回は動いてからスタート
    int temp = i;//最初のマスを記録
    int now = temp;//現在のマス
    //最初の移動をする
    now = P[now];
    ntemp+= C[now];
    nmax=max(nmax,ntemp);
    //スタート
    do {
      if (cnt == K) {
        flag = 0;//サイクルを回らずに終わった場合
        //cout<<"サイクルを回らずに終わった場合"<<endl;
        break;
      }
      now = P[now];
      ntemp += C[now];
      nmax = max(nmax, ntemp);
      cnt++;

    }
    while (now != temp);
    //cout<<now<<" "<<cnt<<"flag"<<nmax<<"ntemp"<<ntemp<<endl;
    
    //サイクルを回らずに終わった場合
    if (flag != 1) {
      allmax = max(allmax, nmax);
      continue;
    }
    
    //サイクルした場合
      //サイクル後スコアが減少している場合
    if (ntemp <= 0) {
      allmax = max(allmax, nmax);
      //cout<<nmax<<"$"<<allmax<<endl;
      continue;
    }
    
    //サイクル後スコアが増加している場合
    if (ntemp > 0) {
      long long sc = K / cnt;//何サイクル回ったか
      //サイクルを回った余りの数　zc
      long long zc = K - (sc-1) *cnt;//残り回数を計算 1周余計に回す
      ntemp=(sc-1)*ntemp;
      nmax = max(nmax, ntemp);
      //cout<<"sc"<<sc<<"zc"<<zc<<"ntemp"<<ntemp<<endl;
      for (int j = 0; j < zc; j++) {
        now = P[now];
        ntemp += C[now];
        //cout<<i<<"###"<<ntemp<<endl;
        nmax = max(nmax, ntemp);
      }
      //cout<<nmax<<"*"<<allmax<<endl;
      allmax = max(allmax, nmax);
      continue;
    }
  }
  //cout<<flag<<" "<<cnt<<endl;
  cout << allmax << endl;
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
ary = list(map(int, input().split()))
bry = list(map(int, input().split()))

n
ary
bry

if sum(ary) < sum(bry):
    print(-1)

else:
    diff = sorted([ary[i] - bry[i] for i in range(n)])

    ns = [d for d in diff if d < 0]
    minus = abs(sum(ns))
    cnt = len(ns)
    for p in diff[::-1]:
        if minus <= 0:
            break
        else:
            minus -= p
            cnt += 1

    print(cnt)


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

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    
    const int NO_OF_ALPHABETS = 26;
    vector <vector <int> > locations(NO_OF_ALPHABETS);
    for(int i = 0; i < S.size(); i++)
    {
        locations[S[i] - 'a'].push_back(i);
    }
    
    int no_of_concatenations = 1, matched_prefix = -1;
    for(int i = 0; i < T.size(); i++)
    {
        if(locations[T[i] - 'a'].size() == 0)
        {
            cout << "-1\n";
            
            return 0;
        }
        
        auto it = upper_bound(locations[T[i] - 'a'].begin(), locations[T[i] - 'a'].end(), matched_prefix);
        
        if(it == locations[T[i] - 'a'].end())
        {
            no_of_concatenations++;
            
            matched_prefix = locations[T[i] - 'a'][0];
        }
        else
        {
            matched_prefix = *it;
        }
    }
    
    long long final_length = (no_of_concatenations - 1)*1LL*S.size() + (matched_prefix + 1);
    cout << final_length << "\n";
    
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int a, b; std::cin >> a >> b;
  if (a > b) swap(a, b);
  rep(i, b) std::cout << a;
  std::cout << "\n";
}


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


int main() {

	string s, t; cin >> s >> t;
	int a = 0;
	for (int i = 0; i < 3; i++) {
		if(s[i] == t[i]) a++;
	}
	cout << a << endl;

	return 0;
}


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

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

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

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

bool sort_fn(Pll &a, Pll &b) {
  if (a.first == b.first) {
    return a.second < b.second;
  }
  return a.first < b.first;
}

int main() {
  ll n, m;
  cin >> n >> m;

  vector<Pll> py;
  for (ll i = 0; i < m; ++i) {
    ll p, y;
    cin >> p >> y;
    py.push_back(mkp(p, y));
  }
  auto spy = py;
  sort(spy.begin(), spy.end(), sort_fn);

  map<Pll, string> ids;
  vector<ll> counter(n, 1);
  each (i, spy) {
    ostringstream oss;
    oss << setw(6) << setfill('0') << i.first << setw(6) << setfill('0') << counter[i.first-1];
    counter[i.first-1]++;
    ids[i] = oss.str();
  }

  each (i, py) {
    cout << ids[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 16368
#include "bits/stdc++.h";
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  int ans=0;
  sort(vec.begin(),vec.end());
  for(int i=0;i<n;i++){
    if(i+1==n) ans+=vec[i]/2;
    else ans+=vec[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,m,x,y;cin>>n>>m>>x>>y;
  vector<int> N(n);
  vector<int> M(m);
  for(int i=0;i<n;i++){cin>>N[i];}
  for(int i=0;i<m;i++){cin>>M[i];}
  sort(N.begin(),N.end());
  reverse(N.begin(),N.end());
  sort(M.begin(),M.end());
  
  
  
  if(N[0]<M[0]&&x<M[0]&&N[0]<y){cout<<"No War"<<endl;}
  else{cout<<"War"<<endl;}}
  

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    lint h, w, k;
    cin >> h >> w >> k;
    lint dp[110][10];
    rep(i, h+1){
        rep(j, w){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    rep(i, h){
        rep(j, (1LL << (w - 1))){
            bool flag = false;
            rep(l, w - 2){
                if((j >> l) % 4 == 3){
                    flag = true;
                    break;
                }
            }
            if(flag){
                continue;
            }
            vector<lint> pos(w);
            rep(l, w){
                pos[l] = l;
            }
            rep(l, w - 1){
                if((j >> l) & 1){
                    swap(pos[l], pos[l + 1]);
                }
            }
            rep(l, w){
                dp[i + 1][pos[l]] += dp[i][l];
                dp[i + 1][pos[l]] %= MOD;
            }
        }
    }
    cout << dp[h][k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    string t = "";
    char c = s[0];
    t += s[0];
    int ans = 0;
    rep(i, 0, n-1) {
        if(s[i] == s[i+1]) ans++; 
    }

    int r_count = 0;
    int l_count = 0;
    if(c == 'L') l_count++;
    else r_count++;

    rep(i, 1, n) {
        if(s[i] == c) { }
        else {
            if(s[i] == 'R') r_count++;
            else l_count++;
            t += s[i];
            c = s[i];
        }
    }

    if(t.size() == 1) cout << ans << endl;
    else if(t.size() == 2) cout << ans+1 << endl;
    else {
        ans = min(ans+2*k, n-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    int d = abs(a-b);
    int s = v-w;
    if(s<=0){cout<<"NO"<<endl;}
    else if(d > t*s){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
}

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

#define rep(i,n) for(long long i=0; i<n ; ++i)
#define REP(i,a,b) for(long long i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);

bool is_prime(ll n){
  if(n<=1) return false;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  faster();
  ll x;
  cin >> x;
  ll temp = x;
  while(!is_prime(x)) x++;
  cout << x;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 256
//Tareq
//not acc
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=b-(a-1) ; i<=(b+(a-1)) ; i++)
    {
        cout<<i;
        if(i==(b+(a-1))) cout<<endl;
        else cout<<" ";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
        if (a > b) {
            System.out.println(a + (a - 1));
        } else if (b > a) {
            System.out.println(b + (b - 1));
        } else {
            System.out.println(a + b);
        }
    }
}


Measured memory_bytes: 35480
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
using namespace std;
typedef long long ll;

ll const MOD = 1e9 + 9;
ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}

ll const MAX = 1e5;
vector<long long> v[MAX];
vector<long long> a(MAX),b(MAX, 0), ans(MAX);
ll cnt = 1;
ll ttl = 0;
void dfs(ll i){
    b[i] = 1;
    for(ll x:v[i]){
        if(b[x] == 0){
            dfs(x);
            
        }
    }
    ans[i] = a[cnt];
    cnt++;
}

int main(){
    ll n;
    cin >> n;
   
    REP(i,1,n-1){
        ll x,y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    } 
    REP(i,1,n){
        cin >> a[i];
    }
    sort(a.begin()+1,a.begin()+1+n);
    dfs(1);
    ll ttl = 0;
    REP(i,1,n-1){
        ttl += a[i];
    }
    cout << ttl << endl;
    REP(i,1,n){
        cout << ans[i];
        if(i < n){
            cout << " ";
        }
    }
    cout << endl;
}

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

int f(int n) {
    int ans = 1;
    while (ans*2<=n)    ans*=2;
    return ans;
}

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

    int n;
    cin>>n;

    if (n<3 || __builtin_popcount(n) == 1) cout<<"No"<<endl;
    else if (n%4==0) {
        cout<<"Yes"<<endl;
        int a = f(n), b = n-a;


        vector<int> v;
        for (int i=1; i<n; i++)
            if (i!=a && i!=b)   v.push_back(i);

        v.push_back(a);
        v.push_back(b);

        for (int i=1; i<v.size(); i++)  cout<<v[i-1]<<" "<<v[i]<<"\n";
        for (int i=1; i<v.size(); i++)  cout<<n+v[i-1]<<" "<<n+v[i]<<"\n";

        cout<<v.back()<<" "<<n+v[0]<<endl;
        cout<<a<<" "<<n<<endl;
        cout<<b<<" "<<2*n<<endl;
    }
    else if (n%4==2) {
        cout<<"Yes"<<endl;
        for (int i=1; i<n-3; i++)    cout<<i<<" "<<i+1<<"\n";
        cout<<n-3<<" "<<n+1<<endl;
        for (int i=n+1; i<2*n-3; i++)    cout<<i<<" "<<i+1<<"\n";

        cout<<n-2<<" "<<n-1<<"\n";
        cout<<n-1<<" "<<1<<"\n";
        cout<<1<<" "<<2*n-2<<"\n";
        cout<<2*n-2<<" "<<2*n-1<<"\n";
        cout<<n-1<<" "<<n<<"\n";
        cout<<2<<" "<<2*n<<"\n";
    }
    else if (n%4==3) {
        cout<<"Yes"<<endl;
        for (int i=1; i<n; i++)    cout<<i<<" "<<i+1<<"\n";
        cout<<n<<" "<<n+1<<endl;
        for (int i=n+1; i<2*n; i++)    cout<<i<<" "<<i+1<<"\n";
    }
    else if (n%4==1) {
        cout<<"Yes"<<endl;
        for (int i=1; i<n-2; i++)    cout<<i<<" "<<i+1<<"\n";
        cout<<n-2<<" "<<n+1<<endl;
        for (int i=n+1; i<2*n-2; i++)    cout<<i<<" "<<i+1<<"\n";

        cout<<n-1<<" "<<n<<"\n";
        cout<<n<<" "<<1<<"\n";
        cout<<1<<" "<<2*n-1<<"\n";
        cout<<2*n-1<<" "<<2*n<<"\n";
    }
}



Measured memory_bytes: 3320
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


X = ni()
if X >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll N,T;
	cin>>N>>T;
	vector<ll>t(N+1);
	ll cnt=T;
	for(int i=1;i<=N;i++){
		cin>>t[i];
		cnt+=min(T,t[i]-t[i-1]);
	}
	cout<<cnt<<endl;
	return 0;
}

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


n = int(input())

res = -1

for i in range(1,int(n**0.5)+1):
    if (n-1)%i == 0:
        if i*i == n-1:
            res += 1
        else:
            res += 2
def divisor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass


pri = divisor(n)
pri.append(n)


for e in pri:
    tmp = n
    while tmp%e == 0:
        tmp = tmp//e
    if tmp%e == 1:
        res += 1

print(res)
        

Measured memory_bytes: 40172
import bisect, heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

for i in range(1,N+1):
    a = bisect.bisect_right(A,i) - bisect.bisect_left(A,i)
    b = bisect.bisect_right(B,i) - bisect.bisect_left(B,i)

    if a + b > N:
        print("No")
        exit()

B = B[::-1]

j, bef = 0, -1
for i in range(N):
    if A[i] != bef:
        j = 0
    if A[i] == B[i]:
        while j < N:
            if A[j] != B[i] and B[j] != A[i]:
                B[i], B[j] = B[j], B[i]
                break
            j += 1
    bef = A[i]

print("Yes")
for b in B:
    print(b,end=" ")
print("")

Measured memory_bytes: 114172
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] l = new int[N];
        for(int i = 0; i < N; i++){
            l[i] = sc.nextInt();
        }
        sc.close();
        Arrays.sort(l);
        long ans = 0;

        int[] s = new int[l[N-1]+1]; // 
        for(int i = 0; i < N; i++){
            s[l[i]]++;
        }
        for(int i = 1; i < s.length; i++){
            if(s[i] == 0){
                s[i] = s[i-1];
            } else {
                s[i] = s[i-1] + s[i];
            }
        }
        
        for(int i = 0; i < N-1; i++){
            for(int j = i+1; j < N-1; j++){
                if(l[i]+l[j] <= l[N-1])
                    ans += s[l[i]+l[j]-1]-j-1;
                else
                    ans += s[l[N-1]]-j-1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
using Node = vector<int>; // そこから伸びる頂点のリスト
using NodeList = vector<Node>;

int main() {
    int n, m;
    cin >> n >> m;
    auto nodes = NodeList(n, Node(0));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        nodes[a].push_back(b);
    }
    // DFSによるトポロジカルソートと同様の考え方でメモ化再帰
    // 末端にあたるノードからの最長距離を記録したメモ
    auto memos = vector<pair<bool, int>>(n, make_pair(false, 0)); // (訪問済みフラグ, 末端ノードからの距離)
    int ans = 0;
    function<int(int)> visit = [&nodes, &memos, &visit, &ans](int index) -> int {
        auto &memo = memos[index];
        if (memo.first) { // 訪問済みならば
            return memo.second;
        }
        memo.first = true;
        int lengthFromLeaf = 0;
        for (auto nextIndex : nodes[index]) {
            auto &nextMemo = memos[nextIndex];
            if (nextMemo.first) { // 次のノードが訪問済みならば
                lengthFromLeaf = max(lengthFromLeaf, nextMemo.second + 1); // 必要に応じて最大値を更新
            } else { // 次のノードが訪問済みならば
                auto len = visit(nextIndex); // 次のノードの末端からの距離を確定させる
                lengthFromLeaf = max(lengthFromLeaf, len + 1); // 必要に応じて最大値を更新
            }
        }
        memo.second = lengthFromLeaf; // このノードの末端からの距離を確定
        ans = max(ans, lengthFromLeaf); // 解を更新
        return lengthFromLeaf; // このノードの末端からの距離を返す
    };
    rep(i, n) {
        visit(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9216
package main

import (
	"fmt"
)

func main(){
	var A, B int
	fmt.Scan(&A)
	fmt.Scan(&B)
	if A+B > 16 {
		panic("Exceeded pieces!")
	}
	if A > 8 || B > 8 {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    ll ans = -1;
    ll tmp = 0;
    for(int i = n-1; i > 0; i--) {
        if (h[i] <= h[i-1]) {
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    if (ans == -1)
        ans = tmp;

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


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

int main() {
  int n;cin>>n;
  int an[n+1];rep(i,n) cin>>an[i+1];
  int next = 1;
  rep(i,n+10) {
    if (an[next] == 2 ) {
      cout << i+1;
      return 0;
    } 
    if (an[next] == next) {
      cout << -1;
      return 0;
    }
    next = an[next];
  }
  cout << -1;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    ll N,H;
    cin >> N >> H;
    priority_queue<pair<ll,ll>> k = priority_queue<pair<ll,ll>>();
    for(int i = 0; i < N; i++){
        ll a,b;
        cin >> a >> b;
        k.push(make_pair(a,1));
        k.push(make_pair(b,0));
    }
    ll count = 0;
    while(true){
        if(H <= 0){
            cout << count << endl;
            return 0;
        }
        auto c = k.top();
        if(c.second == 1){
            count += (H / c.first) + ((H % c.first == 0) ? 0 : 1);
            H = 0;
        }else{
            k.pop();
            H -= c.first;
            count++;
        }
    }

}

Measured memory_bytes: 6000
input = raw_input().split(" ")
list = []
for value in input:
  list.append(int(value))

length = len(list)
i = 0
while i < length - 1:
  min = list[i]
  j = i + 1
  while j < length:
    if list[i] > list[j]:
      temp = list[i]
      list[i] = list[j]
      list[j] = temp
    j += 1
  i += 1

print " ".join(map(str, list))

Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;


class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};



int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> v(h+2, vector<int>(w+2, -1));
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            v[i+1][j+1] = (s[j] == '#');
        }
    }
    int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, 1, -1};
    UnionFind uf(h*w);
    auto f = [&](int p, int q){return (p-1)*w+q-1; };
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            for (int k = 0; k < 4; ++k) {
                if(v[i+dx[k]][j+dy[k]] != -1 && v[i][j]^v[i+dx[k]][j+dy[k]]){
                    uf.unite(f(i, j), f(i+dx[k], j+dy[k]));
                }
            }
        }
    }
    map<int, pair<int, int>> p;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if(v[i][j] == 0) p[uf.root(f(i, j))].first++;
            else p[uf.root(f(i, j))].second++;
        }
    }
    ll ans = 0;
    for (auto &&i : p) {
        ans += (ll)i.second.first*i.second.second;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
#define ld long double
using namespace std;

int main(){
	int n;
	cin>>n;
	ld p[n+1];
	for(int i=1;i<=n;i++){
		cin>>p[i];
		// sum += p[i];
	}
	ld dp[n+1][n+1];
	for(int i = 0;i <=n ;i++){
		for(int j = 0;j <= n;j++){
			dp[i][j] = 0;
		}
	}
	for(int i = 0;i <= n;i++){
		for(int j = 0; j <= i;j++){
			if(i == 0){
				dp[i][j] = 1;
			}
			else if(j == 0){
				dp[i][j] = dp[i-1][j] * (1 - p[i]);
			}
			else
				dp[i][j] = (dp[i-1][j-1] * p[i]) + (dp[i-1][j] * (1 - p[i]));
		}
	}
	ld ans = 0;
	for(int i = n/2 + 1 ; i<=n;i++){
		ans += dp[n][i];
		// cout<<dp[n][i]<<endl;
	}
	cout<<setprecision(10)<<ans<<endl;
}

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

int main(){
    
  int n;
  int ans=0;
  cin>>n;
  vector<int> p(n);
  
  for(int i=0;i<n;i++){
      cin>>p[i];
  }
  
  for(int i=0;i+2<n;i++){
    vector<int> sort_P({p[i],p[i+1],p[i+2]});
    sort(sort_P.begin(),sort_P.end());
    ans+=p[i+1]==sort_P[1];
  }
  cout<<ans<<endl;
  return 0;
}



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

void Main()
{
    int64_t N;
    cin >> N;
    vector<string> S(N);
    for(int64_t i = 0; i < N; ++i)
    {
        cin >> S[i];
    }

    sort(S.begin(), S.end());
    decltype(S)::iterator it = unique(S.begin(), S.end());
    S.erase(it, S.end());

    cout << S.size() << endl;
}

int main()
{
    Main();
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
int main()
{
  int N,cnt=0,p=-1;
  cin>>N;
  while(N) {
    int x = N % 10;
    if (x == p) ++cnt;
    else {
      p = x;
      cnt = 1;
    }
    if (cnt == 3) {
      cout << "Yes";
      return 0;
    }
    N /= 10;
  }
  cout << "No";
}


Measured memory_bytes: 256
def bubbleSort(A, N):
    cnt = 0
    flg = True
    while flg:
        flg = False
        for i in range(N - 1):
            if A[i][1] > A[i + 1][1]:
                tmp = A[i]
                A[i] = A[i + 1]
                A[i + 1] = tmp
                flg = True
                cnt += 1
    return A, cnt


def selectionSort(A, N):
    cnt = 0
    for i in range(N):
        minJ = i
        for j in range(i, N):
            if A[minJ][1] > A[j][1]:
                minJ = j
        if A[i][1] != A[minJ][1]:
            tmp = A[i]
            A[i] = A[minJ]
            A[minJ] = tmp
            cnt += 1
    return A, cnt


def resolve():
    import copy
    N = int(input())
    A = [i for i in input().split()]
    B = copy.deepcopy(A)
    ansA, cnt = bubbleSort(A, N)
    print(*ansA)
    print("Stable")
    ansB, cnt = selectionSort(B, N)
    print(*ansB)
    if ansA == ansB:
        print("Stable")
    else:
        print("Not stable")


resolve()



Measured memory_bytes: 6348
#!/usr/bin/env pypy3

import sys
sys.dont_write_bytecode = True
stdin = sys.stdin
input = stdin.readline
sys.setrecursionlimit(1000000000)

#import numpy as np
#import scipy as sp

# Python 3 modules: https://docs.python.org/3/library/

import math, itertools, operator
from math import *
from math import factorial as fact
from operator import itemgetter, attrgetter
from itertools import permutations, combinations
from functools import reduce, lru_cache
# Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
# Before Python 3.5.  Import from math after it.
from fractions import gcd
from fractions import Fraction as Frac

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(func = input, sep = None, conv = int):
    return list(map(conv, func().split(sep = sep)))

################################################################################

N, M = list(map(int, input().split()))
A = [None for i in range(M)]
for i in range(M):
    A[i] = int(input())
#A = list(map(int, stdin.read().split()))

BROKEN = [False for i in range(N)]
for a in A:
    BROKEN[a] = True

@lru_cache()
def dp(cur):
    if cur > N:
        return 0
    if cur == N:
        return 1
    if BROKEN[cur]:
        return 0
    return dp(cur + 1) + dp(cur + 2)

print(dp(0) % 1000000007)


Measured memory_bytes: 280192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main(int argc, char *argv[]){
    int N,L;
    std::cin >> N >> L;
    std::vector<int> taste(N);
    for(int i=0; i<N; ++i){
        taste[i] = L + i;
    }
    auto tasteAbsMin = *std::min_element(taste.begin(),taste.end(),[](const int &a, const int &b){
                                                                        return std::abs(a) < std::abs(b);
                                                                    });
    int tastePie = ((2*L+N-1)*N)/2 - tasteAbsMin;
    std::cout << tastePie << std::endl;
    return 0;
}


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

int main() {
    long n;
    cin >> n;

    string W[100];
    for (long i = 0; i < n; i++) {
        cin >> W[i];
    }

    for (long i = 1; i < n; i++) {
        if (W[i - 1][W[i - 1].size() - 1] != W[i][0]) {
            cout << "No" << endl;
            return 0;
        }
        for (long j = 0; j < i; j++) {
            if (W[i] == W[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int, int> pii;

int main() {
    int n, m;
    cin >> n >> m;
    pii ba[n];
    for (int i = 0; i < n; i++) {
        cin >> ba[i].second >> ba[i].first;
    }
    sort(ba, ba+n);
    reverse(ba, ba+n);

    set<int> pos;
    for (int i = 0; i < m; i++) {
        pos.insert(i);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        auto it = pos.upper_bound(m - ba[i].second);
        if (it != pos.begin()) {
            ans += ba[i].first;
            pos.erase(prev(it));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
from collections import Counter

def main():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))

    D = Counter(D)
    T = Counter(T)

    for k, v in T.items():
        if D[k] < v:
            print('NO')
            return
    print('YES')

main()

Measured memory_bytes: 55648
n, m = map(int, input().split())
a = []
for i in range(n):
    a.append(input())
b = []
for i in range(m):
    b.append(input())

ok = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        tmp = [a[k][j: j + m] for k in range(i, i + m)]
        if tmp == b:
            ok = True
            break
if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
A.append(0)
A.insert(0, 0)
sum = 0
for i in range(N+1):
    sum += abs(A[i] - A[i+1])
for i in range(1, N+1):
    print(sum-abs(A[i-1] - A[i])-abs(A[i] - A[i+1])+abs(A[i-1] - A[i+1]))


Measured memory_bytes: 83292
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Console.WriteLine(Solve());
		Out.Flush();
	}
	int[] A, B;
	long Solve()
	{
		var N = F;
		A = new int[N];
		B = new int[N];
		for (var i = 0; i < N; i++) A[i] = F;
		var l = 0;
		var ans = 0L;
		while (l < N)
		{
			var tmp = new List<int>();
			if (A[l] != 0) return -1;
			var r = l + 1;
			while (r < N && A[r] > 0) r++;
			var c = Solve(l, r);
			if (c < 0) return -1;
			ans += c;
			l = r;
		}
		return ans;
	}
	long Solve(int l, int r)
	{
		if (r - l == 1) return 0;
		for (var t = l + 1; t < r; t++) if (A[t] - A[t - 1] > 1) return -1;
		var ans = 0L;
		var i = r - 1;
		while (i > l)
		{
			ans += A[i];
			var j = i - 1;
			while (j > l && A[i] - A[j] == i - j) j--;
			i = j;
		}
		return ans;
	}
}


Measured memory_bytes: 18652
import bisect
import sys

A, B, Q = map(int,input().split())
s = tuple([-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18])
t = tuple([-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*B))) + [10**18])


def solve(s,t,x):
    ans = 10**18
    for i in range(2):
        a, b = (s, t) if i==0 else (t, s)
        posX1 = bisect.bisect_left(a,x)
        for j in range(2):
            ax = a[posX1 -j]
            posX2 = bisect.bisect_left(b,ax)
            for k in range(2):
                bx = b[posX2-k]
                ans = min(ans, abs(x-ax)+abs(bx-ax))
    return ans

ans = [solve(s,t,x) for x in map(int,sys.stdin)]
print(*ans, sep="\n")

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

int main(){
    ll l,r;
    cin>>l>>r;
    ll cnt=2019;
    bool t=false;
    for(ll i=0;i<r-l;i++){
        for(ll j=1;j<r-l+1;j++){
            if((l+i)*(l+j)%2019==0){
                cnt=0;
                t=true;
                break;
            }
            else{
                cnt=min((l+i)*(l+j)%2019,cnt);
            }
        }
        if(t)break;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
  int N; cin>>N;
  int near=1001;
  int far=-1;
  for(int i=0;i<N;i++){
    int tmp; cin>>tmp;
    if(near>tmp)near=tmp;
    if(far<tmp)far=tmp;
  }
  cout<<(far-near)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  n,y=map(int,input().split())
  for i in range(0,y//10000+1):
    for j in range(0,n-i+1):
      if 10000*i+5000*j+1000*(n-i-j)==y and n-i-j>=0:
        print(str(i)+' '+str(j)+' '+str(n-i-j))
        exit()
  print('-1 -1 -1')  
if __name__=='__main__':
  main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

typedef long long int int64;

int main(int argc, char **argv)
{
    int64 H, N;
    cin >> H >> N;
    int A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];

    int sum = 0;
    for (int i = 0; i < N; ++i) sum += A[i];
    if (sum >= H) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 640