akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b; cin>>a>>b;
    cout<<a*a-b<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
    int N;
    scanf("%d",&N);
    char s[N];
    scanf("%s",s);
    int red = 0;
    int blue = 0;
    for (int i=0; i < N; i++)   {
        if(s[i]=='R')    red ++;
        if(s[i]=='B')   blue++;
    }
    if(red > blue)  printf("Yes");  
    else    printf("No");
}


Measured memory_bytes: 128
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, m] = spi[0].split(' ').map(e => Number(e));
    const a = spi[1].split(' ').map(e => Number(e));

    const sum = a.reduce((x, y) => x += y);
    let ans = 0;
    for (let i = 0; i < n; i++) {
        if (a[i] >= sum / (4 * m)) ans++;
    }
    
    if (ans >= m)
        console.log("Yes");
    else
        console.log("No");
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29556
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    cout << (k >= 2 ? (n - k) : 0);
    return 0;
}

Measured memory_bytes: 256
def max(a,b); a > b ? a : b; end

N = gets.to_i
E = Array.new(N){ Array.new(N) }
N.times do |a|
  c = gets.to_i
  c.times.map do
    x, y = gets.split.map(&:to_i)
    E[a][x - 1] = y
  end
end
ans = (1 << N).times.inject(0) do |m, s|
  h = N.times.count{|i| s[i] > 0 }
  q = N.times.all? do |a|
    N.times.all? do |x|
      s[a] == 0 || (E[a][x].nil? || E[a][x] == s[x])
    end
  end
  q ? max(m, h) : m
end
puts ans


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

int main() {
	// your code goes here
	int a, b, c, d;
	cin >> a >> b >> c;
	
	if(a == b) d = c;
	else if(a == c) d = b;
	else if(b == c) d = a;
	
	cout << d << endl;
	
	return 0;
}

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

using namespace std;

int main()
{
    int N, result = 0, l, r;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> l >> r;
        result += abs(l - r) + 1; 
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_f64_vec() -> Vec<f64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn is_integer_distance(p1: &Vec<f64>, p2: &Vec<f64>) -> bool {
    let mut sum = 0f64;
    for i in 0..p1.len() {
        sum += (p1[i] - p2[i]) * (p1[i] - p2[i]);
    }
    sum = sum.sqrt();
    //println!("sum = {}", sum);
    (sum - sum.round()).abs() < 1e-6
}

fn main() {
    let (n, _) = input_int_tuple();
    let mut points: Vec<Vec<f64>> = Vec::new();
    for _ in 0..n {
        let x = input_f64_vec();
        points.push(x);
    }

    let mut sum = 0;
    for i in 0..(n as usize) {
        for j in (i+1)..(n as usize) {
            //println!("{}-{}", i, j);
            if is_integer_distance(&points[i], &points[j]) {
                sum += 1;
            }
        }
    }

    println!("{}", sum);

}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    int a, b, c;
    int sm[3];
    cin >> a >> b >> c;

    sm[0] = a+b;
    sm[1] = b+c;
    sm[2] = c+a;

    cout << *min_element(sm, sm+3) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef struct Card{
  char suit;
  int value;
  int id;
}card;
void bubblesort(card c[],int n);
void selectionsort(card c[],int n);
void sorns(card c[],int n);
int main(){
  int N,i;
  scanf("%d",&N);
  card c1[N];
  card c2[N];
  for(i=0;i<N;i++){
    scanf(" %c%d",&c1[i].suit,&c1[i].value);
    c1[i].id=i;
    c2[i]=c1[i];
  }  
  bubblesort(c1,N);
  selectionsort(c2,N);
  /*bubble sort*/
  for(i=0;i<N;i++){
    printf("%c%d",c1[i].suit,c1[i].value);
    if(i<N-1){
      printf(" ");
    }
  }
  printf("\n");
  sorns(c1,N);
  /*selectionsort*/
  for(i=0;i<N;i++){
    printf("%c%d",c2[i].suit,c2[i].value);
    if(i<N-1){
      printf(" ");
    }
  }
  printf("\n");
  sorns(c2,N);
  return 0;
}
void bubblesort(card c[],int n){
  int i,j;
  card temp;
  for(i=0;i<=n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(c[j].value<c[j-1].value){
	temp = c[j];
	c[j] = c[j-1];
	c[j-1] = temp;
      }
    }
  }
}
void selectionsort(card c[],int n){
  int i,j,minj;
  card temp;
  for(i = 0;i<=n-1;i++){
    minj = i;
    for(j = i;j<=n-1;j++){
      if(c[j].value < c[minj].value){
	minj = j;
      }
    }
    temp = c[i];
    c[i] = c[minj];
    c[minj] = temp;
  }
}
void sorns(card c[],int n){
  int stable=1,i;
  for(i=1;i<n;i++){
    if(c[i-1].value == c[i].value && c[i-1].id > c[i].id) stable=0;
  }
  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
}


