akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 10004;

int n;
vector<int> a[N];
int b[N];

int q[N];

int ans[N];
int main()
{
    cin >> n;
    for (int i = 1; i <= n - 1; ++i)
    {
        int x, y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    sort(b, b + n);

    set<pair<int, int> > s;
    for (int i = 1; i <= n; ++i)
    {
        s.insert(m_p(a[i].size(), i));
        q[i] = a[i].size();
    }
    int sum = 0;
    for (int ii = 0; ii < n; ++ii)
    {
        pair<int, int> t = *(s.begin());
        s.erase(t);
        sum += (t.first * b[ii]);
        ans[t.second] = b[ii];
        for (int i = 0; i < a[t.second].size(); ++i)
        {
            int h = a[t.second][i];
            pair<int, int> hh = m_p(q[h], h);
            if (s.find(hh) != s.end())
            {
                s.erase(hh);
                q[h]--;
                hh.first--;
                s.insert(hh);
            }
        }
    }
    cout << sum << endl;
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <vector>
#include  <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <cassert>
#include <locale>
#include <string>
#include <bitset>
#include <functional>
#include <climits>
#include <iomanip>
#include <cstdarg>

using namespace std;


#define testcase() int tc,tci; sf(tc); for(tci=1; tci<=tc; tci++)

#define fi() freopen("i.txt","r", stdin)
#define fo() freopen("o.txt","w", stdout)
#define fri(x) freopen(x,"r", stdin)
#define fro(x) freopen(x,"w", stdout)
#define met(a,b) memset(a,b,sizeof a);

#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)

#define sf(a) scanf("%d", &a)
#define sff(a, b) scanf("%d %d", &a, &b)
#define sfff(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define pf(a) printf("%d\n", a)
#define pff(a, b) printf("%d %d\n", a, b)
#define pfff(a, b, c) printf("%d %d %d\n", a, b, c)

#define pb push_back
#define mp make_pair

#define loop(i, j, n) for(int i=j; i<n; i++)
#define ctrl() printf("xxxxxxxxxxxxxxxxxxxxxxx\n")

#define F first
#define S second

#define INF INT_MAX-10

//------bitmask operations------//
#define setbit(x, j) x |= (1<<j)
#define removebit(x, j) x &= ~(1<<j)
#define checkbit(x, j) x &= (1<<j)
#define flipbit(x, j) x ^= (1<<j)
#define lsb(x, t) t= (x & (-x) )
//------------------------------//



void debug(int n, ...){
	va_list v1;
	va_start(v1, n);
	for(int i=0; i<n; i++){
		int val=va_arg(v1, int);
		printf("%d ", val);
	}
	va_end(v1);
	printf("\n");
}

	/////////////////////////////////////////////////////

const int N = 1e5+7;
const int inf = 1e9 + 7;

int a[107];
bool dp[N];

int n, k;

int main(){
	//freopen("t.gir","r",stdin);
	//freopen("t.cik","w",stdout);
	
	cin >> n >> k;

	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	for(int st = 0; st <= k; st++){
		for(int x = 0; x<n; x++){
			if(st >= a[x] && !dp[st - a[x]]){
				dp[st] = 1;
			}
		}
	}
	
	/*
	for(int i=0; i<=k; i++){
	 cout<< i << ": " << dp[i] << endl;
	}
	*/
	
	//cout << endl;

	if(dp[k])
		cout << "First";
	
	else
		cout << "Second";
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    VI c(4);
    int a,b;
    REP(i,0,3) {
        cin >> a >> b;
        c[a-1]++;
        c[b-1]++;
    }
    sort(all(c));
    if (c[0] == 1 && c[1] == 1 && c[2] == 2 && c[3] == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		long 			x, y, origX, origY;
		String			buffer;
		BufferedReader 	reader = new BufferedReader(new InputStreamReader(System.in));

		while((buffer = reader.readLine()) != null){
			x = Long.parseLong(buffer.split(" ")[0]);
			y = Long.parseLong(buffer.split(" ")[1]);

			origX = x;
			origY = y;

			if(x < y){
				long tmp = x;
				x = y;
				y = tmp;
			}

			long mod;
			while((mod = x % y) != 0){
				x = y;
				y = mod;
			}

			System.out.println(y + " " + (origX * origY / y));
		}


	}

}

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

int main(){
  ll N; cin >> N;
  ll t, a;
  cin >> t >> a;
  for(ll i = 1; i < N; i++){
    ll x, y; cin >> x >> y;
    ll t1 = ((t - 1) / x) + 1;
    ll t2 = ((a - 1) / y) + 1;
    t = max(t1, t2) * x; a = max(t1, t2) * y;
  }
  cout << t + a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int a, b, c;
    cin >> a>> b >>c;
    if (a + b + c >= 22) cout << "bust\n";
    else cout << "win\n";
    return 0;
}

Measured memory_bytes: 892
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 210
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int T;
int n;
char s[N];
ll v[N];
struct node
{
	ll p[63];
	inline void clear(){memset(p,0,sizeof(p));}
	inline ll insert(ll x)
	{
		for(register int i=62;i>=0;i--)
		{
			if((x>>i)&1)
			{
				if(p[i])x^=p[i];
				else {p[i]=x;return x;}
			}
		}
		return 0;
	}
	inline void build()
	{
		for(register int i=62;i>=0;i--)
		{
			for(register int j=i-1;j>=0;j--)
			{
				if((p[i]>>j)&1)p[i]^=p[j];
			}
		}
	}
}A;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int T=read();
	while(T--)
	{
		n=read();
		for(register int i=1;i<=n;i++)v[i]=read();
		scanf("%s",s+1);A.clear();int flag=1;
		for(register int i=n;i>=1;i--){if(s[i]=='0')A.insert(v[i]);else if(A.insert(v[i])){flag=0;break;}}
		if(!flag){printf("1\n");}
		else printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 3684
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  int N;

  cin >> N;
  VI a(N), b(N);

  REP(i, 0, N){
    cin >> a[i];
    b[i] = a[i];
  }

  sort(a.begin(), a.end());

  int a1 = a[N/2-1];
  int a2 = a[N/2];

  REP(i, 0, N){
    if(b[i] <= a1){
      cout << a2 << endl;
    } else {
      cout << a1 << endl;
    }
  }

  return 0;
}


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

int main(void){
  string b;
  cin >> b;
  string ret = "";
  if(b[0] == 'A') ret += 'T';
  else if(b[0] == 'T') ret += 'A';
  else if(b[0] == 'C') ret += 'G';
  else if(b[0] == 'G') ret += 'C';
  cout << ret << endl;
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for(int i = 0; i < N; i++) cin >> P[i];
  
  sort(P.begin(), P.end());
  int ans = 0;
  for(int i = 0; i < K; i++) ans += P[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
from collections import deque


def solve(H, W, Ch, Cw, Dh, Dw, maze):
    # 後の条件分岐を簡略化するためワープしても迷路外に出ないように壁で囲む
    walled_maze = ['##{}##'.format(row) for row in maze]
    walled_maze.insert(0, '##{}##'.format('#' * W))
    walled_maze.insert(0, '##{}##'.format('#' * W))
    walled_maze.append('##{}##'.format('#' * W))
    walled_maze.append('##{}##'.format('#' * W))

    INF = 10 ** 12
    path = [[INF] * (W + 4) for _ in range(H + 4)]
    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    yet = deque()
    yet.append((Ch + 2, Cw + 2, 0))    # 囲った壁の分だけプラス
    path[Ch + 2][Cw + 2] = 0
    done = deque()

    while yet:
        y, x, s = yet.popleft()
        done.append((y, x, s))
        for dy, dx in walk:
            ny = y + dy
            nx = x + dx
            if walled_maze[ny][nx] == '.' and path[ny][nx] > s:
                path[ny][nx] = s
                yet.append((ny, nx, s))
        if len(yet) == 0:
            while done:
                y, x, s = done.popleft()
                for dy, dx in warp:
                    ny = y + dy
                    nx = x + dx
                    if walled_maze[ny][nx] == '.' and path[ny][nx] > s + 1:
                        path[ny][nx] = s + 1
                        yet.append((ny, nx, s + 1))
    ans = path[Dh + 2][Dw + 2] if path[Dh + 2][Dw + 2] < INF else -1
    print(ans)


if __name__ == '__main__':
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    maze = [input() for _ in range(H)]
    solve(H, W, Ch, Cw, Dh, Dw, maze)


Measured memory_bytes: 24524
#include <algorithm>
#include <iostream>
#include <map>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  map<string, int> M;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    if (M.count(s)) {
      ++M[s];
    } else {
      M.insert({s, 1});
    }
  }
  int n = 0;
  for (auto &m : M) {
    n = max(n, m.second);
  }
  for (auto &m : M) {
    if (m.second == n) {
      printf("%s\n", m.first.c_str());
    }
  }
}

Measured memory_bytes: 18752
import java.util.*;

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

	public Main(){
		new AOJ0086().doIt();
	}
	
	class AOJ0086{
		int[] memo;
		boolean solve(){
			if(memo[1]%2==0||memo[2]%2==0)return false;
			for(int i=3;i<1000;i++)if(memo[i]%2!=0)return false;
			return true;
		}
		
		void doIt(){
			memo = new int[1000];
			while(in.hasNext()){
				int a = in.nextInt();
				int b = in.nextInt();
				if(a==0&&b==0){
					boolean ans = solve();
					System.out.println(ans? "OK":"NG");
					memo = new int[1000];
				}
				memo[a]++;memo[b]++;
			}
		}
	}
	
}

