akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(usize);

    let n1e9 = 1_000_000_000usize;
    let n1e18 = n1e9*n1e9;
    if s == n1e18 {
        println!("0 0 {} 0 0 {}", n1e9, n1e9);
        return;
    }

    println!("0 0 {} 1 {} {}", n1e9, n1e9-s%n1e9, s/n1e9+1);
}


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

string res = "CODEFESTIVAL2016";

int minOper(string s)
{
    int i = 0;
    int num = 0;
    while (i < s.length()){
        if (res[i] != s[i])
            num++;
        i++;
    }
    return num;
}

int main()
{
    string s;
    cin >> s;
    cout << minOper(s);
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(H: int, W: int, a: "[List[str]"):
    dp = [[0] * (W+1) for i in range(H+1)]

    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            
            if 0 <= i < H and 0 <= j+1 < W and a[i][j+1] == '.':
                dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD
            if 0 <= i+1 < H and 0 <= j < W and a[i+1][j] == '.':
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD


    print(dp[H-1][W-1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ next(tokens) for _ in range(H) ]  # type: "List[List[str]]"
    solve(H, W, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43656
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<int> cnt(N);
	rep(i, 0, M) {
		int a, b; cin >> a >> b; a--, b--;
		cnt[a]++;
		cnt[b]++;
	}
	rep(i, 0, N) {
		if (cnt[i] % 2) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double a[n];
    double sum=0,x;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        double b=a[i];
        x=1/b;
        sum=sum+x;
    }
double ans=1/sum;
    cout<<ans;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<set>
using namespace std;
int n,i,pre,m;
string s;
set<string> ss;
int main()
{
	pre=-1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		cin>>s;
		if(ss.find(s)!=ss.end())
		{
			printf("No\n");
			return 0;
		}
		if(pre!=-1&&s[0]-'a'!=pre)
		{
			printf("No\n");
			return 0;
		}
		m=s.length();
		pre=s[m-1]-'a';
		ss.insert(s);
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);I++) cin >> x[i];

int main(){
  int a[3];
 
	cin >> a[0] >> a[1] >> a[2];
 
	sort(a, a +3);
 
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)
      cout << "YES" << endl;
	else 
      cout << "NO" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var debug = false

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	if sc.Scan() {
		n, _ = strconv.Atoi(sc.Text())
	}
	var targets []string
	for i := 0; i < n; i++ {
		if sc.Scan() {
			targets = append(targets, sc.Text())
		}
	}

	res := GetAnswer(n, targets)
	fmt.Printf("%v\n", res)
}

// GetAnswer ...
func GetAnswer(n int, targets []string) string {
	prt("inputs: n:%v targets:%#v", n, targets)
	result := "Yes"
	stx := 0
	sty := 0
	pasttime := 0

	for i, t := range targets {
		if i >= n {
			break
		}
		prt("loop: %d, target: %v", i, t)
		tarr := getIntArray(t)
		prt("start: (%v, %v) Dest: (%v, %v)", stx, sty, tarr[1], tarr[2])
		pos := math.Abs(float64(tarr[1]-stx)) + math.Abs(float64(tarr[2]-sty))
		prt("pos: %d, past:%d", int(pos), pasttime)
		if int(pos) > (tarr[0] - pasttime) {
			result = "No"
			break
		}
		if (tarr[0]-pasttime)%2 != int(pos)%2 {
			result = "No"
			break
		}
		pasttime = tarr[0]
		stx = tarr[1]
		sty = tarr[2]
	}

	return result
}

func getIntArray(str string) []int {
	strarr := strings.Split(str, " ")
	intarr := []int{}
	for _, st := range strarr {
		ti, _ := strconv.Atoi(st)
		intarr = append(intarr, ti)
	}
	return intarr
}

func prt(format string, inputs ...interface{}) {
	if debug {
		fmt.Printf(format+"\n", inputs...)
	}
}

Measured memory_bytes: 11008
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    while(n>0){
        if(n%4 == 0 || n%7 == 0){
            printf("Yes\n");
            return 0;
        }
        n -= 7;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<map>
#include<vector>
//#include<algorithm>
using namespace std;

map<string,int> miria;
vector<string> rika;

int main(){
  int N;
  int flag = 0;
  string aho;
  cin >> N;
  cin >> aho;
  miria[aho]++;
  char beginChar = aho[0];
  rika.push_back(aho);
  for(int i=1;i<N;i++){
    char endChar = rika[rika.size()-1][rika[rika.size()-1].length()-1];
    //cout << endChar << endl;

    cin >> aho;
    miria[aho]++;
    beginChar = aho[0];
    rika.push_back(aho);
    if(miria[aho]>1 || endChar != beginChar){
      flag = 1;
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	int x,y;
	cin>>x>>y;
	FOR(a,0,101) {
		FOR(b,0,101) {
			if (a+b != x) continue;
			if (2*a+4*b != y) continue;
			cout<< "Yes";
			return;
		}
	}
	cout<<"No";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int d;
  cin >> d;
  int c[26];
  for(int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  vector<vector<int>> s(d, vector<int>(26));
  for(int i = 0; i < d; i++) {
    for(int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> t(d);
  for(int i = 0; i < d; i++) {
    cin >> t[i];
    t[i]--;
  }
  int m;
  cin >> m;
  vector<int> day(m), q(m);
  for(int i = 0; i < m; i++) {
    cin >> day[i] >> q[i];
    day[i]--;
    q[i]--;
  }

  for(int i = 0; i < m; i++) {
    t[day[i]] = q[i];
    vector<int> last(26, 0);
    int score = 0;
    for(int i = 0; i < d; i++) {
      score += s[i][t[i]];
      last[t[i]] = i + 1;
      for(int j = 0; j < 26; j++) {
        score -= c[j] * ((i + 1) - last[j]);
      }
    }
    cout << score << '\n';
  }
  return 0;
}

Measured memory_bytes: 3980
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        x: i64,
    }

    let mut i = 1;
    let mut current = 0;
    loop {
        current += i;
        if current >= x {
            println!("{}", i);
            return;
        }

        i += 1;
    }
}


Measured memory_bytes: 2136
class comb():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, num + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def com(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD


r1, c1, r2, c2 = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def nasu(n, m):
  if n < 0 or m < 0: return 0
  ans = (com.com(n + 2, m + 1) - 1)
  return ans
N = r2 + c2
com = comb(N + 3, MOD)

ans = nasu(N, r2)
ans = (ans + nasu(c1 + r1 - 2, min(c1, r1) - 1)) % MOD
ans = (ans - nasu(r2 + c1 - 1, c1 - 1))
ans = (ans - nasu(c2 + r1 - 1, r1 - 1))
while ans < 0: ans += MOD

print(ans)

Measured memory_bytes: 133676
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int cnt=0;
	if(a==b&&b==c) cout<<1<<endl;
	else if(a==b||b==c||c==a) cout<<2<<endl;
	else cout<<3<<endl;
	return 0;
}

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

using namespace std;

int main()
{
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<long long> a(x),b(y),c(y);
	for(long long &i:a)
		cin>>i;
	for(long long &i:b)
		cin>>i;
	for(long long &i:c)
		cin>>i;
	sort(a.begin(),a.end(),greater<long long>());
	sort(b.begin(),b.end(),greater<long long>());
	sort(c.begin(),c.end(),greater<long long>());
	vector<long long> tmp(x*y);
	for(int i=0;i<x;i++)
		for(int j=0;j<y;j++)
			tmp[x*i+j]=a[i]+b[j];
	sort(tmp.begin(),tmp.end(),greater<long long>());
	priority_queue<long long> ans;
	for(int i=0;i<min(k,x*y);i++)
		for(int j=0;j<z;j++)
			ans.push(tmp[i]+c[j]);
	for(int i=0;i<k;i++)
	{
		cout<<ans.top()<<endl;
		ans.pop();
	}

	return 0;
}


Measured memory_bytes: 42856
/*
 * @Author: Kaizyn
 * @Date: 2020-05-03 10:18:30
 * @LastEditTime: 2020-05-03 11:12:26
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 2e5+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int n, m;
int a[N], res[N];
vector<int> e[N];
vector<int> lis[N];

void dfs(const int &u, const int &fa) {
    int p, len = m;
    if (a[u] > lis[m].back()) {
        lis[++m].emplace_back(a[u]);
        p = m;
    } else {
        int l = 1, r = m;
        while (l < r) {
            int mid = (l+r)>>1;
            if (lis[mid].back() >= a[u]) r = mid;
            else l = mid+1;
        }
        lis[l].emplace_back(a[u]);
        p = l;
    }
    res[u] = m;
    for (const int &v : e[u]) if (v != fa) {
        dfs(v, u);
    }
    lis[p].pop_back();
    m = len;
}

inline void solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1, u, v; i < n; ++i) {
        cin >> u >> v;
        e[u].emplace_back(v);
        e[v].emplace_back(u);
    }
    lis[0].emplace_back(0);
    dfs(1, 0);
    for (int i = 1; i <= n; ++i) cout << res[i] << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 32848
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: char = read::<String>().chars().collect::<Vec<char>>()[0];

    if a.is_ascii_lowercase() {
        println!("a")
    } else {
        println!("A")
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int M, N, sum(0);
    cin >> N >> M;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    sort(A, A + N, greater<int>());
    int x = (sum % (4 * M) == 0) ? sum / 4 / M : sum / 4 / M + 1;
    if (A[M - 1] < x)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, s, t := ReadInt(), ReadString(), ReadString()

	for i := N; i > 0; i-- {
		if s[len(s)-i:] == t[:i] {
			fmt.Println(i + (N-i)*2)
			return
		}
	}
	fmt.Println(N * 2)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1848
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll bl[222222];
ll wh[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  string s;cin>>s;
  ll cnt=0;
  bool fl=false;
  ll cnt2=0;
  ll cnt3=0;
  vi black;
  vi white;
  if(s[0]!='.')white.pb(0);
  for(int i=0;i<s.size();i++){
    if(s[i]=='#'){
      cnt2++;
      if(cnt!=0)
      white.pb(cnt);
      cnt=0;
    }
    if(s[i]=='.'){
      if(cnt2!=0)
	black.pb(cnt2);
      cnt2=0;
      cnt++;
    }
  }
  if(cnt>0)white.pb(cnt);
  else black.pb(cnt2);
  if(white.size()>black.size())black.pb(0);
  for(int i=0;i<black.size();i++)
    bl[i+1]+=bl[i]+black[i];
  for(int j=0;j<white.size();j++){
    wh[j+1]+=wh[j]+white[j];
  }
  ll ans=llINF;
  for(int i=0;i<white.size();i++){
    // cout<<bl[i]<<" "<<wh[white.size()]-wh[i+1]<<endl;
    ans=min(ans,bl[i]+wh[white.size()]-wh[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    vector<int> v(n),c(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    rep(i,n) if(v[i] > c[i]) ans += v[i]-c[i];
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  int n;
  map<string, vector<int>> mp;
  while (cin >> s >> n) {
    mp[s].emplace_back(n);
  }
  for (auto i : mp) {
    cout << i.first << endl;
    auto v = i.second;
    int vz = v.size();
    sort(v.begin(), v.end());
    for (int j = 0; j < vz; j++) {
      cout << v[j] << " \n"[j + 1 == vz];
    }
  }

  return 0;
}


Measured memory_bytes: 3128
n,m = map(int,input().split())
H = list(map(int,input().split()))
L = [1]*n
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if H[a] == H[b]:
    L[a] = 0
    L[b] = 0
  elif H[a] < H[b]:
    L[a] = 0
  elif H[a] > H[b]:
    L[b] = 0
print(sum(L))

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;





int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m);
  rep(i, m) cin >> a[i];
  ll mod = 1e9 + 7;

  set<ll> st;
  rep(i, m) st.insert(a[i]);

  vector<ll> memo(n+2, 0);
  memo[n+1] = 0;
  memo[n] = 1;
  for(ll i = n-1; 0 <= i; i--){
    if(st.count(i)){
      memo[i] = 0;
      continue;
    }
    memo[i] = memo[i+1] + memo[i+2];
    memo[i] %= mod;
  }
  cout << memo[0] << endl;


  return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#define mod 998244353
#define pb push_back
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=8 && b<=8)cout<<"Yay!"<<endl;
	else cout<<":("<<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;
typedef pair<int, int> P;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	bool elf = true;
	rep(i, n) {
		if (i % 2 == 0) {
			if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') elf = false;
		}
		else {
			if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') elf = false;
		}
	}
	cout << (elf ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iterator>

using namespace std;

int N;

int L[200];
int M[200];
int M_max;
int dp[1000001];

void init() {
    for (int i = 1; i <= 200; i++) {
        L[i - 1] = (i * (i + 1) * (i + 2)) / 6;
    }

    int j = 0;
    for (int i = 0; i < 200 && L[i] <= 1000000; i++) {
        if (L[i] % 2 == 1) {
            M[j++] = L[i];
        }
    }
    M_max = j;

    for (int i = 0; i <= 1000000; i++) {
        dp[i] = 10000000;
    }
    dp[0] = 0;
    for (int i = 1; i <= 1000000; i++) {
        for (int j = 0; j < M_max && M[j] <= i; j++) {
            dp[i] = min(dp[i], dp[i - M[j]] + 1);
        }
    }
}

int f(int nth, int s) {
    int r = N - s;
    int start = distance(L, upper_bound(L, L + 200, r)) - 1;

    int m = 100;
    for (int i = start; i >= 0 && r <= (5 - nth) * L[i]; i--) {
        if (r == L[i]) {
            return nth + 1;
        }

        m = min(m, f(nth + 1, s + L[i]));
    }

    return m;
}

void solve() {
    printf("%d %d\n", f(0, 0), dp[N]);
}

int main() {
    init();
    while (true) {
        scanf("%d", &N);
        if (!N) {
            break;
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 4936
#include <stdio.h>

int main(void)
{
    int a[1000];
    int b[1000];
    char op[1000];
    int i = 0;
    while(1){
        scanf("%d %c %d", &a[i], &op[i], &b[i]);
        if(op[i] == '?') break;
        i++;
    }
    i = 0;
    while(1){
        if(op[i] == '?') break;
        switch(op[i]){
            case '+': printf("%d\n", a[i]+b[i]); break;
            case '-': printf("%d\n", a[i]-b[i]); break;
            case '*': printf("%d\n", a[i]*b[i]); break;
            case '/': printf("%d\n", a[i]/b[i]); break;
        }
        i++;
    }
    return (0);
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define  endl '\n'
using namespace std;
ll mod = 998244353;
ll n, s, a[3005], dp[3005][3005];

ll solve(ll i, ll have) {
    // base case
    if (i == n) {
        return (have == s);
    }
    ll &ret = dp[i][have];
    if (~ret) return ret;

    ll ans = (2 * solve(i + 1, have)) % mod;
    if (have + a[i] <= s)
        ans += solve(i + 1, have + a[i]);
    ans %= mod;
    return ret = ans;
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;

}

Measured memory_bytes: 74360
#include <bits/stdc++.h>
 
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define INF 1000000000000000
 
 
int main()
{
  ll n,d,ans=0;
  cin>>n>>d;
  d=d*d;
  ll i;
  for(i=0;i<n;i++)
  {
    	ll x,y;
	  	cin>>x>>y;
  	if(x*x+y*y<=d)ans++;
 
  }
  cout<<ans;
}







Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll        = long long;
using ld        = long double;
using vl        = vector<ll>;
using vd        = vector<ld>;
using vs        = vector<string>;
using vb        = vector<bool>;
using vvl       = vector<vector<ll>>;
using vvd       = vector<vector<ld>>;
using vvs       = vector<vector<string>>;
using vvb       = vector<vector<bool>>;
using pll       = pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T& a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T& a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll X, N, M;
    cin >> N >> X >> M;
    ll ans= 0;
    vl EM(M, -1);
    vl lo(M * 2);
    bool did= 0;
    REP(i, N) {
        if(i != 0) {
            if(EM[X] != -1 && did == 0) {
                ll nokori= N - i;
                ans+= (nokori / (i - EM[X])) * (lo[i - 1] - lo[EM[X] - 1]);
                i+= (nokori / (i - EM[X]))*(i - EM[X]);
                did= 1;
            }
        }
        if(i >= N)break;
        ans+= X;
        if(i != 0 && did == 0) EM[X]= i;
        if(did == 0) lo[i]= ans;
        X= X * X % M;
        if(X == 0) break;
    }
    cout << ans << "\n";
}

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

int main()
{
ll n;
vector<ll> p(3,0);
cin >> n >> p[0] >> p[1] >> p[2] ;
vector<vector<ll>> v(n, vector<ll>(3,0) );
vector<char> ans(n);

rep(i,n){
  string s;
  cin >> s;
  if(s=="AB"){v[i][0]++;v[i][1]++;}
  if(s=="AC"){v[i][0]++;v[i][2]++;}
  if(s=="BC"){v[i][1]++;v[i][2]++;}
}
if(p[0]+p[1]+p[2]>=3||p[0]+p[1]+p[2]<=1){
  rep(i,n){
    bool ok=0;
    ll ind=-1;
    rep(j,3){
      if(v[i][j]&&p[j]>0)ok=1;
      if(v[i][j]&&ind==-1){ind=j;}
      else if(v[i][j]){
        if(p[ind]>=p[j]){ans[i]='A'+j;p[j]++;p[ind]--;}
        else {ans[i]='A'+ind;p[j]--;p[ind]++;}
      }
    }
    if(!ok){cout << "No" << endl;return 0;}
  }
}
else{
  rep(i,n){
    bool ok=0;
    ll ind=-1;
    rep(j,3){
      if(v[i][j]&&p[j]>0)ok=1;
      if(v[i][j]&&ind==-1){ind=j;}
      else if(v[i][j]){
        if(p[ind]==1&&p[j]==1&&i!=n-1){
          if(v[i+1][ind]){ans[i]='A'+ind;p[j]--;p[ind]++;}
          else{ans[i]='A'+j;p[j]++;p[ind]--;}
        }
        else if(p[ind]>p[j]){ans[i]='A'+j;p[j]++;p[ind]--;}
        else {ans[i]='A'+ind;p[j]--;p[ind]++;}
      }
    }
    if(!ok){cout << "No" << endl;return 0;}
  }
}
cout << "Yes" << endl;
for(auto r:ans){
  cout << r << endl;
}
return 0;
}

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

string s;
int main()
{
    cin >> s;
    int start = -1;
    string res;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A')
        {
            start = i;
            break;
        }

    }
    int end = -1;
    for(int i = s.size() -1; i >= 0; i--)
        if(s[i] == 'Z')
        {
            end = i;
            break;
        }
    cout  << end -  start + 1<< endl;

}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
c = gcd(a, b)

def extgcd(a, b, d=0):
    g = a
    if b == 0:
        x, y = 1, 0
    else:
        x, y, g = extgcd(b, a % b)
        x, y = y,  x - a // b * y
    return x, y, g

print(*extgcd(a, b)[:2])



Measured memory_bytes: 7108
#include<iostream>
#include<algorithm>
#include<vector>
using LL =    long long;
using namespace std;

LL pow_l(LL x, LL n) {
	LL mod = 1e9 + 7;

	LL res = 1, x_n = x;
	while (n > 0) {
		if ((n & 1) == 1) {
			res *= x_n;
			res = res % mod;
		}
		n = n >> 1;
		x_n = x_n * x_n % mod;
		if (x_n == 0) {
			return 0;
		}
	}

	return res;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int main() {
	LL N;
	cin >> N;
	vector<LL>A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	LL sum = 0, s_sum = 0;
	LL mod = 1e9 + 7;

	for (int i = 0; i < N; i++) {
		sum += A[i] % mod;
		sum = sum % mod;
		s_sum += A[i] * A[i] % mod;
		s_sum = s_sum % mod;
	}

	LL ans = (sum * sum % mod - s_sum);
	while (ans < 0) {
		ans += mod;
	}
	ans %= mod;
	LL temp1 = (mod + 1) / 2;
	LL temp2 = modinv(2, mod);
	ans = ans * (modinv(2, mod) % mod);
	//ans = ans + 9223372036854775807 % mod;
	
	ans = ans % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007

int h,w;
int dp[1002][1002];
char grid[1002][1002];

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			dp[i][j]=0;
			cin>>grid[i][j];
		}
	}
	for(int i=1;i<=h;i++)
	{
		if(grid[i][1]=='.')
		{
			dp[i][1]=1;
		}
		else
			break;
	}
	for(int j=1;j<=w;j++)
	{
		if(grid[1][j]=='.')
		{
			dp[1][j]=1;
		}
		else
			break;
	}
	for(int i=2;i<=h;i++)
	{
		for(int j=2;j<=w;j++)
		{
			if(grid[i][j]=='.')
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			}
		}
	}
	cout<<dp[h][w]<<endl;
return 0;
}

Measured memory_bytes: 9088
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=998244353;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

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

char s[N];
void Solve(){
  int n,ans=0;
  cin>>n>>s+1;
  int l=1,r=1;
  while(l<=n&&s[l]=='R')l++;
  r=n;
  while(l<=n){
    if(s[l]=='W'){
      while(r>=l&&s[r]!='R')r--;
      if(r>=l){
        ans++;
        swap(s[r],s[l]);
      }
    }
    l++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3816
# coding: utf-8
# Here your co
import math

def merge(left,right,mid,A):
    global cnt
    n1=mid-left
    n2=right-mid
    L=A[left:mid]
    R=A[mid:right]
    L.append(centi)
    R.append(centi)
    Li,Ri = 0, 0
    for k in range(left,right):
        if L[Li] <= R[Ri]:
            A[k]=L[Li]
            Li+=1
        else:
            A[k] =R[Ri]
            Ri+=1
            cnt += (n1)-Li
            
    
cnt = 0
centi = math.pow(10,10)

def mergesort(left, right , A):
    if left+1 < right:
        mid = (left+right)//2
        mergesort(left,mid,A)
        mergesort(mid,right,A)
        merge(left,right,mid,A)
        
        
Right=int(input())
N=list(map(int,input().split()))

mergesort(0,Right,N)
print(cnt)

Measured memory_bytes: 30160
import java.util.Arrays;

public class Main {
    // field
    static int arraySize, truck;
    static  int[] input;

    // method
    public static void main(String[] args) {
	//System.out.print("> ");
	java.util.Scanner scan = new java.util.Scanner(System.in);
	arraySize = scan.nextInt();          // n
	truck = scan.nextInt();              // k
	input = new int[arraySize];
	//System.out.print("> ");
	for (int i = 0; i < arraySize; i++){
	    input[i] = scan.nextInt();
	}
	int ans = solve();
	System.out.println(ans);
    }

    private static int solve(){
	int left = 0;
	int right = 100000*10000;
	while(right-left>1){
	    int mid = (left+right)/2;
	    int v = search_maxv(mid);
	    if (v >= arraySize) {
		right = mid;
	    } else {
		left = mid;
	    }
	}
	return right;
    }

    private static int search_maxv(int P){
	int v = 0;
	for (int i = 0; i<truck; i++) {
	    int w = 0;
	    while(w+input[v]<=P){
		w+=input[v];
		v++;
		if(v == arraySize) return v;
	    }
	}
	return v;
    }
}



Measured memory_bytes: 71240
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>

using namespace std;
using ll = long long int;


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

  cout<<n*(n-1)/2+m*(m-1)/2 <<endl;
  
  return 0;
}

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

int main() {
	int N, M, R;
	cin >> N >> M >> R;
	vector<int> r(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}
	sort(r.begin(), r.end());
	vector<vector<int>> D(N, vector<int>(N, 1<<29));
	for (int i = 0; i < M; i++) {
		int A, B, C;
		cin >> A >> B >> C;
		D[A - 1][B - 1] = C;
		D[B - 1][A - 1] = C;
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
	int MIN = 1 << 29;
	do {
		int sum = 0;
		for (int i = 0; i < R - 1; i++) sum += D[r[i]][r[i + 1]];
		MIN = min(MIN, sum);
	} while (next_permutation(r.begin(), r.end()));
	cout << MIN << endl;
}

Measured memory_bytes: 3728
#include <iostream>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a >= b && a >= c) {
        cout << a * 10 + b + c << endl;
    } else if (b >= a && b >= c) {
        cout << a + b * 10 + c << endl;
    } else {
        cout << a + b + c * 10 << endl;
    }   
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

d = Counter(D)
t = Counter(T)
d_key = list(d.keys())
t_key = list(t.keys())

p = len(d_key)
d_key += t_key
q = set(d_key)

if p != len(q):
    print('NO')
    exit()

for i in t_key:
    if t[i] > d[i]:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 128072
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int N; cin>>N;
    set<int> S;
    rep(i, N) {
        int A; cin>>A;
        if(S.count(A)>0) S.erase(A);
        else S.insert(A);
    }
    cout << S.size() << endl;
    return 0;
}

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

int dfs(int i,int n,int turn){
    if(n==0)
        return 1;
    if(turn==4)
        return 0;
    int res=0;
    for(int j=i;j*j<=n;j++){
        res+=dfs(j,n-j*j,turn+1);
    }
    return res;
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<dfs(1,n,0)<<endl;

    }
    return 0;

}

Measured memory_bytes: 3096
//#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<time.h>
#include<set>
#include <random>
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define fore(i,fa,fb) for(i=fa;i<=fb;++i)
#define all(n) (n.begin(),n.end())
#define F first
#define S second
typedef long long ll;
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	int i, j, k, m, n;
	string a, b, c;
	cin >> a >> b;
	if (a == "H")
	{
		if (b == "H")
			cout << "H";
		else cout << "D";
	}
	else
	{
		if (b == "H")
			cout << "D";
		else cout << "H";
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using pii = std::pair<int, int>;

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

const int mn = 1e5 + 5;

vector<string> v{"MON","TUE","WED","THU","FRI","SAT","SUN"};

int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    string s;
    cin>>s;
    for(int i=0;i<sz(v);i++){
        if (s==v[i]) {
            if (i==6) printf("%d\n",7);
            else printf("%d\n",6-i);
            exit(0)
;        }
    }
    return 0;
}

Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for i in range(q)]
data=[0]*(n+1)
if s[0]=='A' and s[1]=='C':
  data[1]=1
for i in range(1,n-1):
  if s[i]=='A' and s[i+1]=='C':
    data[i+1]+=1
  data[i+1]+=data[i]
data[n]=data[n-1]
for i in range(q):
  print(data[lr[i][1]-1]-data[lr[i][0]-1])

Measured memory_bytes: 92792
N,M=map(int,input().split())

x=[-1]*N
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if (s==c==0 and N>1 or
        x[s]!=-1 and x[s]!=c):
        print(-1)
        exit()
    x[s]=c

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

print(''.join(map(str,x)))


Measured memory_bytes: 61904
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <string>
using namespace std;

int main(void)
{
    //float f;
    string s;
    int m,n,o;
    //vector <float> f(10);
    //char a,b,c;
    int i=0,j,sum=0,dir=1,pos;
    //long long int m,n,o,total=0;
    cin>>n;
    int *num=new int [n];
    if(n%2==0) dir=1;
    else dir=-1;
    for(i=0;i<n;i++)
    {
        pos=n/2+(i+1)/2*dir;
        cin>>num[pos];
        dir=-dir;
    }
    for(i=0;i<n;i++) cout<<num[i]<<' ';
    delete [] num;
    return 0;
}



Measured memory_bytes: 2944
r, g, b, n = map(int,input().split())
res = 0
for i in range(n // r + 1):
    for j in range((n-r*i) // g + 1):
        if (n - (i * r) - (g * j) ) % b == 0:
            #print("{0}, {1}, {2}".format(i, j, (n - (i * r) - (g * j) ) % g))
            res += 1

print(res)


Measured memory_bytes: 40300
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

ll gcd(ll a, ll b){
	if (a==0){
		return b;
	}else{
		return gcd(b%a, a);
	}
}


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	ll N;
	cin >> N;
	ll A[N];
	rep(i, N)cin >> A[i];
	ll l[N], r[N];
	l[0] = A[0];  r[N-1] = A[N-1];
	rep1(i, N-1) l[i] = gcd(l[i-1], A[i]);
	for(ll i=N-2; i>=0; i--) r[i] = gcd(r[i+1], A[i]);
	ll ans = max(r[1], l[N-2]);
	//show(ans);
	rep1(i, N-2) chmax(ans, gcd(l[i-1], r[i+1]));
	cout << ans << endl;

}








Measured memory_bytes: 2560
a = int(input())

if 600 > a >= 400:
    print(8)
elif 800 > a >= 600:
    print(7)
elif 1000 > a >= 800:
    print(6)
elif 1200 > a >= 1000:
    print(5)
elif 1400 > a >= 1200:
    print(4)
elif 1600 > a >= 1400:
    print(3)
elif 1800 > a >= 1600:
    print(2)
elif 2000 > a >= 1800:
    print(1)

Measured memory_bytes: 9064
let (n1, n2, n_limit) = (3, 9, 31)

let goal = Array.init n2 (fun i -> (i + 1) mod n2)

let area = Array.make n2 []

let md = Array.make_matrix n2 n2 0

let initialize_area () =
  for i = 0 to n2 - 1 do
    let lst = [] in
    let lst = if i + n1 < n2 then (i + n1) :: lst else lst in
    let lst = if (i + 1) mod n1 <> 0 then (i + 1) :: lst else lst in
    let lst = if i - 1 >= 0 && (i - 1) mod n1 <> n1 - 1 then (i - 1) :: lst else lst in
    let lst = if i - n1 >= 0 then (i - n1) :: lst else lst in
    area.(i) <- lst;
  done

let initialize_md () =
  for i = 0 to n2 - 2 do
    for j = 0 to n2 - 1 do
      md.(i+1).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done

let idastar a limit space lower =
  let rec doit i space moved lower =
    if i = limit then
      if a <> goal then ()
      else begin
        Printf.printf "%d\n" limit;
        exit 0;
      end
    else
      List.iter (fun j ->
        let x = a.(j) in
        if x = moved then ()
        else
          let lower = lower - md.(x).(j) + md.(x).(space) in
          if lower + i > limit then ()
          else begin
            a.(j) <- 0;
            a.(space) <- x;
            doit (i + 1) j x lower;
            a.(j) <- x;
            a.(space) <- 0;
          end)
      area.(space) in
  doit 0 space (-1) lower

let findi a x =
  let n = Array.length a in
  let rec doit i =
    if i = n then assert false
    else if a.(i) = x then i
    else doit (i + 1) in
  doit 0

let () =
  initialize_area ();
  initialize_md ();
  let a = Array.init n2 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let space = findi a 0 in
  let lower =
    Array.fold_left (fun (i, sum) e -> (i + 1, sum + md.(e).(i))) (0, 0) a |> snd in
  for limit = lower to n_limit do
    idastar a limit space lower
  done

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
queue<ll> q;
int k;

int main() {
    scanf("%d", &k);
    for (int i = 1; i <= 9; i++)q.push(i);
    for (int i = 1; i < k; i++) {
        ll x = q.front();
        q.pop();
        int dig = x % 10;
        if (dig != 0)q.push(x * 10 + dig - 1);
        q.push(x * 10 + dig);
        if (dig != 9)q.push(x * 10 + dig + 1);
    }
    printf("%lld\n", q.front());
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=998244353LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
class Combination{
private:
    vi fact;
public:
    Combination(int size){
        size++;
        fact.resize(size);
        fact[0]=1;
        FOR(i,1,size){
            fact[i]=(fact[i-1]*i)%MOD;
        }
    }
    int Fact(int n){
        return fact[n];
    }
    int MPow(int x,int y){
        if(y==0)return 1;
        if(y%2){
            return (MPow(x,y-1)*x)%MOD;
        }
        int p=MPow(x,y/2);
        return (p*p)%MOD;
    }
    int Comb(int n,int r){
        int res=Fact(n);
        (res*=MPow(Fact(r),MOD-2))%=MOD;
        (res*=MPow(Fact(n-r),MOD-2))%=MOD;
        return res;
    }
};
signed main(){
    ll N,A,B,K;
    cin>>N>>A>>B>>K;
    ll ans=0;
    Combination C(N+100);
    REP(i,N+1){
        if((K-A*i)%B){
            continue;
        }
        ll j=(K-A*i)/B;
        if(j<0||j>N){
            continue;
        }
        ans+=C.Comb(N,i)*C.Comb(N,j)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560