Measured memory_bytes: 2124
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if(a > b) {
            System.out.println("a > b");
        } else if(a < b) {
            System.out.println("a < b");
        } else {
            System.out.println("a == b");
        }

        scanner.close();
    }
}

Measured memory_bytes: 26192
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1 + M)]

import sys
sys.setrecursionlimit(100010)

from collections import defaultdict

vs = defaultdict(set)

for a, b in AB:
    vs[b].add(a)

cache = {}

def calc(n):
    if n in cache:
        return cache[n]
    max_distance = 0
    max_distance_parent = 0
    for m in vs[n]:
        d = calc(m)[0]
        if max_distance < d + 1:
            max_distance = d + 1
            max_distance_parent = m
    result = max_distance, max_distance_parent
    cache[n] = result
    return result

for i in range(1, N + 1):
    print(calc(i)[1])


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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  long long N, P, cnt = 0, min_num;
  cin >> N;
  for(long long i = 0; i < N; ++i) {
    cin >> P;
    if(i == 0) {
      min_num = P;
    }
    if(min_num >= P) {
      cnt++;
    }
    min_num = min(min_num, P);
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
void push (int);
int pop ();

int S[1000];
int top = 0;
int main(){
    char s[100];
    while (scanf("%s",s) != EOF){
        if (s[0] == '+'){
            int a = pop();
            int b = pop();
            push(b + a);
        }else if (s[0] == '-'){
            int a = pop();
            int b = pop();
            push(b - a);
        }else if (s[0] == '*'){
            int a = pop();
            int b = pop();
            push(b * a);
        }else{
            push(atoi(s));
        }
    }
    cout << pop() << endl;
    return 0;
}
void push(int n){
   S[top + 1] = n;
   top++;
}
int pop(){
    top--;
    return S[top + 1];
}



Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll n, m;
vector<pair<ll, ll>> ab;

int main() {
  cin >> n >> m;
  ab = vector<pair<ll, ll>>(n);
  REP(i, n) {
    ll input(a, b);
    ab[i] = {a, b};
  }

  sort(ab.begin(), ab.end(), [](auto v1, auto v2){
      return v1.second > v2.second;
  });

  // sort(ab.begin(), ab.end(), [](auto v1, auto v2){
  //     if (v1.first == v2.first) {
  //       return v1.second > v2.second;
  //     }
  //     return v1.first > v2.first;
  // });

  vector<ll> plan(m + 1, 0);
  vector<ll> shift(m + 1);
  REP(i, n) {
    if (ab[i].first > m) continue;
    if (plan[ab[i].first] == 0) {
      plan[ab[i].first] = ab[i].second;
      shift[ab[i].first] = ab[i].first + 1;
    } else {
      vector<ll> visited;
      for (ll nxt = shift[ab[i].first];; nxt = shift[nxt]) {
        if (nxt > m) break;

        visited.push_back(nxt);
        if (plan[nxt] == 0) {
          for (auto v: visited) {
            shift[v] = nxt + 1;
          }
          plan[nxt] = ab[i].second;
          break;
        }
      }
    }
  }
  cout << accumulate(plan.begin(), plan.end(), 0ll) << endl;
}


Measured memory_bytes: 6428
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	int A,B;
	cin >> A >> B;
	if(A == 1) {
		A += 13;
	}
	if(B == 1) {
		B += 13;
	}
	if(A > B) {
		cout << "Alice" << endl;
	}
	else if(A < B) {
		cout << "Bob" << endl;
	}
	else if(A == B) {
		cout << "Draw" << endl;
	}
}

