akhauriyash/Code-Regression huggingface dataset:
using System;
class Solution
{
   static void Main(string[] args)
   {
      int num = int.Parse(Console.ReadLine());
      int r = 0;
      int b = 0;
      string input = Console.ReadLine();
      for(int i = 0; i < num; i++)
      {
        if(input[i] == 'B') b++;
        if(input[i] == 'R') r++;
      }
     
      if(r > b) Console.WriteLine("Yes");
      else Console.WriteLine("No"); 
   }
}

Measured memory_bytes: 11092
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

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

using namespace std;



//bubble_sort
template<class T> inline void myswap(T& a,T& b)
{
	T tmp;
	tmp = a;
	a = b;
	b = tmp;
}


template<class _RanIt,class _Diff> inline	void _bubble_sort (_RanIt _Array,_Diff _Count)
{
	for(_Diff i = 0; i < _Count; i++)
	{
		for(_Diff j = _Count - 1; j > i; j--)
		{
			if(_Array[j] < _Array[j-1])
			{
				myswap(_Array[j],_Array[j-1]);
			}

		}
	}	
}

template<class _RanIt,class _Diff,class _Pr> inline void _bubble_sort (_RanIt _Array,_Diff _Count,_Pr Pred)
{
	for(_Diff i = 0; i < _Count; i++)
	{
		for(_Diff j = _Count - 1; j > i; j--)
		{
			if(Pred(_Array[j] , _Array[j-1]))
			{
				myswap(_Array[j],_Array[j-1]);
			}

		}
	}	

}

template<class _RanIt> inline	void bubble_sort(_RanIt _First,_RanIt _Last)
{
	_bubble_sort(_First,_Last - _First);
}

template<class _RanIt,class _Pr> inline	void bubble_sort (_RanIt _First,_RanIt _Last, _Pr _Pred)
{
	_bubble_sort(_First,_Last - _First,_Pred);
}
	