Measured memory_bytes: 24476
N = int(input())
H = list(map(int, input().split()))
 
if N == 1:
    print(0)
    quit()

count = 0
moves = []
for h0, h1 in zip(H,H[1:]):
    if h0 >= h1:
        count += 1
    else:
        moves.append(count)
        count = 0
print(max(moves + [count]))


Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{     

    static void IsPlus(Stack<int> data)
    {
        int a;
        int b;
        a = data.Pop();
        b = data.Pop();
        data.Push(b + a);
    }

    static void IsMinus(Stack<int> data)
    {
        int a;
        int b;
        a = data.Pop();
        b = data.Pop();
        data.Push(b - a);
    }

    static void IsMulti(Stack<int> data)
    {
        int a;
        int b;
        a = data.Pop();
        b = data.Pop();
        data.Push(b * a);
    }
    
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');

        var data = new Stack<int>();

        foreach(var s in str)
        {
            if(s == "+")
            {
                IsPlus(data);
            }
            else if(s == "-")
            {
                IsMinus(data);
            }
            else if(s == "*")
            {
                IsMulti(data);
            }
            else
            {
                data.Push(int.Parse(s));
            }
        }

        Console.WriteLine(data.Peek());

    }
}


Measured memory_bytes: 16376
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int a[4];
	int b[2];
	int res = 0;
	REP(i, 4){
		cin >> a[i];
	}
	cin >> b[0] >> b[1];

	sort(a, a+4);
	sort(b, b+2);
	cout << a[1] + a[2] + a[3] + b[1] << endl;
	return 0;
}