Measured memory_bytes: 256
"""
    showBit(n):nを2進数表示
    bitCheck(n,i):nのi桁目を返す
    bitOn(n,i):nのi桁目を1にする
    bitOff(n,i):nのi桁目を0にする
    bitFlip(n,i):nのi桁目を反転する
    isbitAll(n):nが(1<<64)-1か判定
    isbitAny(n):nが0でないか判定
    isbitNone(n):nが0か判定
    bitCount(n):nの1の数を判定
"""
def showBit(n):
    print("{:b}".format(n))

def bitCheck(n,i):
    return (int(bool(n&1<<i)))

def bitOn(n,i):
    return n|1<<i

def MaskOn(n,m):
    return n|m

def bitOff(n,i):
    return n&~(1<<i)

def MaskOff(n,m):
    return n&~m

def bitFlip(n,i):
    return n^1<<i

def MaskFlip(n,m):
    return n^m

def isbitAll(n):
    return int(bitCount(~n)==0)

def isMaskAll(n,m):
    return int(bitCount(~n&m)==0)

def isbitAny(n):
    return int(bitCount(n)>0)

def isMaskAny(n,m):
    return int(bitCount(n&m)>0)

def isbitNone(n):
    return int(bitCount(n)==0)

def isMaskNone(n,m):
    return int(bitCount(n&m)==0)

def bitCount(n):
    return bin(n).count('1')

def MaskCount(n,m):
    return bitCount(n&m)



b=0
masks=[]
n=int(input())
for i in range(n):
    mask=0
    m=list(map(int,input().split()))
    for j in range(m[0]):
        mask=bitOn(mask,m[j+1])
    masks.append(mask)

q=int(input())
for i in range(q):
    qry=list(map(int,input().split()))
    if qry[0]==0:
        print(bitCheck(b,qry[1]))
    elif qry[0]==1:
        b=MaskOn(b,masks[qry[1]])
    elif qry[0]==2:
        b=MaskOff(b,masks[qry[1]])
    elif qry[0]==3:
        b=MaskFlip(b,masks[qry[1]])
    elif qry[0]==4:
        print(isMaskAll(b,masks[qry[1]]))
    elif qry[0]==5:
        print(isMaskAny(b,masks[qry[1]]))
    elif qry[0]==6:
        print(isMaskNone(b,masks[qry[1]]))
    elif qry[0]==7:
        print(MaskCount(b,masks[qry[1]]))
    elif qry[0]==8:
        print(b&masks[qry[1]])


Measured memory_bytes: 5640
#include <iostream>
using namespace std;
int n, m, k, a, ans, c[35];
int main() {
	int i;
	cin>>n>>m;
	for(i=0; i<n; i++) {
		cin>>k;
		while(k--) {
			cin>>a;
			c[a]++;
		}
	}
	for(i=1; i<=m; i++) if(c[i]==n) ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define maxn 1000000
using namespace std;

int n,cnt,ans;
bool book[maxn];

int main(){
	scanf("%d",&n);
	
	for(int i = 1;i <= n;i++){
		scanf("%d",&cnt);
		if(cnt == i) book[i] = true;
	}
	
	for(int i = 1;i <= n;i++){
		if(book[i]){
			ans++;
			book[i] = false;
			book[i+1] = false;
		}
	}
	
	printf("%d",ans);
	
	return 0;
} 

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

int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i,n) cin >> p[i].second >> p[i].first;//Bがfirstに来るように入力を取りたい(firstの大小が優先されるから)
  sort(p.begin(), p.end());
  ll t = 0;//経過時間
  rep(i,n) {
    t += p[i].second;
    if (t > p[i].first) {//締め切りを過ぎていたら
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl P(N);
  REP(i, N) cin >> P[i];
  ll a = 0, b = 0;
  bool backout = false;
  REP(i, N) {
    if (backout && P[i] == i + 1) {
      a++;
      backout = false;
    } else if (!backout && P[i] == i + 1) {
      backout = true;
    } else if (backout && P[i] != i + 1) {
      backout = false;
      b++;
    }
  }
  if (backout)
    b++;
  cout << a + b << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String S = sc.next();
   String T = sc.next();
   int A = sc.nextInt();
   int B = sc.nextInt();
   String U = sc.next();

   if(S.equals(U)) {
	   A = A - 1;
   }else {
	   B = B - 1;
   }

   System.out.print(A);
   System.out.print(' ');
   System.out.print(B);
    }
}