int main()
{
	
	int a[10];
	rep(i,10) cin>>a[i];

	bubble_sort(a,a+10);


	cout<<a[9]<<endl;
	cout<<a[8]<<endl;
	cout<<a[7]<<endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>

using namespace std;

int W, H, sw, sh, cnt;
char tiles[20][20];
int dw[4] = {-1, 0, 0, 1};
int dh[4] = {0, -1, 1, 0};


void dfs(int w, int h)
{
	tiles[h][w] = '#';
	cnt++;
	
	for (int i=0; i<4; i++)
	{
		int nw = w + dw[i];
		int nh = h + dh[i];
		
		if (0<=nw && nw<W && 0<=nh && nh<H && tiles[nh][nw]=='.')
		{
			dfs(nw, nh);
		}
	}
}


int main()
{
	while (cin >> W >> H)
	{
		if (W == 0 && H == 0) break;
		
		//入力
		for (int i=0; i<H; i++)
		{
			cin >> tiles[i];
		}
		
		//スタート地点を探す
		for (int i=0; i<H; i++)
		{
			for (int j=0; j<W; j++)
			{
				if (tiles[i][j] == '@')
				{
					sw = j;
					sh = i;
					break;
				}
			}
		}
		
		cnt = 0;
		dfs(sw, sh);
		cout << cnt << endl;
		
		//cout << "sw = " << sw << " : sh = " << sh << endl;
		
		/*
		//テスト出力
		for (int i=0; i<H; i++)
		{
			cout << tiles[i] << endl;
		}
		*/
	}
	
	return 0;
}

Measured memory_bytes: 1172
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder (f : int -> unit) t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder (f : int -> unit) t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  print_newline ();
  preorder (fun e -> print_string " "; print_int e) t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let delete x t =
  let rec balance = function
    | Nil -> assert false
    | Node (x, Nil, r) -> (x, r)
    | Node (x, l, r) ->
      let (m, l) = balance l in
      (m, Node (x, l, r)) in
  let rec doit = function
    | Nil -> assert false
    | Node (y, l, r) ->
      if x = y then
        if l = Nil then r
        else if r = Nil then l
        else
          let (m, r) = balance r in
          Node (m, l, r)
      else if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    match read_line () |> split_on_char ' ' with
    | ["insert"; n] -> t := insert (int_of_string n) !t
    | ["find"; n] -> print_endline (if find (int_of_string n) !t then "yes" else "no")
    | ["delete"; n] -> t := delete (int_of_string n) !t
    | _ -> print !t
  done

Measured memory_bytes: 25264
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>
#include <map>
using namespace std;

class state{
public:
  int x,y,l;
  state(int y=0, int x=0, int l=0):y(y),x(x),l(l){}
  bool operator < (const state &s) const {return l > s.l;}
};

const int INF = (1<<29);
typedef pair<int,int> P;
int r,h,w,rx,ry,a[500][500];
int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
bool f[500][500];
vector<int> numr[2],numl[2];
map<int,int> m[2];

bool check(int y, int x){
  if(y < 0 || y >= h) return false;
  if(x < 0 || x >= w) return false;
  return true;
}

void bfs(int k){
  int maxl = 0;
  priority_queue<state> Q;
  state u,v;

  m[k].clear();
  fill(f[0],f[max(h,w)],false);
  f[ry][rx] = true;
  Q.push(state(ry,rx,1));
  while(!Q.empty()){
    u = Q.top();
    Q.pop();

    if(u.l > maxl){
      m[k][u.l] = m[k][maxl] + 1;
      maxl = u.l;
    } else m[k][maxl]++;

    for(int i=0;i<4;i++){
      v.x = u.x + dx[i];
      v.y = u.y + dy[i];
      if(check(v.y,v.x) && !f[v.y][v.x]){
	f[v.y][v.x] = true;
	v.l = a[v.y][v.x];
	Q.push(v);
      }
    }
  }

  numr[k].clear();
  numl[k].clear();
  for(map<int,int>::iterator it=m[k].begin(); it!=m[k].end(); it++){
    numl[k].push_back(it->first);
    numr[k].push_back(it->second);
  }

}

int main(){
  while(cin >> r && r){
    int ans = INF;
    for(int k=0;k<2;k++){
      cin >> w >> h >> rx >> ry;
      rx--;
      ry--;
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  cin >> a[i][j];
      bfs(k);      
    }

    for(int i=0;i<numr[0].size();i++){
      if(numr[0][i] >= r){
	ans = min(numl[0][i],ans);
	break;
      }
      int cnt = r - numr[0][i];
      int pos = upper_bound(numr[1].begin(), numr[1].end(), cnt) - numr[1].begin();
      if(pos < numr[1].size()) ans = min(ans,numl[0][i] + numl[1][pos]);
      pos = max(0,pos-1);
      if(numr[0][i] + numr[1][pos] >= r) ans = min(ans,numl[0][i] + numl[1][pos]);
    }
    int pos = upper_bound(numr[1].begin(), numr[1].end(), r) - numr[1].begin();
    if(pos < numr[1].size()) ans = min(ans,numl[1][pos]);
    pos = max(0,pos-1);
    if(numr[1][pos] >= r) ans = min(ans,numl[1][pos]);

    cout << ans << endl;
  }
}

Measured memory_bytes: 15036
#include <iostream>
#include <string>

using namespace std;
bool used[27];

int check(int x) {
    for (int i = x + 1; i < 26; ++i) {
        if (!used[i]) return i;
    }
    return -1;
}

int main() {
    string s;
    cin >> s;
    int n = (int) s.size();
    for (int i = 0; i < n; ++i) {
        used[s[i] - 'a'] = true;
    }

    int able;
    for (int i = 0; i < 27; ++i) {
        if (!used[i]) {
            able = i;
            break;
        }
    }
    if (able != 26) {
        cout << s << (char) ('a' + able) << endl;
        return 0;
    }

    for (int i = n - 1; i >= 0; --i) {
        int nc = check(s[i] - 'a');
        if (nc == -1) {
            used[s[i] - 'a'] = false;
        } else {
            for (int j = 0; j < i; ++j) {
                cout << s[j];
            }
            cout << (char) ('a' + nc) << endl;
            return 0;
        }
        if (i == 0) cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
  h, w, n = map(int, input().split())
  mp = ["X" + input() + "X" for _ in range(h)]
  mp.insert(0, "X" * (w + 2))
  mp.append("X" * (w + 2))
  
  poss = [None] * (n + 1)
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if mp[y][x] == "S":
        poss[0] = (x, y)
      elif "1" <= mp[y][x] <= "9":
        poss[int(mp[y][x])] = (x, y)
  
  ans = 0
  vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
  for i in range(n):
    sx, sy = poss[i]
    gx, gy = poss[i + 1]
    used = [[False] * (w + 2) for _ in range(h + 2)]
    used[sy][sx] = True
    que = deque()
    push = que.append
    pop = que.popleft
    push((0, sx, sy))
    while que:
      cnt, x, y = pop()
      if (x, y) == (gx, gy):
        ans += cnt
        break
      
      for dx, dy in vec:
        nx, ny = x + dx, y + dy
        if used[ny][nx] or mp[ny][nx] == "X":continue
        used[ny][nx] = True
        push((cnt + 1, nx, ny))
  
  print(ans)

main()


Measured memory_bytes: 22960
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n;cin>>n;
    if(n<357){
        cout<<"0";
        return 0;
    }
    
    vector<long> a={3,5,7};
    vector<long> ap=a;
    vector<long> k={3,5,7};
    for(int i=1;i<9;i++){
        vector<long> aa;
        for(auto x:k){
            for(auto y:ap){
                long t=pow(10,i)*x;
                aa.push_back(t+y);
            }
        }
        a.insert(end(a),begin(aa),end(aa));
        ap=aa;
    }
    long count=0;
    for(auto x:a){
        if(x<=n){
            int c[3]={0};
            while(x!=0){
                int t=x%10;
                if(t==3)
                    c[0]=1;
                if(t==5)
                    c[1]=1;
                if(t==7)
                    c[2]=1;
                x/=10;
            }
            if(c[0]==1&&c[1]==1&&c[2]==1)
                count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 1024
module Main where


main :: IO ()
main = do
    [k, n] <- map read . words <$> getLine
    homeList <- map read . words <$> getLine

    let numList = getNum (homeList ++ [k+(head homeList)])
    let sumNum = foldl (\acc x-> acc + x ) 0 numList
    let maxNum = foldr (\acc x -> if x>acc then x else acc) 0 numList
    putStrLn (show (sumNum - maxNum))

getNum :: [Int]->[Int]
getNum [] = []
getNum (_:[]) = []
getNum (x:xs) = [(head xs)-x] ++ getNum xs



Measured memory_bytes: 86268
#include<iostream>

using namespace std;

int main(){
    int a[5];
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    int ind = 0;
    for (int i = 0; i < 5; i++)
    {
        if((a[ind]-1)%10>(a[i]-1)%10)
        {
            ind = i;
        }
    }
    int time = 0;
    for (int i = 0; i < 5; i++)
    {
        if(i!=ind)
        {
            if(a[i]%10!=0)
            {
                time += a[i] + 10 - a[i] % 10;
            }
            else
            {
                time += a[i];
            }
        }
        else
        {
            time += a[i];
        }
    }
    cout << time << endl;
    return 0;
}

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


int main(){
    ll n; cin >> n;
    ll ans = 0;
    for(int i=1; i<n; i++){
        ll tmp = ceil((double)n/i);
        ans += tmp - 1;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define io  ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main(){
    double d;
    cin>>d;
    d=2*pi*d;
   printf("%.6lf\n",d);

return 0;
}


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

typedef long long ll;

const ll N = 2000 + 10, inf = 1e18;
ll dp[N][N], a[N];

int main() {
	ll n, x;
  	cin >> n >> x;
  	for (int i = 0; i < n; i++)
    	cin >> a[i];
	for (int i = 0; i < n; i++)
    	dp[0][i] = a[i];
    for (int i = 1; i < n; i++)
		for (int j = 0; j < n; j++)
  			dp[i][j] = min(dp[i - 1][j], a[(i + j) % n]);
	ll ans = inf;
  	for (int i = 0; i < n; i++) {
    	ll cnt = x * i;
    	for (int j = 0; j < n; j++)
			cnt += dp[i][j];
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 31616
#include<stdio.h>
#define N 100000
#define INFTY 1000000000
 
struct Card{
  char suit;
  int value;
};
 
struct Card L[N], R[N];
 
void merge(struct Card [], int , int , int );
void mergeSort(struct Card [], int , int ); 
int partition(struct Card [], int , int );
void quickSort(struct Card [], int , int );
 
 
int main(){
   
  int n, i, v;
  struct Card A[N], B[N];
  char S[10];
  int stable = 1;
   
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = S[0];
    B[i].suit = S[0];
    A[i].value = v;
    B[i].value = v;
  }
 
  mergeSort(A, 0, n);
  quickSort(B, 0, n-1);
 
  for ( i = 0; i < n; i++ ){
    if ( A[i].suit != B[i].suit ) {
      stable = 0;
    }
  }
 
  if ( stable == 1 ) {
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  return 0;
}
 
void merge(struct Card A[], int l, int mid, int r){
   
  int i, j, k, n1, n2;
   
  n1 = mid - l;
  n2 = r - mid;
   
  for(i=0;i<n1;i++){
    L[i] = A[l + i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid + i];
  }
 
  L[n1].value=INFTY;
  R[n2].value=INFTY;
  i=0;
  j=0;
   
  for ( k = l; k < r; k++ ){
    if ( L[i].value <= R[j].value ){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}
 
void mergeSort(struct Card A[], int l, int r){
   
  int mid;
   
  if (l+1 < r){
    mid = (l + r)/2;
    mergeSort(A, l, mid);
    mergeSort(A, mid, r);
    merge(A,l, mid, r);
  }
}
 
int partition(struct Card A[], int p, int r){
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j <= r-1; j++ ){
    if ( A[j].value <= x.value ){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;   
  return i+1;
}

void quickSort(struct Card A[], int p, int r){
  int q; 
  if ( p < r ){
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

Measured memory_bytes: 2956
#include<bits/stdc++.h> 
using namespace std; 
 
int main(){
	long int n,k;
	const int max = 200001;
	cin>>n>>k;
	
	long int sum[max+3] = {};
	for(int i=1;i<=max;i++)
		sum[i] = sum[i-1] + i;
	
	long int mod = 1e9+7;
	long int ans = 0;
	
	for(int i = k ;i<=n;i++){
		long int mi = sum[i-1];
		long int ma = sum[n] - sum[n-i];
		ans += (ma - mi + 1);
		ans %= mod;
	}
	ans += 1;
	ans %= mod;
	cout<<ans<<endl;
}


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

int ara[3][(int)2e5];
int  dp[3][(int)2e5];


int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	for(int i = 0; i < n;i++){
		for(int j = 0; j < 3;j++){
			scanf("%d",&ara[j][i]);
		}
	}
	dp[0][0] = ara[0][0];
	dp[1][0] = ara[1][0];
	dp[2][0] = ara[2][0];
	for(int i = 0; i < n-1;i++){
		dp[0][i+1] = max(dp[1][i]+ara[0][i+1],dp[2][i]+ara[0][i+1]);
		dp[1][i+1] = max(dp[0][i]+ara[1][i+1],dp[2][i]+ara[1][i+1]);
		dp[2][i+1] = max(dp[1][i]+ara[2][i+1],dp[0][i]+ara[2][i+1]);
	}
	printf("%d\n",max({dp[0][n-1],dp[1][n-1],dp[2][n-1]}));

	return 0;
}

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

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

    int32_t s = 0;
    for (int32_t i = 0; i <= n; i++) {
        s += abs(a[i + 1] - a[i]);
    }

    for (int32_t i = 1; i <= n; i++) {
        int32_t answer = s - (abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i])) + abs(a[i + 1] - a[i - 1]);
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
int main(){
	int n;
	int *A = NULL;
	int i,j;
	int temp;
	int minj;
	int count = 0;

	scanf("%d",&n);
	A = (int *)malloc(4*n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	for(i=0;i<n;i++){
		minj = i;
		for(j=i;j<n;j++){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		if(i != minj){
			temp = A[minj];
			A[minj] = A[i];
			A[i] = temp;
			count++;
		}
		
	}
	for(i=0;i<n-1;i++){
		printf("%d ",A[i]);
	}
	printf("%d\n",A[n-1]);
	printf("%d\n",count);
	free(A);
}

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

int main() {
  ios::sync_with_stdio(false);
  unordered_set<int> S;
  int N, A;
  cin >> N;
  while (cin >> A) {
    if (S.count(A)) S.erase(A);
    else S.insert(A);
  }

  cout << S.size() << "\n";
}

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

template <class T>
struct SegmentTree {
  // 1-indexed
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) {
    init(newn);
  }
  void init(int newn) {
    n = 1;
    while(n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while(k >>= 1) {
      dat[k] = f(dat[(k << 1)], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, dat[l++]);
      if(r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};

struct data {
  long long all, lef, righ, ans;
  data(long long a, long long b, long long c, long long d)
      : all(a), lef(b), righ(c), ans(d) {}
};

long long n, q;
vector<long long> a;

int main() {
  auto f = [](data l, data r) {
    data now = l;
    now.all += r.all;
    now.lef = max(now.lef, l.all + r.lef);
    now.righ = max(r.righ, l.righ + r.all);
    now.ans = max({l.ans, r.ans, now.lef, now.righ, now.all,
                   l.righ + r.lef});
    return now;
  };
  cin >> n >> q;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  SegmentTree<data> seg(n, f, data(0, 0, 0, 0));
  for(int i = 0; i < n; ++i)
    seg.update(i, {a[i], max(0LL, a[i]), max(0LL, a[i]),
                   max(0LL, a[i])});
  cout << seg.query(0, n).ans << endl;
  for(int i = 0; i < q; ++i) {
    long long k, x;
    cin >> k >> x;
    seg.update(k - 1,
               {x, max(0LL, x), max(0LL, x), max(0LL, x)});
    cout << seg.query(0, n).ans << endl;
  }
  return 0;
}


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

#define ll long long
 
int main(void){
    string s,t;
    cin >> s>>t;
    bool flag = true;
    vector<char>words(int('z')+1);
    vector<char>wordt(int('z')+1);
    for(int i=0;i<words.size();i++){
        words[i] = '0';
        wordt[i] = '0';
        // cout << words[i]<<' ';
    }

    for(int i=0;i<s.length();i++){
        if(words[int(s[i])]=='0'){
            words[int(s[i])] = t[i];
        }else if(words[int(s[i])] != t[i] ){
            flag = false;
        }
    }

    for(int i=0;i<t.length();i++){
        if(wordt[int(t[i])]=='0'){
            wordt[int(t[i])] = s[i];
        }else if(wordt[int(t[i])] != s[i]){
            flag = false;
        }
    }

    // for(int i=0;i<words.size();i++){
    //     cout << words[i] <<' ';
    // }

    if(flag == true){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
    return 0;

}

Measured memory_bytes: 776
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD   = 1000000007;
const int MAXN  = 200005;

int64 a[MAXN];

void run() {
    int n, k;
    cin >> n >> k;
    int cntp = 0, cntn = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > 0)
            cntp++;
        else if (a[i] < 0)
            cntn++;
    }
    sort(a, a + n);
    int64 ans = 1;
    if (k <= min(k & (~1), cntn & (~1)) + cntp) {
        int j = n - 1;
        if (k & 1)
            ans *= a[j--];
        vector<int64> b;
        for (int i = 0; i < (cntn & (~1)); i += 2)
            b.pb(a[i] * a[i + 1]);
        for (int i = j; i > n - cntp; i -= 2)
            b.pb(a[i] * a[i - 1]);
        sort(b.begin(), b.end());
        for (int i = sz(b) - 1; i >= sz(b) - k / 2; i--)
            ans = ((b[i] % MOD) * ans) % MOD;
    } else if (cntp + cntn != n) {
        ans = 0;
    } else {
        int j = cntn - 1;
        if (k & 1)
            ans *= a[j++];
        vector<int64> b;
        for (int i = cntn - 2; i > 0; i -= 2)
            b.pb(a[i] * a[i - 1]);
        for (int i = j; i < n - 1; i += 2)
            b.pb(a[i] * a[i + 1]);
        sort(b.begin(), b.end());
        for (int i = 0; i < k / 2; i++)
            ans = ((b[i] % MOD) * ans) % MOD;
        ans = (ans + MOD) % MOD;
    }
    cout << ans << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}


Measured memory_bytes: 5844
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007;

int main() {
    int n;
    cin>>n;
    int lim=pow(2,n);
    vector <vector<int>> match(n,vector <int>(n,0));
    vector <int> vec(lim,0);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
        cin>>match[i][j];    
        }
    }
    vec[0]=1;
    for(int i=0;i<lim;i++){
        int row=0;
        int check=1;
        for(int j=0;j<n;j++){
            int band=i&check;
            if(band==check)row++;
            check*=2;
        }
        //cout<<i<<" "<<row<<" row "<<endl;
        if(row<n){
            int check=1;
            for(int j=0;j<n;j++){
            if(match[row][j]==1){
                int band=i&check;
                //cout<<j<<" "<<band<<endl;
                if(band==0){
                int bor=i|check;
                vec[bor]=(vec[bor]+vec[i])%mod;
                }}
                check*=2;
            }    
        }
    }
    cout<<vec[lim-1]<<endl;
}

Measured memory_bytes: 8448
#include <cstdio>

int num[101];

int main(){
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF){
		if(a == 0 && b == 0){
			if(num[1]%2==1&&num[2]%2==1){
				bool ok = true;
				for(int i = 3; i <= 100; i++){
					if(num[i]%2==1){
						ok = false;
						break;
					}
				}
				if(ok) printf("OK\n");
				else printf("NG\n");
			} else printf("NG\n");
			for(int i = 0; i < 101; i++) num[i] = 0;
		} else{
			num[a]++;
			num[b]++;
		}
	}
}

Measured memory_bytes: 1012
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T>
struct Stack{
private:
    T* begin;
    int size;
    int end;
    
public:
    Stack(){
        begin=(T*)malloc(sizeof(T));
        size=1;
        end=0;
    }
    
    ~Stack(){free(begin);}
    
    void push(const T &data){
        if(end==size){
            T* New=(T*)realloc(begin,sizeof(T)*(size<<=1));
            if(New==NULL){
                free(begin);
                assert(false);
            }
            begin=New;
        }
        *(begin+(end++))=data;
    }
    
    T top() const {
        assert(end>0);
        return *(begin+(end-1));
    }
    
    void pop(){
        assert(end>0);
        --end;
    }
    
    bool empty() const {return end==0;}
};


template<typename T>
struct Queue{
private:
    Stack<T> L;
    Stack<T> F;
    
    void change(){
        while(!L.empty()){
            F.push(L.top());
            L.pop();
        }
    }
    
public:
    void push(const T &data){
        L.push(data);
    }
    
    void pop(){
        if(F.empty()){change();}
        assert(!F.empty());
        F.pop();
    }
    
    T front(){
        if(F.empty()){change();}
        assert(!F.empty());
        return F.top();
    }
    
    bool empty() const {
        return F.empty() && L.empty();
    }
};




int main(){
    typedef pair<string,ll> node;
    Queue<pll> q;
    ll n,t;
    cin>>n>>t;
    vector<node> dp(n);
    for(int i=0;i<n;i++){
        string s;
        ll a;
        cin>>s>>a;
        q.push({i,a});
        dp[i].F=s;
    }
    ll count=0;
    while(!q.empty()){
        pll N=q.front();
        q.pop();
        if(N.S<=t){
            count+=N.S;
            dp[N.F].S=count;
            cout<<dp[N.F].F<<" "<<dp[N.F].S<<endl;
        }
        else{
            count+=t;
            N.S-=t;
            q.push(N);
        }
    }
    
    
    
    return 0;
}



Measured memory_bytes: 7664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin>>n;
    vector<int> odd(100010,0),even(100010,0);
    for(int i=0;i<n/2;i++){
        cin>>a>>b;odd[a]++;even[b]++;
    }
    int o1=0,o2=0,e1=0,e2=0,on,en;
    for(int i=0;i<=100000;i++){
        if(odd[i]>o1){
            o2=o1;o1=odd[i];on=i;
        }
        else if(odd[i]>o2)
        o2=odd[i];
        if(even[i]>e1){
            e2=e1;e1=even[i];en=i;
        }
        else if(even[i]>e2)
        e2=even[i];
    }
    int ans;
    if(on==en)
    ans=max(e2,o2)+e1;
    else
    ans=e1+o1;
    cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
namelist = [input().split() for i in range(N)]
for i in range(N):
  namelist[i].append(i+1)
namelist.sort(key=lambda x:-int(x[1]))
namelist.sort(key=lambda x:x[0])
for i in range(N):
  print(namelist[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
//lli p = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    lli d, t, s;
    cin>>d>>t>>s;
    if (t*s>=d) cout<<"Yes";
    else cout<<"No\n";
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    int n;cin >> n;
    vi v(n);
    vi even;
    vi odd;
    rep(i,n){
        int tmp;cin >> tmp;
        if(i%2==0)even.push_back(tmp);
        else odd.push_back(tmp);
        v[i] = tmp;
    }
    //全ての数が同じ
    if(count(ALL(v), v[0]) == v.size()){
        cout << n / 2 << endl;
        return 0;
    }else if(count(ALL(even), even[0]) == even.size() && count(ALL(odd), odd[0]) == odd.size()){
        //それぞれの数列で全ての数が同じ
        cout << 0 << endl;
        return 0;
    }

    sort(ALL(even));
    sort(ALL(odd));

    vector<pair<int,int>> runlen_even;
    runlen_even.push_back({even[0], 1});
    for(int i=1;i<n/2;i++){
        if(runlen_even.back().first == even[i]){
            runlen_even.back().second++;
        }else{
            runlen_even.push_back({even[i], 1});
        }
    }

    vector<pair<int,int>> runlen_odd;
    runlen_odd.push_back({odd[0], 1});
    for(int i=1;i<n/2;i++){
        if(runlen_odd.back().first == odd[i]){
            runlen_odd.back().second++;
        }else{
            runlen_odd.push_back({odd[i], 1});
        }
    }
    
    sort(ALL(runlen_even), [](auto a, auto b){
        if(a.second > b.second)return true;
        else return false;
    });
    sort(ALL(runlen_odd), [](auto a, auto b){
        if(a.second > b.second)return true;
        else return false;
    });

    if(runlen_even[0].first != runlen_odd[0].first){
        cout << v.size() - (runlen_even[0].second + runlen_odd[0].second) << endl;
    }else{
        int Max = max(runlen_even[0].second + runlen_odd[1].second, runlen_even[1].second + runlen_odd[0].second);
        cout << v.size() - Max << endl;

    }
    return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
vector<int> v[1<<17];int n,k,a,y,t,i=1;
int s(int x,int p=0){int r=0;for(t:v[x])r=max(r,s(t,x));a+=++r>=k&&p;return r%k;}
int main(){cin>>n>>k>>y;a=(y!=1);while(i<n){cin>>y;v[y-1].push_back(i++);}s(0);cout<<a;}

Measured memory_bytes: 11136
s = input()
k = int(input())

#alphabet = "abcdefghijklmnopqrstuvwxyz"
candidates = []

for i in range(len(s)):
  for j in range(i + 1, len(s) + 1):
    if not s[i:j] in candidates:
      candidates += [s[i:j]]
    if len(s[i:j]) >= k:
      break

candidates.sort()
print(candidates[k - 1])

Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <functional>
#include <queue>
#include <tuple>
#include <cstring>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define each(i,n) for(auto i : n)
#define clr(n) memset(n,0,sizeof(n))
#define mclr(n) memset(n,-1,sizeof(n))

//2^8 * 100 * 500 * 24
int INF = 1e9;
int n, m, H, K;
int c[105][105];
int h[105][105];
int r[105][105];

int l[300];
int d[300];
int k[300];
int s, t, p;

int me[(1 << 8) + 1][(1 << 8) + 1];
int ct[105][30];

int solve(int i, int bit, int tg) {
	if (me[i][bit] != -1)return me[i][bit];
	if (i == p) {
		if ((bit & tg) == tg) {
			return 0;
		}
		else {
			return INF;
		}
	}
	return me[i][bit] = min(solve(i + 1, bit, tg), solve(i + 1, bit | k[i], tg) + d[i]);
}

vector<vector<int>> ce;
int main() {

	while (cin >> n >> m >> H >> K && n) {
		mclr(c);
		mclr(h);
		mclr(r);
		mclr(l);
		mclr(d);
		clr(k);
		ce.clear();
		ce.resize(n);
		rep(i, m) {
			int a, b, e, f, g;
			cin >> a >> b >> e >> f >> g;
			a--; b--;
			g--;
			ce[a].push_back(b);
			ce[b].push_back(a);
			c[a][b] = c[b][a] = e;
			h[a][b] = h[b][a] = f;
			r[a][b] = r[b][a] = g;
		}
		cin >> s >> t >> p;
		s--; t--;
		rep(i, p) {
			cin >> l[i] >> d[i];
			rep(j, l[i]) {
				int tmp;
				cin >> tmp;
				tmp--;
				k[i] |= (1 << tmp);
			}
		}
		int ans = INF;
		rep(bit, 1 << K) {
			mclr(me);
			int cost = solve(0, 0, bit);
			if (cost == INF)continue;
			rep(i, 105)rep(j, 30) {
				ct[i][j] = INF;
			}
			ct[s][0] = cost;
			typedef tuple<int, int, int> T;
			priority_queue<T, vector<T>, greater<T>> qu;
			qu.push(T(cost, s, 0));
			while (qu.size()) {
				int mc = get<0>(qu.top());
				int nw = get<1>(qu.top());
				int tm = get<2>(qu.top());
				qu.pop();
				if (ct[nw][tm] < mc)continue;
				each(i, ce[nw]) {
					if (c[nw][i] != -1) {
						int nt = tm + h[nw][i];
						if (nt <= H) {
							int nc = ct[nw][tm];
							if (!(bit & (1 << r[nw][i]))) {
								nc += c[nw][i];
							}
							if (nc < ct[i][nt]) {
								ct[i][nt] = nc;
								qu.push(T(nc, i, nt));
							}
						}
					}
				}
			}
			rep(i, H + 1) {
				ans = min(ans, ct[t][i]);
			}
		}
		if (ans == INF)ans = -1;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

LL solve(LL n, vector<LL>& a){
    vector<LL> max_n(n+1);
    LL total = 0;
    for(LL i = n; i >= 0; --i){
        total += a[i];
        max_n[i] = total;
    }
    LL ans = 0;
    LL rest = 1;
    for(LL i = 0; i <= n; ++i){
        ans += rest;
        rest -= a[i];
        if(rest < 0) return -1;
        if(i < n){
            rest = min(rest*2, max_n[i+1]);
        }
    }
    assert(rest == 0);
    return ans;
}

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n+1);
    for(LL i = 0; i < n+1; ++i){
        cin >> a[i];
    }
    cout << solve(n, a) << endl;
    return 0;
}



Measured memory_bytes: 4404
import sys
sys.setrecursionlimit(100000)
a=[int(input()) for i in range(int(input()))]
import bisect
LIS = [a[0]]
for i in range(len(a)):
    if a[i]>LIS[-1]:
        LIS.append(a[i])
    else:
        LIS[bisect.bisect_left(LIS,a[i])] = a[i]
print(len(LIS))



Measured memory_bytes: 10360
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a-lin bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int N;cin >> N;
    vector<long long> T(N),A(N);
    for(int i = 0;i<N;i++) cin >> T.at(i);
    for(int i = 0;i<N;i++) cin >> A.at(i);
    if(T.at(N-1) != A.at(0)){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1;
    for(int i = 0;i<N;i++){
        //高橋君と青木君の最初の山は高さが確定
        if(i == 0 || i == N-1){
            continue;
        }
        //前の山より増えていたら高さが確定する→それが条件を満たすか？
        //二人とも更新→記録が同じでないといけない
        if(T.at(i) > T.at(i-1) && A.at(i) > A.at(i+1) && T.at(i) != A.at(i)){
            cout << 0 << endl;
            return 0;
        }
        else if(T.at(i) > T.at(i-1) && A.at(i) == A.at(i+1) && T.at(i) > A.at(i)){
            //高橋君だけ更新→高橋君の高さが青木くんのより高かったらダメ
            cout << 0 << endl;
            return 0;
        }
        else if(T.at(i) == T.at(i-1) && A.at(i) > A.at(i+1) && T.at(i) < A.at(i)){
            //青木君だけ更新→青木君の高さが高橋くんのより高かったらダメ
            cout << 0 << endl;
            return 0;
        }
        else if(T.at(i) == T.at(i-1) && A.at(i) == A.at(i+1)){
            ans *= min(T.at(i),A.at(i));
            ans %= MOD;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  char c[10];
  r(i,10)cin >> c[i];
  c[3]='8';
  r(i,10)cout << c[i];
  cout << endl;
}


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

#define ll long long
struct new1{
string s;
int y,z;
};
bool operator<(const new1 &a, const new1 &b)
{
    if(a.s==b.s){
    return a.y>b.y;
    }
    else{return a.s<b.s;}
}
    int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<new1>v(n);
    for(int i=0;i<n;i++){
    string q;
    int w;
    cin>>q>>w;
    v[i].s=q;
    v[i].y=w;
    v[i].z=i+1;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
    cout<<v[i].z<<endl;
    }}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define poq pop_back
#define tof ios_base :: sync_with_stdio(NULL);cin.tie(0);cout.tie(0)




using namespace std;

char  y[809][809];
bool viz[809][809];
bool vizz[809][809];

int main()
{
    ll h,w,k,X,Y;
    cin>>h>>w>>k;
    for (ll i=0; i<h; i++)
    {
        for (ll j=0; j<w; j++)
        {
            cin>>y[i][j];
            if (y[i][j]=='S')
            {
                X=i;
                Y=j;
            }
        }
    }
    stack<pair<ll,ll> > stk;
    stack<pair<ll,ll>  >sttk;
    stack<pair<ll,ll>  >stttk;
    pair<ll,ll> v;
    stk.push(mp(X,Y));
    stttk.push(mp(X,Y));
    viz[X][Y]=1;


    ll ans=0;
    for (ll i=0; i<k; i++)
    {
        while(!stk.empty())
        {
            v=stk.top();
            if (v.F>0)
            {
                if (y[v.F-1][v.S]!='#')
                {
                    sttk.push(mp(v.F-1,v.S));
                }
            }
            else
            {
                cout<<1;
                return 0;
            }
            if (v.F<h-1)
            {
                if (y[v.F+1][v.S]!='#')
                {
                    sttk.push(mp(v.F+1,v.S));
                }
            }
            else
            {
                cout<<1;
                return 0;
            }
            if (v.S>0)
            {
                if (y[v.F][v.S-1]!='#')
                {
                    sttk.push(mp(v.F,v.S-1));
                }
            }
            else
            {
                cout<<1;
                return 0;
            }
            if (v.S<w-1)
            {
                if (y[v.F][v.S+1]!='#')
                {
                    sttk.push(mp(v.F,v.S+1));
                }
            }
            else
            {
                cout<<1;
                return 0;
            }
            stk.pop();
        }
        while (!sttk.empty())
        {
            v=sttk.top();
            if (v.F==0||v.S==0||v.F==h-1||v.S==w-1)
            {
                cout<<1;
                return 0;
            }
            if (!viz[v.F][v.S])
            {
                stk.push(v);
                stttk.push(v);
                viz[v.F][v.S]=1;
            }
            sttk.pop();
        }
    }
    ans=1e9;
    while (!stttk.empty())
    {
        v=stttk.top();
        ans=min(ans,v.F);
        ans=min(ans,v.S);
        ans=min(ans,w-1-v.S);
        ans=min(ans,h-1-v.F);
        stttk.pop();
    }
    if (ans%k==0)
    {
        cout<<ans/k+1;
    }
    else
    {
        cout<<ans/k+2;
    }
}


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

int main(){
	int N,a=0,b=0,c[100];
  	cin>>N;
	for(int i=0;i<N;++i)cin>>c[i];
  	sort(c,c+N);
  	reverse(c,c+N);
  	for(int i=0;i<N;++i){
    	if(i%2==0)a+=c[i];
      	else b+=c[i];
    }
  	cout<<a-b<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int n,k;
  cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];
  for(int i=k; i<n; i++)
  {
    if(a[i]>a[i-k])
      cout<<"Yes"<<"\n";
    else
      cout<<"No"<<"\n";
  }
  
}

Measured memory_bytes: 5184
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[j]=="R" or S[j]=="U" or S[j]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

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

class Program
{
    int n;
    bool[,,] f;
    int[,] p;
    bool[] s = new bool[10];
    void Run()
    {
        var sc = new Scanner();
        n = sc.NextInt();
        f = new bool[n, 5, 2];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < 5; j++)
                for (int k = 0; k < 2; k++)
                    f[i, j, k] = sc.NextInt() == 1;
        p = new int[n, 11];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < 11; j++)
                p[i, j] = sc.NextInt();

        Console.WriteLine(Dfs(0));
    }

    int Dfs(int o)
    {
        if (o == 10)
        {
            if (s.All(p => !p)) return int.MinValue;
            int pp = 0;
            for (int j = 0; j < n; j++)
            {
                int c = 0;
                for (int i = 0; i < 10; i++)
                {
                    int d = i / 2;
                    int h = i % 2;
                    if (s[i] && f[j, d, h]) c++;
                }
                pp += p[j, c];
            }

            return pp;
        }


        s[o] = true;
        int a = Dfs(o + 1);
        s[o] = false;
        int b = Dfs(o + 1);
        return Math.Max(a, b);
    }


    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <vector>

using namespace std;

int n;
vector<int> A;

int main()
{
    scanf("%d", &n);
    A=vector<int>(n);
    vector<int> B(n); //, //C(10000+1, 0);
    int max=-1;
    for(auto &it : A){
        scanf("%d", &it);
        if(it>max){
            max=it;
        }
    }

    vector<int> C(max+1, 0);
    for(auto &it : A){
        C[it]++;
    }
    for(int i=1; i<=max; i++){
        C[i]+=C[i-1];
    }
    for(auto it=A.rbegin(); it!=A.rend(); it++){
        B[C[*it]-1]=*it;
        C[*it]--;
    }

    for(auto it=B.begin(); it!=B.end(); it++){
        if(it!=B.begin()){
            printf(" ");
        }
        printf("%d", *it);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 17908
n, h = gets.chomp.split.map(&:to_i)
a_swords = []
b_swords = []
n.times.each do
  input = gets.chomp.split.map(&:to_i)
  a_swords.push input[0]
  b_swords.push input[1]
end
b_swords = b_swords.sort.reverse
a_max = a_swords.max

min = Float::INFINITY

(0..n).each do |k|
  break if h < 0

  h -= b_swords[k - 1] if k > 0
  count = ((h % a_max).zero? ? h / a_max : h / a_max + 1)
  min = [k + (h > 0 ? count : 0), min].min
end

puts min


Measured memory_bytes: 5088
def popcount(n):
    return bin(n).count("1")

def f(n):
    cnt = 0
    while n != 0:
        n %= popcount(n)
        cnt += 1
    return cnt

N = int(input())
S = input()

pcnt_X = S.count("1")
X = int(S, 2)

Xm = X % (pcnt_X - 1) if pcnt_X - 1 > 0 else float("inf")
Xp = X % (pcnt_X + 1)

for i, s in enumerate(S):
    if s == "0":
        x = (Xp + pow(2, N - 1 - i, pcnt_X + 1)) % (pcnt_X + 1)
        print(1 + f(x))
    elif pcnt_X - 1 > 0:
        x = (Xm - pow(2, N - 1 - i, pcnt_X - 1)) % (pcnt_X - 1)
        print(1 + f(x))
    else:
        print(0)

Measured memory_bytes: 9224
#include<stdio.h>
int main()
{
    int x,u=0;
    scanf("%d",&x);
    while(x>=500){
        u+=1000;
        x-=500;
    }
    while(x>=5){
        u+=5;
        x-=5;
    }
    printf("%d\n",u);
    return 0;
}

Measured memory_bytes: 128
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N = int(input())
	ans = pow(10, N, mod) - pow(9, N, mod) * 2 + pow(8, N, mod)
	print(ans % mod)





if __name__ == '__main__':
	main()

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    set<string> A;
    string S;
    REP(i,0,N) {
        cin >> S;
        A.insert(S);
    }
    PR(SZ(A));


    return 0;
}

/*



*/

Measured memory_bytes: 19140
#include <iostream>
int main(){
    int r,c,j,k;
    std::cin >> r >> c;
    int gyouretu[r+1][c+1] = {0};
    gyouretu[0][c] = 0;
    j = 0;
    k = 0;
    int A = 2 * c + 2;
    for(int a = 0;a < r;a++){
        for(int b = 0;b < c;b++){
            std::cin >>gyouretu[a][b];
        }
    }
    for(int d = 0;d < r;d++){
        for(int e = 0;e < c;e++){
            j = j + gyouretu[d][e];
        }
        gyouretu[d][c] = j;
        j = 0;
    }
    for(int f = 0;f < c + 1;f++){
        for(int g = 0;g < r;g++){
            k = gyouretu[g][f] + k;
        }
        gyouretu[r][f] = k;
        k = 0;
    }
    for(int h = 0;h < r + 1;h++){
        for(int i = 0;i < c + 1;i++){
            if(i < c){
            std::cout << gyouretu[h][i] <<" ";
            }else{
                std::cout <<gyouretu[h][i];
            }
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);

    long long maxv = 0;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        maxv = max(maxv, a[i]);
    }

    long long right = maxv;
    long long left = 0;

    while(right - left > 1){
        long long mid = (left + right)/2;
        long long cnt_m = 0;
        
        for(long long i = 0; i < n; i++){
            cnt_m += (a[i]+mid-1)/mid -1;
        }

        if(cnt_m <= k) right = mid;
        else left = mid;
    }

    cout << right << endl;
    return 0;
}

Measured memory_bytes: 4828
S = input()
N = len(S)

s1 = "01" * (N // 2)
s2 = "10" * (N // 2)

if N % 2 == 1:
    s1 += "0"
    s2 += "1"

diff1 = 0
diff2 = 0

for i in range(N):
    if S[i] != s1[i]:
        diff1 += 1
    if S[i] != s2[i]:
        diff2 += 1

print(min(diff1, diff2))


Measured memory_bytes: 3316