Measured memory_bytes: 3084
#ifdef LOCAL
    #define _GLIBCXX_DEBUG
    #define __clock__
#else
    #pragma GCC optimize("Ofast")
#endif
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

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;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

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
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    char c;cin>>c;
    c++;
    p(c);
    
    return 0;
}

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

using namespace std;
typedef long long ll;

int N;
vector<string> ans;
void dfs(string s, int u){
    if(s.size() == N){
        ans.push_back(s);
        return;
    }
    for(int i = 0; i <= u; i++){
        dfs(s+(char)('a'+i), max(u, i+1));
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    dfs("a", 1);
    sort(ans.begin(), ans.end());
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}

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

signed main(){
  int N,A,B;
  cin>>N>>A>>B;
  if(A>B)swap(A,B);
  int ans=0;
  if(B-(A+N)>0)ans=B-(A+N);
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int n;
    std::cin>>n;
    std::vector<int> v(n+2);
    std::vector<std::pair<int,int>> dist(n); // 都市iを経由する合計 / 経由しない合計
    int len = 0;

    for(int i=1;i<=n;i++)std::cin>>v[i];
    for(int i=0;i<=n;i++){
        len += std::abs(v[i] - v[i+1]);
    }

    for(int i=0;i<n;i++){
        dist[i].first = std::abs(v[i+1] - v[i]) + std::abs(v[i+2] - v[i+1]);
        dist[i].second = std::abs(v[i+2] - v[i]);
    }
    for(int i=0;i<n;i++){
        std::cout<<len - dist[i].first + dist[i].second << std::endl;
    }

}

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

using namespace std;

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

	if(a <= x && a + b >= x) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	
}


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

using namespace std;
 