Measured memory_bytes: 21716
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef vector< pair<ll,ll> > Root;
Root root[1000005];
ll L[1000005];
void dfs(ll r,ll fa,ll sum)
{
    L[r]=sum;
    for(int i=0;i<root[r].size();i++)
    {
        if(root[r][i].first==fa) continue;
        dfs(root[r][i].first,r,root[r][i].second+sum);
    }
}
int main(void)
{
    int n;
    cin>>n;
    for(int i=1;i<n;i++)
    {
        ll a,b,val;
        cin>>a>>b>>val;
        root[a].push_back(make_pair(b,val));
        root[b].push_back(make_pair(a,val));
    }
    ll que,k;
    cin>>que>>k;
    dfs(k,-1,0);
    while(que--)
    {
        ll a,b;
        cin>>a>>b;
        cout<<L[a]+L[b]<<endl;
    }
    return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
	int a,b,c;

	cin >> a >> b >> c;
	if((a > c && c > b) || (a < c && c < b)){
		cout << "Yes";
	} else {
		cout << "No";
	}

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(){
  int n, s[10000], q, t[500], i, j, count = 0;


  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &s[i]);

  scanf("%d", &q);
  for(i = 0; i < q; i++)
    scanf("%d", &t[i]);


  for(i = 0; i < q; i++){
    s[n] = t[i]; //番兵の配置
    j = 0;
    while(s[j] != t[i]){
      j++;
    }
    if(j != n)
      count++;
  }

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

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n, k;

int main(){
	cin >> n >> k;
	
	int cnt = 0;
	
	REP(i,n){
		int h;
		cin >> h;
		
		if (h >= k) cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  string s;
  cin >> s;
  bool a,b,c,d;
  a=b=c=d=0;
  rep(i,(int)s.size()) {
    if( s[i] == 'N' ) a=1;
    if( s[i] == 'S' ) b=1;
    if( s[i] == 'W' ) c=1;
    if( s[i] == 'E' ) d=1;
  }
  if( ( ( a | b ) && !( a & b ) ) || ( ( c | d ) && !( c & d ) ) ) {
    puts("No");
  } else {
    puts("Yes");
  }
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int n; cin >> n;
  vector<int>v(n);
  for(int i=0; i<n; ++i) cin >> v[i];
  long long count = 0;
  int mx = 0;
  for(int i=0; i<n; ++i){
		mx = max(mx,v[i]);
       
        count += mx - v[i];
    } 
  cout << count << "\n";
  return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

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

int main(){
    string s;
    string t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i]==t[i])ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prseq(var, n)    rep(i,n){cout << var[i] << " ";} cout << endl
#define prseql(var, n)   rep(i,n){cout << var[i] << " " << endl;}

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

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

  vector<double> v(n);
  rep(i,n){
    cin >> v[i];
  }

  sort(all(v));

  double ans=0.0;
  double div=1.0;
  rep(i,n){
    if(i!=n-1){div *= 2;}
    ans += v[n-i-1] / div;
  }

  prtd(8, ans);
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long p = sc.nextLong();
        
        long maxRoot = (long)Math.ceil(Math.pow(p, 1.0/n));
        
        for(long l = maxRoot; l > 0; l--){
            if(p % (long)Math.pow(l, n) == 0){
                System.out.println(l);
                break;
            }
        }
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(void){
    // Your code here!
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    mint dight=1,res=0;
    rep(i,63){
        ll x=0,y=0;
        rep(j,n){
            if(a[j]%2==0)x++;
            else y++;
            a[j]/=2;
        }
        mint buf=x*y;
        res+=buf*dight;
        dight*=2;
    }
    cout<<res.x<<endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
#pragma GCC optimize("O2")
static inline int comp(const int a,const int b,int desc){return a<b?(!desc?a:b):(!desc?b:a);}
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
int main(void)
{
  int N=IN(),i=0,u,v;long x=1l*N*(N+1)*(N+2)/6;
  while(i++<N-1){u=IN(),v=IN();x=x-1l*comp(u,v,0)*(N-comp(u,v,1)+1);}
  return printf("%ld",x),0;
}

Measured memory_bytes: 1700
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        if (n == 2) {
            System.out.println(Math.abs(h[0] - h[1]));
            return;
        }

        int[] cost = new int[n];
        cost[0] = 0;
        cost[1] = Math.abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
            cost[i] = Math.min(cost[i-2] + Math.abs(h[i] - h[i-2]),
                    cost[i-1] + Math.abs(h[i] - h[i-1]));
        }

        System.out.println(cost[n-1]);

    }
}