int main() {
    string a;cin>>a;
    for(int i = 0;i<a.size();i++){
      if(i%2 == 0){
         if(a[i] == 'L'){
           cout<<"No";
           return 0;
         }
      }
      if(i%2 == 1){
         if(a[i] == 'R'){
           cout<<"No";
           return 0;
         }
      }
    
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func solve(h []int, n, k int) {
	min := 99999999999
	for i := 0; i < n-k+1; i++ {
		if h[i+k-1]-h[i] < min {
			min = h[i+k-1] - h[i]
		}
	}
	fmt.Println(min)
}
func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var h = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	sort.Ints(h)
	solve(h, n, k)
}

Measured memory_bytes: 5504
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();

		char[][] c = new char[H][W];
		int ans=0;
		for (int h = 0; h < H; h++) {
			String s = scan.next();
			for (int w = 0; w < W; w++) {
				c[h][w] = s.charAt(w);
			}
		}

		boolean[][] flag = new boolean[H][W];
		Queue<int[]> queue = new ArrayDeque<int[]>();
		for(int sh = 0; sh < H; sh++){
			for(int sw = 0; sw < W; sw++){
				if(c[sh][sw] != '#'){
					
					for(int i = 0; i < H; i++){
						Arrays.fill(flag[i], false);
					}
					
					int[] a = {sh, sw, 0};
					queue.add(a);
					flag[sh][sw] = true;
					int[] dx={1,0,-1,0,};
					int[] dy={0,-1,0,1,};
					while (!queue.isEmpty()) {
						int[] rem = queue.remove();
						int y = rem[0];
						int x = rem[1];
						int depth=rem[2];
						for (int i=0;i<4;i++) {
							if(0 <= y+dy[i] && y+dy[i] < H && 0 <= x+dx[i] && x+dx[i] < W){
								if (c[y+dy[i]][x+dx[i]]=='#' || flag[y+dy[i]][x+dx[i]] == true) {
								} else {
									int[] ad = {y+dy[i],x+dx[i],depth+1};
									queue.add(ad);
									flag[y+dy[i]][x+dx[i]] = true;
									ans = Math.max(depth + 1, ans);
								}
							}
						}
					}
				}
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 27048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int result  = 0;
			for(int i = N; i > 0; i--){
				if(Check(i)){
					result = i;
					break;
				}
			}
			System.out.println(result);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	private static boolean Check(int n){
		while(n%2 == 0){
			n = n/2;
		}
		if(n == 1)return true;
		return false;
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <iostream>
#include <string.h>
#include <map>
#include <set>
#include <functional>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
	ios::sync_with_stdio(false);
    int T;
    cin >> T;
    while(T--){
        bool ok = true;
        int l, r;
        l = r = -1;
        for(int i=0; i<10; i++){
            int b;
            cin >> b;
            if(l >= r && b > l)
                l = b;
            else if(b > r)
                r = b;
            else
                ok = false;
            //cout << l << " " << r << endl;
        }
        cout << (ok ? "YES" : "NO") << endl;
    }
    
	return 0;
}

Measured memory_bytes: 1184
def examA():
    N = I()
    S = [""]*N; T = [""]*N
    for i in range(N):
        S[i],T[i] = LSI()
        T[i] = int(T[i])
    X = SI()
    ans = 0
    flag = False
    for i in range(N):
        if flag:
            ans +=T[i]
        if S[i]==X:
            flag = True
    print(ans)
    return

class combination():
    # 素数のmod取るときのみ　速い
    def __init__(self, n, mod):
        self.n = n
        self.fac = [1] * (n + 1)
        self.inv = [1] * (n + 1)
        for j in range(1, n + 1):
            self.fac[j] = self.fac[j - 1] * j % mod

        self.inv[n] = pow(self.fac[n], mod - 2, mod)
        for j in range(n - 1, -1, -1):
            self.inv[j] = self.inv[j + 1] * (j + 1) % mod

    def comb(self, n, r, mod):
        if r > n or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.inv[n - r] * self.inv[r] % mod

def examB():
    N = I()
    X = LI()
    B = [1]*N
    for i in range(1,N-1):
        B[i+1] =B[i]*(i+1)
        B[i+1] %= mod
    XL = [X[i+1]-X[i] for i in range(N-1)]
    C = combination(N, mod)
    """
        cumL = [0]*N
    cumL[1] = XL[0]
    for i in range(1,N):
        cumL[i+1] = cumL[i]+XL[i]
    print(cumL)
    """
    ans = 0; cur = B[-1]
    now = 0
#    print(B,XL)
    for i in range(N-1):
        ans += cur*XL[i]
        ans %=mod
#        print(ans)
    for i in range(1,N-1):
        now += C.comb(N-1,1+i,mod)
        ans += now*XL[i]
        ans %=mod
#        print(ans)
    print(ans)
    return
"""
4
1 3 6 7
"""
def examB2():
    N = I()
    X = LI()
    L = [0]*(N-1)
    for i in range(N-1):
        L[i] = X[i+1] - X[i]

    S = [1]*N
    for i in range(1,N):
        S[i] = S[i-1] + pow(i+1,mod-2,mod)
    C = combination(N,mod)
    cnt = 0
    for i in range(N-1):
        #print(S[i], L[i], C.fac[N - 1])
        cnt += S[i]*L[i]*C.fac[N-1]%mod
        cnt %= mod
    ans = cnt
    print(ans)
    return

def examC():

    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB2()


Measured memory_bytes: 91236
(function main() {
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8')) + 1;
  const root5 = Math.sqrt(5);
  console.log(Math.round(1/root5*(Math.pow((1+root5)/2,n)-Math.pow((1-root5)/2,n))));
})();



Measured memory_bytes: 15368
n,k = map(int,input().split())

ans =[]

A = [0]*k
x = [0]*k

for j in range(k):
     x[j]= int(input())
     A[j] = [int(x) for x in input().split()]
     ans += A[j]



ans2 = set(ans)
print(n-len(ans2))


Measured memory_bytes: 9384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string s;
  ll k;
  cin >> s >> k;

  for(int i = 0; i < min((ll)s.size(), k); ++i) {
    if (s[i] >= '2') {
      cout << s[i] << endl;
      return 0;
    }
  }

  cout << '1' << endl;
  return 0;
}


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

int main ()
{
    int	n;

    while (cin >> n) {
        int res = 0;
    	for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                for (int k = 0; k <= 9; k++) {
                    for (int l = 0; l <= 9; l++) {
                        if (i + j + k + l == n) res++;
                    }
                }
            }
    	}

        cout << res << endl;
    }

    return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a!=1 and b!=1)
    {
        if(a>b)
        {
            cout<<"Alice";
        }
        else if(a<b)
        {
            cout<<"Bob";
        }
        else if(a==b)
        {
            cout<<"Draw";
        }
    }
    else
    {
        if(a==1 and b!=1)
        {
            cout<<"Alice";
        }
        else if(a!=1 and b==1)
        {
            cout<<"Bob";
        }
        else if(a==1 and b==1)
        {
            cout<<"Draw";
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

int main(){
  int n,i;
  long int temp;
  long int max ,min;
  long int sum = 0;

  std::cin >> n;

  scanf("%ld" ,&temp);
  max = min = temp;
  sum += temp;

  for (i = 0; i < n-1 ; i++ ) {
    /* code */
    scanf("%ld" ,&temp);
    if(max< temp ){
      max = temp;
    }else if(min > temp){
      min = temp;
    }
    sum += temp;

  }
printf("%ld %ld %ld\n",min ,max ,sum );

  return 0;
}



Measured memory_bytes: 3212
package main

import (
  "fmt"
)

func check(n, a, b int) int {
  n1 := n % 10
  n10 := (n % 100) / 10
  n100 := (n % 1000) / 100
  n1000 := (n % 10000) / 1000
  n10000 := n / 10000

  if v := n1 + n10 + n100 + n1000 + n10000; a <= v && v <= b {
    return n
  }
  return 0
}

func main() {
  var n, a, b, count int
  fmt.Scan(&n, &a, &b)
  for i := 1; i <= n; i++ {
    count += check(i, a, b)
  }
  fmt.Println(count)
}

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

int n, m, s[26];
int sum[100];
bool used[110][110];

int pop(int x, int y) {
	int ans = 0;
	if (!used[x][y])
		ans = 1;
	used[x][y] = true;
	return ans;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			char k;
			for (k = getchar(); k <= 32; k = getchar());
			s[k - 'a'] += 1;
		}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (!used[i][j]) {
				int ss = 0;
				ss += pop(i, j);
				ss += pop(n - i + 1, j);
				ss += pop(i, m - j + 1);
				ss += pop(n - i + 1, m - j + 1);
				sum[ss] += 1;
			}
	for (int i = 4; i >= 1; i--)
		for (int j = 1; j <= sum[i]; j++) {
			bool find = false;
			for (int k = 0; k < 26; k++)
				if (s[k] >= i) {
					s[k] -= i;
					find = true;
					break;
				}
			if (!find) {
				printf("No\n");
				return 0;
			}
		}
	printf("Yes\n");
}


Measured memory_bytes: 256
n, m = map(int, input().split())
c = list(map(int, input().split()))

INF = 10**12

T = [[INF for i in range(n+1)] for j in range(m)]

for i in range(n+1):
    T[0][i] = i

for i in range(m):
    T[i][0] = 0

for i in range(m):
    for j in range(1, n+1):
        if j - c[i] >= 0:
            T[i][j] = min(T[i-1][j], T[i][j - c[i]] + 1)
        else:
            T[i][j] = T[i-1][j]

print(T[m-1][n])

Measured memory_bytes: 45440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vii vector<int, int>
#define pii pair<int, int>
#define nn "\n"


int main() {

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

	ios::sync_with_stdio(0);
	cin.tie(0);

	int n; cin >> n;

	std::vector<ll> v(n + 1);

	for (int i = 1; i <= n; ++i) cin >> v[i];


	vector<int> dp(n + 1);
	dp[1] = 0;

	for (int i = 2; i <= n; i++) {
		int op1 = abs(v[i] - v[i - 1]) + dp[i - 1];
		int op2 = (i == 2) ? INT_MAX : abs(v[i] - v[i - 2]) + dp[i - 2];
		dp[i] = min(op1, op2);
	}

	cout << dp[n];

	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
ll cal(ll len,ll k);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    int k=nxt();
    ll test=0;
    for(int d=k;d<n;d++)
    {
        test+=(9*cal(d-1,k-1));
           //cout<<test<<endl;
    }
    vector <pair<int,int> > v;
    for(int i=0;i<n;i++)
        if(s[i]>48)
            v.push_back({s[i]-48,n-i-1});


    for(int i=0;i<k&&i<v.size();i++)
    {
        ll x=v[i].first;
        int j=0;
        if(i==0)
            j++;
        for(;j<x;j++){
            test+=cal(v[i].second,k-i-!!j);
            //cout<<j<<" "<<k-i-1<<" "<<v[i].second<<" "<<test<< endl;
        }
    }

    if(v.size()>=k)
        test++;
    cout<<test<<endl;


    return 0;   
}

ll cal(ll len,ll k)
{
    if(len<k)
        return 0;
    if(k==0)
        return 1;
    if(k==1)
        return 9*len;
    if(k==2)
    {
        ll ans=9*4*(len)*(len-1);
        ans+=9*(((len)*(len-1))/2);
        return ans;
    }
}


 
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int MAX_PRI=123456*2+1;

int main(){
     bool isprime[MAX_PRI];
     for(int i=0;i<MAX_PRI;i++){
	  isprime[i]=true;
     }
     for(int i=2;i*i<=MAX_PRI;i++){
	  if(!isprime[i])continue;
	  for(int j=i*2;j<MAX_PRI;j+=i){
	       isprime[j]=false;
	  }
     }
     isprime[1]=false;

     int in;
     while(cin>>in,in){
	  int a=count(&isprime[in+1],&isprime[in*2+1],true);
	  cout<<a<<endl;
     }
     return 0;
}
	       

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int n, k, p;
	vector<double> pv;
	cin >> n >> k;
	rep(i, n) {
		cin >> p;
		pv.pb((1+p)/2.0);
	}

	double e_max, e=0.0;
	rep(i, k) {
		e += pv[i];
	}
	e_max = e;
	for(int i=k; i<n; i++) {
		e = e + pv[i] - pv[i-k];
		e_max = e_max > e ? e_max : e;
	}

	vector<double> ev;
	double e_acc = 0;
	rep(i, n) {
		e_acc += pv[i];
		ev.pb(e_acc);
	}
	double e_max2 = 0;
	double e2;
	rep(i, n - k) {
		e2 = ev[i+k] - ev[i];
		e_max2 = e_max2 > e2 ? e_max2 : e2;
	}
	cout << setprecision(50) << e_max << endl;
	return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll a=0;
  ll c=s.size();
  ll cnt=0;
  if(s[0]!=s[c-1]){
    for(int i=0;i<c-1;i++){
      if(s[i]==s[i+1]){
        cnt++;
        s[i+1]='1';
      }
    }
    cout << cnt*k << endl;
  }
  else{
    for(int i=0;i<c-1;i++){
      if(s[i]!=s[i+1]){
        a=1;
      }
    }
    if(a==0){
      cout << c*k/2 << endl;
    }
    else{
      int x,y;
      for(int i=0;i<c-1;i++){
        if(s[i]!=s[i+1]){
          x=i;
          break;
        }
      }
      x++;
      for(int i=c-1;i>0;i--){
        if(s[i]!=s[i-1]){
          y=c-i-1;
          break;
        }
      }
      y++;
      //cout << x << endl;
      //cout << c-y << endl;
      for(int i=x;i<c-y;i++){
        if(s[i]==s[i+1]){
          cnt++;
          s[i+1]='1';
        }
      }
      //cout << cnt << endl;
      cout << cnt*k+(x+y)/2*(k-1)+x/2+y/2 << endl;
    }
  }
}

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