Measured memory_bytes: 59012
N,Q=map(int,input().split())
 
S=input()
 
ACDP=[0]*N
Aflag=0
ACcount=0
for i in range(len(S)):
  if S[i]=='C' and Aflag==1:
    ACcount+=1
  if S[i]=='A':
    Aflag=1
  else:
    Aflag=0
  ACDP[i]=ACcount
#print(ACDP)
 
for _ in range(Q):
  start,end=map(int,input().split())
  print(ACDP[end-1]-ACDP[start-1])

Measured memory_bytes: 6108
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  int x = 0 ;
  int max = 0;
  cin >> S ;
  for(int i = 0 ; i < N ; i++){
    
    //cout << S[i] << endl;
    char s = S[i];
    if( s == 'D' )
      x--;
    else
      x++;

    if(max < x)
      max = x;
      
  }

  cout << max << endl;


  return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <cmath>
// #include <algorithm>
// #include <unordered_set>
// #include <unordered_map>
// #include <set>
// #include <map>
// #include <queue>
// #include <deque>
// #include <bitset>
// #include <stack>
// #include <random>
// #include <fstream>
// #include <sstream>
// #include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	string s;
	cin >> n >> s;
	vector<int> _a (n), _b (n), _c (n), a (n), b (n), c (n);
	int ans = 0;
	fr (i, n) {
		if (s[i] == 'R') _a[i] = 1;
		else if (s[i] == 'G') _b[i] = 1;
		else _c[i] = 1;
	}
	reverse (all (_a)), reverse (all (_b)), reverse (all (_c));
	partial_sum (all (_a), a.begin ()), partial_sum (all (_b), b.begin ()), partial_sum (all (_c), c.begin ());
	reverse (all (a)), reverse (all (b)), reverse (all (c));
	fr (i, n) {
		fl (j, i + 1, n) {
			map <char, int> kek;
			kek[s[i]] = kek[s[j]] = 1;
			if (sz (kek) != 2) continue;
			if (!kek.count ('R')) {
				ans += a[j];
				if (2 * j - i < n && s[2 * j - i] == 'R') --ans;
			}
			if (!kek.count ('G')) {
				ans += b[j];
				if (2 * j - i < n && s[2 * j - i] == 'G') --ans;
			}
			if (!kek.count ('B')) {
				ans += c[j];
				if (2 * j - i < n && s[2 * j - i] == 'B') --ans;
			}
		}
	}
	cout << ans;







}

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int a[3], b[2];
	cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1];
	cout << min(min(a[0], a[1]), a[2]) + min(b[0], b[1]) - 50 << endl;
	return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;

vector <int> G[N];
int n,m;
int ans = INT_MAX;
vector<int> path;
bool vis[N];
int pre[N];

void bfs(int s) {
    memset(vis,0,sizeof vis);
    queue<int> Q;
    Q.push(s);
    vis[s] = 1;
    bool f = 0;
    while(!Q.empty()) {
        int u = Q.front(); Q.pop();
        for(auto &v : G[u]) {
            if(v == s) {
                f = 1;
                pre[s] = u;
                goto end;
            }
            if(!vis[v]) {
                Q.push(v);
                vis[v] = 1;
                pre[v] = u;
            }
        }
    }
    end:;
    if(f) {
        vector<int> p;
        int u = s;
        do {
            p.push_back(pre[u]);
            u = pre[u];
        } while(u != s);
        if(p.size() < ans) {
            ans = p.size();
            path = p;
        }
    }
}