using namespace std;

int main(void) {
    int N;
    int K = 0;

    cin >> N;

    vector<int> d(N);

    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    for (int i = d[N / 2 - 1]; i < d[N / 2]; i++) K++;

    cout << K << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1;}
    return 0;
}
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    int ans = 0;
    REP(i,N){
        int h;
        cin >> h;
        if(h >= K)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split(' ')))
sum = 0
min = 1000000000
minus = 0
for n in range(N):
    n_abs = abs(A[n])
    sum += n_abs
    if min > n_abs:
        min = n_abs
    if A[n] < 0:
        minus += 1
if minus%2 != 0:
    sum -= 2*min
print(sum)

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

int main(){
  char a;
  cin>>a;
  if(a=='a' || a=='i' || a=='u' || a=='e' || a=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}
    

Measured memory_bytes: 256
#include<iostream>
#include<iterator>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stack>
#include<string.h>
#include<map>
#include<bitset>
#include<set>
#include<deque>
#include<sstream>
#include<queue>
#include<list>
#include <fstream>
#include <iomanip>
#define ln 1000005
#define pi acos(-1.0)
#define pb push_back
#define mp nake_pair
using namespace std;
int main()
{
    //std::ofstream outfile;
    //outfile.open("acm", std::ios_base::app);
    //outfile<<"write here"<<endl
    //outfile.close();
    string s;
    cin>>s;
    
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = [int(m) for m in input().split()]
sum = 0
for i in range(n):
    if a[i] > 0:
        sum += a[i]

sei = 0
fu = 0
for i in range(k):
    if a[i] > 0:
        sei += a[i]
    else:
        fu += a[i]
zen = sei + fu
ansli = []
if zen > 0:
    ansli.append(sum + fu)
else:
    ansli.append(sum - sei)
for i in range(k, n):
    if a[i] > 0:
        sei += a[i]
    else:
        fu += a[i]
    if a[i - k] > 0:
        sei -= a[i - k]
    else:
        fu -= a[i - k]
    zen = sei + fu
    if zen > 0:
        ansli.append(sum + fu)
    else:
        ansli.append(sum - sei)
print(max(ansli))

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


int main() {
  int N;
  cin >> N;
  vector<int> A(N-1);
  for (auto i = 0; i < N-1; ++i) {
    cin >> A[i];
  }

  vector<int> Buka(N);
  for (auto i = 0; i < N-1; ++i) {
    ++Buka[A[i]-1];
  }

  for (auto& x : Buka) {
    cout << x << endl;
  }
}

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

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> h(n);
  for (size_t i = 0; i < n; i++) {
    std::cin >> h.at(i);
  }
  int count = 0;
  int max_h = 0;
  for (size_t i = 0; i < n; i++) {
    if (h.at(i) >= max_h) {
      /* code */
      count++;
      max_h = h.at(i);
    }
  }
  std::cout << count << '\n';
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
ans = A[0]
M = N-2
for i in range(1,N):
    if M <= 0:
        break
    ans += A[i]
    M -= 1
    if M <= 0:
        break
    ans += A[i]
    M -= 1
    
print(ans)

Measured memory_bytes: 94284
#include <iostream>
#include <cstdio>
using namespace std;
int k, n;
int a[200010], ans = 0x7f7f7f7f;
int main() {
	cin >> k >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		ans = min(ans, a[i] + k - a[i + 1]);
	}
	ans = min(ans, a[n] - a[1]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
template <typename Container> void P(const Container &c) {
    for (const auto& x : c) cout << x << ' '; cout << '\n';
}
const int MOD = 1000000007;
int main()
{
    string S; cin >> S;
    for (int i = (S.size()-1) / 2; i > 0; i--) {
        if (S.substr(0, i) == S.substr(i, i)) {
            cout << 2 * i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
ans = ""
while len(s)>0:
    ind = s.find("LR")
    if ind != -1:
        sp = s[:ind+1]
        s = s[ind+1:]
    else:
        sp = s
        s=""
    ind = sp.find("RL")
    l = len(sp)
    lst = [0] * l
    even = l//2
    odd = l-even

    if ind%2==1:
        lst[ind] = even
        lst[ind+1] = odd
    else:
        lst[ind] = odd
        lst[ind+1] = even

    maped_list = map(str, lst)
    mojiretu = ' '.join(maped_list)
    ans = ans + " " + mojiretu

    #print(lst)
    


print(ans[1:])

Measured memory_bytes: 10484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
bool notT(bool T){
    if(T) return false;
    else return true;
}
int main(void){
    string s;
    cin>>s;
    ll q;
    cin>>q;
    vector<string>s1,s2;
    bool T=true;
    rep(0,i,q){
        ll q1;
        cin>>q1;
        if(q1==1){
            T=notT(T);
        }else{
            ll q2;
            cin>>q2;
            if(T){
                string c;
                cin>>c;
                if(q2==1){
                    s1.push_back(c);
                }else{
                    s2.push_back(c);
                }
            }else{
                string c;
                cin>>c;
                if(q2==1){
                    s2.push_back(c);
                }else{
                    s1.push_back(c);
                }
            }
        }
    }
    ll n0=s.length(),n1=s1.size(),n2=s2.size();
    vector<string> s0(n0);
    rep(0,i,n0)s0[i]=s.substr(i,1);
    if(T){
        rep(0,i,n1)cout<<s1[n1-1-i];
        rep(0,i,n0)cout<<s0[i];
        rep(0,i,n2)cout<<s2[i];
        cout<<endl;
    }else{
        rep(0,i,n2)cout<<s2[n2-1-i];
        rep(0,i,n0)cout<<s0[n0-i-1];
        rep(0,i,n1)cout<<s1[i];
        cout<<endl;
    }
}

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

using namespace std;

int main () {
	int H, W;
	cin >> H >> W;
	// 境界外は'.'としておく
	vector<char> one_row(W+2,'.');// 両サイド余分に1つずつ
	vector<vector<char> > s(H+2, one_row);// 両サイド余分に1つずつ
	for (int i=1; i<=H; ++i) {
		for (int j=1; j<=W; ++j) {
			cin >> s[i][j];
		}
	}
	// 「孤立した」#がなければ"Yes"となる。
	bool is_yes = true;
	for (int i=1; i<=H; ++i) {
		for (int j=1; j<=W; ++j) {
			if (s[i][j] == '#') {
				bool is_ok = 
					s[i-1][j] == '#' || s[i+1][j] == '#' ||
					s[i][j-1] == '#' || s[i][j+1] == '#';
				if (!is_ok) {
					is_yes = false;
					goto flag;
				}
			}
		}
	}
flag:
	// answer:"Yes", "No"
	cout << (is_yes ? "Yes" : "No") << endl;
	return 0;
}



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

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  
  vector<vector<int>> vec(n, vector<int>(3));
  for (int i=0; i<n; i++){
    for (int j=0; j<3; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  int x_m = 0, x_M = w, y_m = 0, y_M = h;
  
  for (int i=0; i<n; i++){
    if(vec.at(i).at(2) == 1){
      x_m = max(x_m, vec.at(i).at(0));
    }
    if(vec.at(i).at(2) == 2){
      x_M = min(x_M, vec.at(i).at(0));
    }
    if(vec.at(i).at(2) == 3){
      y_m = max(y_m, vec.at(i).at(1));
    }
    if(vec.at(i).at(2) == 4){
      y_M = min(y_M, vec.at(i).at(1));
    }
  }
  if (x_M>=x_m && y_M>=y_m){
    cout << (x_M-x_m)*(y_M-y_m) << endl;
  }
  else{
    cout << 0 << endl;
  }
}

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

int main()
{
  string S;
  cin >> S;
  int count=0;
  int len=S.length();
  
  for (int i; i< len/2; i++)
  {
    if (S.at(i) != S.at(len-1-i))
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
using System;
 
class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    
    string a = input[0].ToUpper();
    string b = input[1].ToUpper();
    string c = input[2].ToUpper();
    
    Console.WriteLine("{0}{1}{2}", a[0], b[0], c[0]);
  }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include <string.h>
using namespace std;
int main()
{

  int A_initial,B_initial;
  scanf("%d %d", &A_initial, &B_initial);
  if(A_initial%2==1){
    if(B_initial%2==1){
      printf("Yes\n");
      return 0;
   }
  }

  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
// B - ∵∴∵

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	string O, E;
	cin >> O >> E;

	for (int i=0; i<O.size(); i++) {
		cout << O[i];
		if (i < E.size()) cout << E[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top + 1];
}

int main(int argc, char const *argv[])
{
    int a, b;
    top = 0;
    char s[100];
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            b = pop();
            a = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') {
            b = pop();
            a = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
}




Measured memory_bytes: 2044
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N,M =LI()
X,Y=[],[]
for i in range(M):
	a = LI()
	if a[0] == 1:
		X.append(a[1])
	if a[1] == N:
		Y.append(a[0])
X=set(X)
Y=set(Y)
for x in X:
	if x in Y:
		print("POSSIBLE")
		exit()
	

	
print("IMPOSSIBLE")

Measured memory_bytes: 93272