int main () {
   // freopen("in","r",stdin);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        G[u].push_back (v);
    }
    for (int i = 1;i <= n; ++ i) {
        bfs(i);
    }
    if(ans == INT_MAX) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
        for(int i = 0;i < path.size();++i) {
            cout << path[i] << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 384
r,g,b,n = map(int,input().split())
res = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        p = n-r*i-g*j
        if p%b == 0 and p >= 0:
            res += 1
        elif p == 0:
            res += 1
print(res)


Measured memory_bytes: 40812
using System;
class aoj
{
    static void Main()
    {
        int a = 0;
        for(int i = 0; i < 4; i++)
        {
            int b = int.Parse(Console.ReadLine());
            a += b;
        }
        int y = a % 60, x = (a - y) / 60;
        Console.WriteLine(x + "\n" + y);
    }
}

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff<b.ff);
    else
        return (a.ss<b.ss);
}
void sieve(vl &prime){          //SIEVE OF ERATOSTHENES
    ll maxN=1e6;
    vector<bool> pr(maxN+1,1);
    for(int i=2;i*i<=maxN;i++)
        if(pr[i]==1)
            for(int j=i*i;j<=maxN;j+=i)
                pr[j]=0;
    for(ll i=2;i<=maxN;i++)
        if(pr[i]==1)
            prime.pb(i);
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    int t;
    cin>>t;
    if(t%1000)
    cout<<1000-t%1000 nn;
    else
    cout<<0 nn;
    return 0;
}

Measured memory_bytes: 3536
N = int(input())
A = [int(x) for x in input().split()]

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i + 1] = 0
    else:
        A[i] = 0

A[N - 1] = 0

A.sort()
A.reverse()
print(A[0] * A[1])


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

vector<int> digitlist(int x){
  vector<int> a;
  while(x!=0){
    int now = x%10;
    x = x/10;
    a.push_back(now);
  }
  return a;
}

int main(){
  int a,b;
  vector<int> v;
  cin >> a >> b;
  int ans=0;
  for(int j=a; j<=b; j++){
    v = digitlist(j);
    int flag = 1;
    for(int k = 0; k< (int)v.size(); k++){
      if(v[k] != v[v.size() - 1 -k]){
        flag=0;
      }
    }
    if(flag==1) ans++;
  }
  
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,x;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    x=i;
    if(i%3==0){
      printf(" %d",x);
    }
    else{
      while(x){
      if(x%10==3){ 
	printf(" %d",i);
        break;
      }
      x=x/10;
      }
    }
  }
    printf("\n");
  return 0;
}



Measured memory_bytes: 2040
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: AtCoder Beginner Contest 175

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007
int n;
vector<int> a;
void solution() {
	cin >> n;
	a.resize(n);
	for (auto& e:a) {
		cin >> e;
	}
}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	// int t;
	// cin >> t;	
	// while(t--) {
		// solution();
	// }
	string s;
	cin >> s;
	int ans = 0;
	for (auto& e:s) if (e == 'R') ans++;
	if (ans == 2) {
		if (s[0] == 'R' && s[2] == 'R') {
			--ans;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i;
	cin >> n;
	int arr[n + 1];
	foe(i, 1, n)
	cin >> arr[i];
	int cnt = 0;
	foe(i, 1, n){
		if(arr[i] != i)
		cnt++;
	}
	if(cnt <= 2)
	cout << "YES";
	else
	cout << "NO";
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var N = Inputer.Int1Char();
            var flag = false;
            for(int i = 1; i <= 9; i++)
            {
                for(int j= 0; j <= 9; j++)
                {
                    if(i*j == N)
                    {
                        flag = true;
                    } 
                }
            }
            Console.WriteLine(flag ? "Yes" : "No");
        }
    }

    /// <summary>
    /// 入力受付
    /// </summary>
    static class Inputer
    {
        /// <summary>
        /// A B C の複数整数からなる1行を受け取る
        /// </summary>
        /// <returns></returns>
        public static int[] IntArray1Line()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }

        /// <summary>
        /// 整数N　のような１つの整数からなる入力を受け取る
        /// </summary>
        /// <returns></returns>
        public static int Int1Char()
        {
            return int.Parse(Console.ReadLine());
        }
    }

    /// <summary>
    /// 順列を出すやつ
    /// </summary>
    /// <typeparam name="T"></typeparam>
    static class Permutation<T>
    {
        private static void Search(List<T[]> perms, Stack<T> stack, T[] a)
        {
            int N = a.Length;
            if (N == 0)
            {
                perms.Add(stack.Reverse().ToArray());
            }
            else
            {
                var b = new T[N - 1];
                Array.Copy(a, 1, b, 0, N - 1);
                for (int i = 0; i < a.Length; ++i)
                {
                    stack.Push(a[i]);
                    Search(perms, stack, b);
                    if (i < b.Length) { b[i] = a[i]; }
                    stack.Pop();
                }
            }
        }
        public static IEnumerable<T[]> All(IEnumerable<T> src)
        {
            var perms = new List<T[]>();
            Search(perms, new Stack<T>(), src.ToArray());
            return perms;
        }
    }
}

Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>
#include <cctype>
#include <sstream>

typedef long long lint;

using namespace std;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);++i)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define makeupper(t) transform(all(t),t.begin(),::toupper);
#define makelower(t) transform(all(t),t.begin(),::tolower);
lint* arr1(lint x) {
	lint *array = new lint[x];
	rep(i, x)array[i] = 0;
	return array;
}
lint** arr2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {
	string text;
	int n;
	cin >> text >> n;
	rep(i, n) {
		string code;
		cin >> code;
		if (code == "replace") {
			int a, b;
			string c;
			cin >> a >> b >> c;
			text.replace(a, b-a+1, c);
		}
		if (code == "reverse") {
			int a, b;
			cin >> a >> b;
			reverse(text.begin()+a, text.begin() +b+1);
		}
		if (code == "print") {
			int a, b;
			cin >> a >> b;
			cout << text.substr(a,b-a+1)<<"\n";
		}
	}
}


Measured memory_bytes: 3208
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = (n - 2) * 180;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//借助c++ 实现逆波兰表达式的求解
#include <cstdlib>
#include <iostream>
#include <stack>

using namespace std;

int main() {
  stack<int> S;

  int a, b, x;
  string s;
  while (cin >> s) {
    if (s[0] == '+') {
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();

      S.push(a + b);
    } else if (s[0] == '-') {
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();

      S.push(b - a);
    } else if (s[0] == '*') {
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();

      S.push(a * b);
    } else {
      S.push(atoi(s.c_str()));
    }
  }
  cout<<S.top()<<endl;
  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll> > vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll addmod(ll a,ll b)
{
    if(a+b<mod)return a+b;
    else return a+b-mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll modinv(ll a)
{
    return modexp(a,mod-2,mod);
}

bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
    return a.fi>b.fi;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll a,b,c; cin>>a>>b>>c;
swap(a,b);
swap(a,c);
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}
/*
6
1 2 3 4 5 -6
*/


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

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

  map<int, int> a;
  rep(i,n){
    int ai;
    cin >> ai;
    a[ai] = i + 1;
  }

  for (auto ele : a){
    cout << ele.second << endl;
  }
  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, M;
  cin >> N >> M;
 
  int a[N];
 
 
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  for (int i=0; i<N; ++i) {
    for (int j=i+1; j<N; ++j) {
      if (a[i] < a[j]) {
        int tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
 
  int sum = 0;
  for(int i=0; i<N; i++){
    sum += a[i];
  }
 
  if(a[M-1] < sum / (4.0 * M)){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int a, b, c; cin >> a >> b >> c;
	if ((100 * a + 10 * b + c) % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << 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;

typedef long long ll;

int main() {
    int N, a, ans = 0;
    cin >> N;
    rep(i, N) {
        cin >> a;
        if (i % 2) continue;
        if (a % 2) ans++;
    }
    cout << ans << "\n";
}

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

int main() {
  
  int a,b,c;
  cin >> a >> b >> c;
  
  cout << (a+b)*c/2 << endl;
  
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        mut x: i128,
        mut k: i128,
        d: i128,
    }

    x = x.abs();
    if x > k * d {
        x -= k * d;
    } else {
        let xd = x / d;
        k -= xd;
        x -= xd * d;
        if k % 2 == 1 {
            x -= d;
        }
    }

    println!("{}", x.abs());
}


Measured memory_bytes: 2152