akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

void insert(int k){
  struct Node *x=root,*y=NIL,*z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->right=NIL;
  z->left=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL)root=z;
  else {
     if(z->key < y->key){
       y->left=z;
     }
     else y->right=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,j,x;
  char com[100];
  char str1[]="insert";
  char str2[]="print";

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);

    if(strcmp(str1,com)==0){
      scanf("%d",&x);
      insert(x);
    }

    else if(strcmp(str2,com)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
  }

  }

  return 0;
}


Measured memory_bytes: 25120
#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 = 998244353;
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;
ll gcd(ll x, ll y) {
	if (x < y)swap(x, y);
	while (y) {
		ll r = x % y; x = y; y = r;
	}
	return x;
}
int main(){
	int n; ll k, a; cin >> n >> k >> a;
	ll d = a;
	ll ma = a;
	rep(i, n - 1) {
		cin >> a; d = gcd(a, d); ma = max(ma, a);
	}
	if (k%d == 0&&k<=ma)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

int main()
{
  int n,x,t,temp;
  cin >> n >> x >> t;
  int t1;
  if(n < x) t1=t;
  else
  {
    if(n%x!=0)
    temp= (n/x)+1;
    else
      temp=n/x;
    t1=temp*t;
  }
  cout << t1;
  return 0;
}

Measured memory_bytes: 3596
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var n string
	fmt.Scan(&n)
	in := nextSlice()
	solve(in)
}

func solve(buf []string) {
	var cnt, min int
	p := atoi(buf)
	for i := range p {
		if p[min] > p[i] {
			min = i
			cnt++
		}
	}
	fmt.Println(cnt + 1)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	string S; cin >> S;
rep(i, S.size()) cout << 'x'; cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define bug(x) cerr<<#x<<"="<<x<<endl;



int main( ){
  int n,m,pos,num;

  scanf("%d %d",&n,&m);

   vector<int>s(n+1,-1);

  bool ex=0;

  for(int i=0;i<m;i++){

    scanf("%d %d",&pos,&num);
    pos--;

    if((s[pos]>-1&&s[pos]!=num)||(pos+num<1&&n>1)){
        return cout<<-1<<endl,0;
    }
    s[pos]=num;
  }

    cout<<(s[0]==-1?(n>1?1:0):s[0]);
    for(int i=1;i<n;i++)cout<<max(s[i],0);
    cout<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<climits>
#include<vector>
#include <sstream>
#include<algorithm>
#include<array>
#include<map>

using namespace std;

int main(void) {

	int n;
	string in;

	cin >> n;

	vector<long long> sum(n+1);
	long long buf=0;

	for (int i = 1; i <= n;++i) {
		cin >> in;
		buf += stoll(in);
		sum[i] = buf;
	}

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

	long long score=0,now,combo=0;
	now = sum[0];
	for (int i = 1;i <= n;++i) {
		if(now==sum[i]){
			combo++;
			score += combo;
		}
		else {
			now = sum[i];
			combo = 0;
		}
	}

	cout << score;
	return 0;

}

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

using lint = long long;

int main() {
    int n; lint a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    n--;

    bool ans = false;
    for (int m = 0; m <= n; m++) {// プラスの数で全探索
        lint min = a + c*m - d*(n - m);
        lint max = a + d*m - c*(n - m);
        if (min <= b and b <= max) {
            ans = true;
            break;
        }
    }

    if (ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,A; cin >> N >> A;
    cout << (N%500 <= A ? "Yes" : "No") << endl;
}


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

int main() {
	long long x, g500, g5;
	cin >> x;
	g500 = x / 500;
	x %= 500;
	g5 = x / 5;
	cout << g500 * 1000 + g5 * 5 << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func checkMM(mm string) bool {
	mmI, _ := strconv.Atoi(mm)
	if (mmI == 0) || (mmI >= 13) {
		return false
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextLine()
	front := string(n[0:2])
	back := string(n[2:4])
	checkFront := checkMM(front)
	checkBack := checkMM(back)

	if checkFront && checkBack {
		fmt.Println("AMBIGUOUS")
	} else if checkFront && !checkBack {
		fmt.Println("MMYY")
	} else if !checkFront && checkBack {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MAXN 200000
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    int a[10][110]={0};
    for (int i=0;i<2;i++){
	for (int j=1;j<=N;j++){
	    cin >> a[i][j];
	}
    }

    int sum[110]={0};
    int sum2[110]={0};
    for (int i=1;i<=N;i++){
	sum[i]=sum[i-1]+a[0][i];
	sum2[i]=sum2[i-1]+a[1][i];
    }

    int res=0;
    for (int i=1;i<=N;i++){
	res=max(res,sum[i]+(sum2[N]-sum2[i-1]));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
macro_rules! read {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read!().split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn main() {
    let _: i32 = read_to_vec()[0];
    let input: Vec<i32> = read_to_vec();
    let mut s: i32 = 0;

    for &w in input.iter() {
        s += w;
    }

    let sum = s;
    s = 0;
    let mut weight: i32 = 0;

    for &w in input.iter() {
        s += w;
        if s >= sum / 2 {
            weight = w;
            break;
        }
    }

    s = 2*s - sum;
    let vec = vec![s, 2*weight - s];

    println!("{}", vec.iter().min().unwrap())
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
using namespace std;
int a,c,z=0;
string s;
int main(){
    cin>>a>>s>>c;
    if(s =="+") {
        z = a + c;
        cout << z << endl;
    }
    if(s=="*"){
        z=a*c;
        cout<<z<<endl;
    }
    if(s=="/") {
        z = a / c;
        cout<<z<<endl;
    }
    if(s=="-"){
        z = a - c;
        cout<<z<<endl;
    }
}

Measured memory_bytes: 256
import Control.Monad
import Data.List

kr x
    |x>0 = "Yes"
    |otherwise = "No"

main = do
    ns <- getLine
    let (n:k:q:_) = map read $ words ns :: [Int]
    a <- replicateM q readLn :: IO [Int]
    mapM_ putStrLn $ map kr $ zipWith (-) (map length . group . sort $ a ++ [1..n]) [q-k+1,q-k+1..]


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  int ans=0;
  for(int i = 1;i<=n;i+=2){
    int cnt = 0;
    for(int j = 1;j<=i;j++){
      if(i%j==0) cnt++;
    }
    if(cnt==8) ans++;
  }

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


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    REP (i, S.size()) {
        int j = S.size() - i - 1;
        if (S[i] != S[j]) {
            S[i] = S[j];
            ans++;
        }
    }
    cout << ans << endl;
}

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

typedef pair<int,int> pii;

int N,M;
long long K;
vector<pii> V;
priority_queue<int> Q;
long long D[100010] = {0};

int main()
{
    scanf("%d%lld",&N,&K);
    for(int i = 0; i < N; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        D[a] += b;
    }

    for(int i = 1; i < 100000 + 1; i++)
    {
        K -= D[i];
        if(K == 0)printf("%d\n",i);
        else if(K < 0)printf("%d\n",i);
        if(K <= 0) return 0;
    }
    return 0;
}


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

#define REP(i, a) for(int i=0; i<(int)(a); i++)
#define REP1(i, a, b) for(int i=(int)(a); i<=(int)(b); i++)
typedef long long LL;

const int MAX_N = 105, MAX_W = 100005;
int n, W;
int v[MAX_N], w[MAX_N];
LL dp[MAX_W];
void input() {
    scanf("%d %d", &n, &W);
    REP(i, n) {
        scanf("%d %d", &w[i], &v[i]);
    }
}

void solve() {
    REP(i, n) {
        for(int j=W; j>=w[i]; j--) {
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
        }
    }

    printf("%lld\n", dp[W]);
}

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

Measured memory_bytes: 1024
num = input()
ans = num[-1]

if ans == "3":
  print('bon')
elif ans == "0" or ans == "1" or ans == "6" or ans == "8":
  print("pon")
elif ans == "2" or ans == "4" or ans == "5" or ans == "7" or ans == "9":
  print("hon")

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    if (a<b) swap(a, b);
    if (a<c) swap(a, c);
    rep(i, k) {
        a *= 2;
    }
    int ans = a + b + c;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

bool find(int* array, int num, int min, int max){
  if(array[min] == num){return true;}
  if(array[max] == num){return true;}
  if(array[min] > num){return false;}
  if(array[max] < num){return false;}
  int mid = (min + max) >> 1;
  if(array[mid] >= num){
    return find(array, num, min, mid);
  }else{
    return find(array, num, mid + 1, max);
  }
}

int main(){
  int n, q;
  int S[100000], T[50000];
  int count = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &(S[i]));
  }
  scanf("%d", &q);
  for(int i = 0; i < q; i++){
    scanf("%d", &(T[i]));
  }
  for(int i = 0; i < q; i++){
    if(find(S, T[i], 0, n-1)){
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1592
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	vector< pair<int,int> > teams;

	while ( true )
	{
		string buffer;

		cin >> buffer;

		for ( unsigned int i = 0; i < buffer.length(); i++ )
		{
			if ( buffer[i] == ',' )
			{
				buffer[i] = ' ';
				break;
			}
		}

		int number, point;

		istringstream( buffer ) >> number >> point;

		if ( number == 0 && point == 0 )
		{
			break;
		}

		teams.push_back( pair<int,int>( point, number ) );
	}

	sort( teams.begin(), teams.end(), greater< pair<int,int> >() );

	map<int,int> result;

	int cpoint = teams[0].first, crank = 1;
	for ( unsigned int i = 0; i < teams.size(); i++ )
	{
		if ( teams[i].first != cpoint )
		{
			cpoint = teams[i].first;
			crank++;
		}

		result[ teams[i].second ] = crank;
	}

	int number;
	
	while ( cin >> number )
	{
		cout << result[ number ] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int a[2*maxn];
int b[2*maxn];

int32_t main(){
	fastio();
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int j = 0; j < n; j++){
		cin >> b[j];
	}
	reverse(b,b+n);
	int l = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == b[i]){

			bool ok = false;
			int cnt = 0;
			while((b[l] == a[i] || a[l] == a[i] || b[l] == b[i]) and cnt < n){
				l++;
				l %= n;
				cnt++;
			}
			if(cnt == n){
				cout << "No";
				return 0;
			}
			//cout << i << " " << l << "\n";
			swap(b[l],b[i]);
		}
	}
	cout << "Yes\n";
	for(int i = 0; i < n; i++) cout << b[i] << " ";
}

Measured memory_bytes: 6744
N = int(input())

if N == 1:
    print(0)
    exit()

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
c = collections.Counter(prime_factorize(N))

# print(c)
ans = 0
for key in c.keys():
    i = 1
    while True:
        c[key] -= i
        ans += 1
        i += 1
        if c[key] < i:
            break

print(ans)

Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cout<<(#x)<<" is "<<(x)<<endl //to debug values of variables
#define ZINDA cout<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
 
int nDig(lld n)
{
	return floor(log10(n) + 1);
}

//--------------------------------------------------------------------------------
 
int main()
{
    SPEEDUP;
 	lld h,n,sum=0;
 	cin>>h>>n;

 	int arr[n];
 	FORZ(i,n)
 	{
 		cin>>arr[i];
 		sum+=arr[i];
	}

 	cout<<((sum>=h)?"Yes" : "No");
    return 0;
}

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

int main()
{
    ll N, M;
    cin >> N;
    vector<ll> D(N);
    unordered_map<ll, ll> md;
    rep(i, N){
        cin >> D[i];
        if (md.find(D[i]) == md.end()){
            md[D[i]] = 1;
        }else{
            md[D[i]] += 1;
        }
    }
    cin >> M;
    vector<ll> T(M);
    unordered_map<ll, ll> mt;
    rep(i, M){
        cin >> T[i];
        if (mt.find(T[i]) == mt.end()){
            mt[T[i]] = 1;
        }else{
            mt[T[i]] += 1;
        }
    }

    if (N < M){
        puts("NO");
        return 0;
    }
    
    for(auto x: mt){
        if (md[x.first] < x.second){
            puts("NO");
            return 0;
        }
    }

    puts("YES");


    return 0;
}


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

    int a,b;
    cin>>a>>b;
    if((a==1||b==1)&&(a==2||b==2))  cout<<3<<endl;
    if((a==1||b==1)&&(a==3||b==3))  cout<<2<<endl;
    if((a==2||b==2)&&(a==3||b==3))  cout<<1<<endl;

 return 0;
}

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

int main() {
  	int x1, x2, x3, x4, x5;
  	cin >> x1 >> x2 >> x3 >> x4 >> x5;
  	if (x1 == 0) cout << 1 << endl;
  	if (x2 == 0) cout << 2 << endl;
  	if (x3 == 0) cout << 3 << endl;
  	if (x4 == 0) cout << 4 << endl;
  	if (x5 == 0) cout << 5 << endl;
}

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

MOD = 1000000007  # type: int


def solve(n: int, a: int, b: int):
    # 1本選ぶ時→nC1、2本選ぶ時→nC2、...、n本選ぶ時→nCn
    # 二項定理の和の公式より、上記の和はnC1+nC2+...+nCn=2**n
    # ans=2**n-1-nCa-nCb # 「-1」は、0本選ぶ場合を除外している。(問題の制限がN>=1なので)
    # 数列nCaの総和 = ΣnCa = n/1 + n(n-1)/2*1 + n(n-1)(n-2)/3*2*1 + ... + n(n-1)(n-2)...(n-a+1)/a!
    # ΣnCa = Π(n-a)/a! # Π(パイ)は総乗(数列を掛け算した合計)のこと。Σ(シグマ)は総和。
    # 2**nは普通に**で求めるとTLEする。python3ならpow()を使用することでO(logn)で計算できる。「繰り返し二乗法」という。
    # 繰返し二乗法・・・f(x) = 2**x、f(2x) = f(x)**2、f(2x+1) = f(x)**2 * 2、f(N) = f(2/N)**2
    nCa = choose(n, a)
    nCb = choose(n, b)
    ans = (pow(2, n, MOD) - 1 - nCa - nCb) % MOD
    print(int(ans))


def choose(n, a):
    x = y = 1  # xが分子、yが分母
    for i in range(a):
        x *= n - i
        x %= MOD
        y *= i + 1
        y %= MOD
    # 割り算はコストが高いので,x/yするとTLEする。
    # mod pの結果が素数の場合は、フェルマーの小定理でx=x**(p-1)となる。
    # ここから逆元(逆数)を求めると、1/x = x**(p-1)/x = x**(p-2)となる。
    return x * pow(y, MOD-2, MOD) % MOD


# Generated by 1.1.6 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()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float('inf')
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0

from itertools import product, permutations
for i, k in product(range(1, 1 + n), repeat=2):
    dists[:, k] = np.minimum(dists[:, k], dists[:, i] + dists[i, k])

ans = float('inf')
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val

print(ans)

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

int main() {
  int a, b;
  cin >> a >> b;
  a--;
  b--;
  int ans = b / a;
  if (b % a > 0) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    int N, M; cin >> N >> M;
    vector<vector<P>> mp(N);
    rep(i, M) {
        int P, Y; cin >> P >> Y;
        P -= 1;
        mp[P].push_back(make_pair(Y, i));
    }

    vector<pair<int, int>> mm(M);
    rep(i, N) {
        sort(mp[i].begin(), mp[i].end());
        int count = 1;
        for (auto pir : mp[i]) {
            mm[pir.second].first = i+1;
            mm[pir.second].second = count;
            count += 1;
        }
    }

    rep(i, M) {
        cout << setw(6) << setfill('0') << mm[i].first;
        cout << setw(6) << setfill('0') << mm[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 7808
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def su(N):
    return N*(N+1) / 2

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(1,n+1):
        ans += i * su(n//i)
    print(int(ans))



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9176
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
struct Town {
  int idx, x, y;
  bool operator< (const Town &other) const { return y < other.y; }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<Town> towns(N);
  REP(i, N) {
    cin >> towns[i].x >> towns[i].y;
    towns[i].x--; towns[i].y--;
    towns[i].idx = i;
  }
  sort(ALL(towns), [](auto const &a, auto const &b) { return a.x > b.x; });
  dsu d(N);
  set<Town> st;
  REP(i, N) {
    auto t = st.upper_bound(towns[i]);
    Town tmp = towns[i];
    while(t != st.end()) {
      d.merge(towns[i].idx, (*t).idx);
      if(tmp.y < (*t).y) tmp = *t;
      t++;
    }
    st.insert(tmp);
  }
  REP(i, N) cout << d.size(i) << "\n";
}

Measured memory_bytes: 7432
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 200500;
const int mod = 1e9 + 7;
int a[N];
int n, ans;
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		a[i] -= i + 1;
	}
	for (int i = 0; i < n;) {
		if (a[i] == 0) {
			int cnt = 0;
			while (i < n && a[i] == 0) {
				cnt++;
				i++;
			}
			ans += (cnt + 1) / 2;
		} else {
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main () {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  if (N > K) {
  	cout << K * X + (N - K) * Y << endl;
  }
  
  else {
    cout << N * X << endl;
  }
}


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

using namespace std;
using ll = long long;
using pa = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll H,W;
    cin>>H>>W;
    ll x,y;
    rep(i,H)rep(j,W){
    	string s;
    	cin>>s;
    	if(s=="snuke"){
    		x=j,y=i+1;
    	}
    }
    cout<<(char)('A'+x)<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

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

void solve(void){
    int a, b;
    cin >> a >> b;
    cout << ((a <= b)?a:a-1) << '\n';
}

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


Measured memory_bytes: 256
n,m=list(map(int, input().split()))
h  =list(map(int, input().split()))
answer=[0]*n
for i in range(m):
    a,b=list(map(int, input().split()))
    if(h[a-1]>=h[b-1]):
        answer[b-1]+=1
    if(h[a-1]<=h[b-1]):
        answer[a-1]+=1
anum=0
for i in answer:
    if(i==0):
        anum+=1
print(anum)

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

ll mod = 1e9+7;

ll modpow(int a,int b){
    if(b == 0) return 1;
    ll ans = modpow(a,b/2);
    ans = ans * ans % mod;
    if(b%2 == 1) ans = ans * a % mod ;
    return ans;
}

ll modinv(int x){
    return modpow(x,mod-2);
}
ll comb(int N, int K){
    ll n1 = 1,n2 = 1;
    rep(i,K) n1 = n1 * (N-i) % mod;
    rep(i,K) n2 = n2 * (i+1) % mod;
    ll ans = n1*modinv(n2) % mod;
    return ans;
}

int main(){
    int n,k; cin >> n >> k;
    for(int i = 1;i <= k;++i){
        ll num;
        num = comb(k-1,i-1)*comb(n-k+1,i)%mod;
        cout << num << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;


int main()
{
    string ans = "";
    ll n; cin >> n;
    while (n > 0) {
        n--;
        char c = 'a' + n % 26;
        n /= 26;
        //cout << c << endl;
        ans.insert(ans.begin(), c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
#define EPS 0.000000001

bool eq(double a,double b){
  return (-EPS<a-b&&a-b<EPS);
}

int main(){
  while(1){
    double D,px,py,vx,vy;
    cin>>D;
    if(D==0.0)break;
    cin>>px>>py>>vx>>vy;
    if(eq(vx,0.0)){
      swap(px,py);
      swap(vx,vy);
    }

    double t=(-px)/vx;
    if(!eq(-py,vy*t)){
      cout<<"impossible"<<endl;
      continue;
    }
    double d=sqrt(vx*vx+vy*vy)*t;
    if(t<0.0){
      d=2.0+d;
    }
    if(d<D){
      printf("%.8f\n",d);
    }else{
      cout<<"impossible"<<endl;
    }
    
  }
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  bool flag = true;
  if(a % 3 != 0 && b % 3 != 0 && (a+b) % 3 != 0) {
    flag = false;
  }
  
  if(flag) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}

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

const int maxn = 100000 + 10;
int a[maxn];
int dp[maxn];

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; scanf("%d", &a[i]), i ++ );

	for(int i = 2; i <= n; i++) dp[i] = INT_MAX;
	for(int i = 1; i <= n; i++) {
		dp[i+1] = min(dp[i+1], dp[i] + abs(a[i]-a[i+1]));
		dp[i+2] = min(dp[i+2], dp[i] + abs(a[i]-a[i+2]));
	}

	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m;
    ll k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];

    vector<ll> sa(n,0);
    sa[0]=a[0];
    for(int i=1;i<n;i++) sa[i]=sa[i-1]+a[i];
    vector<ll> sb(m,0);
    sb[0]=b[0];
    for(int i=1;i<m;i++) sb[i]=sb[i-1]+b[i];


    int ans=0;
    rep(i,n){
        if(sa[i]>k) break;
        int tmp=i+1;
        ll x=k-sa[i];
        if(sb[0]>x){
            ans=max(ans,tmp);
        }
        else{
            int ind=upper_bound(all(sb),x)-sb.begin();
            tmp+=ind;
            //cout<<tmp<<endl;
            ans=max(ans,tmp);
        }
        
    }

    rep(i,m){
        if(sb[i]>k) break;
        int tmp=i+1;
        ll x=k-sb[i];
        if(sa[0]>x){
            ans=max(ans,tmp);
        }
        else{
            int ind=upper_bound(all(sa),x)-sa.begin();
            tmp+=ind;
            ans=max(ans,tmp);
        }
        
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 9580
n = gets.to_i
x = []
y = []

n.times do
  line = gets.split.map(&:to_i)
  x << line.shift
  y << line.shift
end

#道の組み合わせ
per = []
(0..n-1).each do |i|
    per[i]=i
end
per=per.permutation(n).to_a
#p per

total=0
(0..per.size-1).each do |i|
    (0..per[i].size-2).each do |j|
        total+=((x[per[i][j]]-x[per[i][j+1]])**2+(y[per[i][j]]-y[per[i][j+1]])**2)**0.5
    end
end
#p total
p total/per.size


Measured memory_bytes: 8188
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????

NEXT = 2
DATA = 1
PREV = 0
from collections import deque
def dll_processor(operations):
    
    front = None
    end = None
    dll = deque([])
    for o in operations:
        if o[0] == "insert":
            dll.appendleft(o[1])
            #front, end = insert(front, end, o[1])
        elif o[0] == "delete":
            if o[1] in dll:
                dll.remove(o[1])
            #front, end = delete(front, end, o[1])
        elif o[0] == "deleteFirst":
            dll.popleft()
            #front, end = delete_first(front, end)
        else:
            dll.pop()
            #front, end = delete_last(front, end)
        #print(get_list(front))
        
    return dll

def get_list(front):
    if not front:
        return []
    
    l = []
    target = front
    while True:
        l.append(target[DATA])
        if not target[NEXT]:
            break
        target = target[NEXT]
    return l

def insert(front, end, target):
    node = [None, target, None]
    if front:
        front[PREV] = node
        node[NEXT] = front
        return node, end
    else:
        return node, node
    
def delete(front, end,target):

    delete_node = front
    while not delete_node[DATA] == target:
        delete_node = delete_node[NEXT]
        if delete_node == None:
            return front, end

    if delete_node[PREV] == None:
        delete_node[NEXT][PREV] = None
        return delete_node[NEXT], end
    elif delete_node[NEXT] == None:
        delete_node[PREV][NEXT] = None
        return front, delete_node[PREV]
    else:
        delete_node[NEXT][PREV] = delete_node[PREV]
        delete_node[PREV][NEXT] = delete_node[NEXT]
        return front, end
    
def delete_last(front, end):
    
    if not end[PREV]:
        return None, None
    else:
        end[PREV][NEXT] = None
        return front, end[PREV]
    
def delete_first(front, end):
    
    if not front[NEXT]:
        return None, None
    else:
        front[NEXT][PREV] = None
        return front[NEXT], end

def main():
    n_list = int(input())
    target_list = [input().split() for i in range(n_list)]
    print(*dll_processor(target_list))
    
if __name__ == "__main__":
    main()

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

int main(){
    double pai=3.141592653589;
    int a;
    long long s=0;
    scanf("%d",&a);
    vector<long>ar(a);
    for(auto&e:ar){
        scanf("%ld",&e);
    }
    sort(ar.begin(),ar.end());
    for(int i=0;i<a;i++){
        s+=ar[i];
    }
    printf("%ld %ld %lld\n",ar[0],ar[a-1],s);
    return 0;
}


Measured memory_bytes: 3312
#!/usr/bin/env python3
import sys
from collections import Counter
import heapq
INF = float("inf")


def solve(N: int, K: int, A: "List[int]"):
    counter = Counter(A)
    # print(counter)
    values = sorted(counter.values())
    # print(values)
    if len(values) < K:
        print(0)
    else:
        print(sum(values[:len(values)-K]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43744
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn pow(x: i32, y: i32, p: i32) -> i32 {
  if y == 0 {
    x
  } else if y % 2 == 1 {
    (pow(x, y - 1, p) * x) % p
  } else {
    let a = pow(x, y / 2, p);
    a * a % p
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    p: i32,
    a: [i32; p as usize],
  }
  let pu = p as usize;
  let mut fact = vec![1; pu];
  for i in 1 .. pu {
    fact[i] = (fact[i-1] * i as i32) % p;
  }
  let mut inv_fact = vec![1; pu];
  inv_fact[pu-1] = pow(fact[pu-1], p-1, p);
  for i in (1 .. pu).rev() {
    inv_fact[i-1] = (inv_fact[i] * i as i32) % p;
  }
  let mut ans = vec![0; pu];
  for (i, &x) in a.iter().enumerate() {
    if x == 1 {
      ans[0] = (ans[0] + 1) % p;
      let mut prod = 1;
      for k in 0 .. pu {
        let coef = fact[pu-1] * inv_fact[k] % p * inv_fact[pu-1-k] % p * prod % p;
        if k % 2 == 0 {
          ans[pu-1-k] = (ans[pu-1-k] + p - coef) % p;
        } else {
          ans[pu-1-k] = (ans[pu-1-k] + coef) % p;
        }
        prod = (prod * i as i32) % p;
      }
    }
  }
  for &x in &ans {
    puts!("{} ", x);
  }
  puts!("\n");
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

vector<int> h;

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

    // もらうDP
    vector<int> mi(N, INF);
    mi[0] = 0;
    for (int i = 1; i < N; i++) {
        for (int k = 1; k <= K and 0 <= i - k; k++) {
            mi[i] = min(mi[i], mi[i - k] + abs(h[i] - h[i - k]));
        }
    }
    cout << mi[N - 1] << endl;
    // dump(mi);

    return 0;
}

Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
int a[100005],n;
char s[100005];
signed main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;){
        int j=i;
        while(j+1<=n&&s[j+1]=='R') j++;
        int k=j+1,l=k;
        while(l+1<=n&&s[l+1]=='L') l++;
        // printf("%d %d %d %d\n",i,j,k,l);
        int L=j-i+1,R=l-k+1;
        if((L+R)&1)
        {if(L&1){
            a[j]=(L+R)/2+1;
            a[k]=L+R-a[j];
        }
        else{
            a[k]=(L+R)/2+1;
            a[j]=L+R-a[k];
        }}
        else a[j]=a[k]=L+R>>1;
        i=l+1;
    }
    for(int i=1;i<=n;i++)
        printf("%d ",a[i]);
}

// RLLLL
//
// 11111
// 01121
// 00122
// 00032
//
// 11111
// 12110
// 22100
// 23000


Measured memory_bytes: 896
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8").split('');

// B - 美しい文字列
let result: boolean = true;

const tag = input.filter((x) => {
    return x !== '\n';
});

tag.forEach(x => {
    if (tag.filter((y) => { return y === x }).length % 2 !== 0) {
        result = false;
    } 
})

if (result) {
    console.log('Yes');
} else {
    console.log('No');
}

// 手元のテストはクリアしているのになぜが違うと言われる

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


int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h.at(i);
  }

  int count = 0, maxcount = 0;

  for(int i=0; i<n-1; i++){
    if(h.at(i) >= h.at(i+1)){
      count += 1;
    }else{
      maxcount = max(count, maxcount);
      count = 0;
    }
  }

  maxcount = max(count, maxcount);

  cout << maxcount << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll pow(ll a,ll b,ll m)
{
    ll ans=1;
    a%=m;
    while(b)
    {
        if(b&1)ans=(ans%m)*(a%m)%m;
        b/=2;
        a=(a%m)*(a%m)%m;
    }
    ans%=m;
    return ans;
}
ll inv(ll x,ll p)
{
    return pow(x,p-2,p);
}
ll C(ll n,ll m,ll p)
{
    if(m>n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<=n;i++) up=up*i%p;
    for(int i=1;i<=m;i++) down=down*i%p;
    return up*inv(down,p)%p;
}


int main()
{
	ll n,k;cin>>n>>k;
	ll maxn=0,minn=0;
	ll ans=0;
	for(ll i=k;i<=n+1;i++)
	{
		maxn=(n+n-i+1)*i/2%mod;
		minn=(i-1)*i/2%mod;
		ll temp=maxn-minn+1;
		ans+=temp;
		ans%=mod;
	}
	while(ans<0)
	ans+=mod;
	cout<<ans<<endl;
}
 

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int k;
	cin >> k;
	ll ans = 0;
	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			for (int p = 1; p <= k; ++p) {
				ans += gcd(i, gcd(j, p));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H;
    cin>>H;
    vector<int> A(251);
    for(int i=0;i<H;i++){
        cin>>A[i+1];
    }

    for(int i=1;i<H+1;i++){
        cout<<"node "<<i<<": key = ";
        cout<<A[i];
        cout<<", ";
        int p=i/2,l=i*2,r=i*2+1;
        if(1<=p&&p<=H){
            cout<<"parent key = ";
            cout<<A[p];
            cout<<", ";
        }
        if(1<=l&&l<=H){
            cout<<"left key = ";
            cout<<A[l];
            cout<<", ";
        }
        if(1<=r&&r<=H){
            cout<<"right key = ";
            cout<<A[r];
            cout<<", ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);
  int res;
  
  int max1, max2;
  if (A%2 == B%2 && B%2 == C%2) {
    max1 = max(B, C);
    max2 = max(A, max1);
    res = (max2 - A)/2 + (max2 - B)/2 + (max2 - C)/2;
  } else if (A%2 == B%2) {
    max1 = max(B+1, C);
    max2 = max(A+1, max1);
    res = (max2 - (A+1))/2 + (max2 - (B+1))/2 + (max2 - C)/2 + 1;
  } else if (B%2 == C%2) {
    max1 = max(B+1, C+1);
    max2 = max(A, max1);
    res = (max2 - A)/2 + (max2 - (B+1))/2 + (max2 - (C+1))/2 + 1;
  } else if (A%2 == C%2) {
    max1 = max(B, C+1);
    max2 = max(A+1, max1);
    res = (max2 - (A+1))/2 + (max2 - B)/2 + (max2 - (C+1))/2 + 1;
  }
  printf("%d\n", res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, m; cin >> n >> m;
	if (n == 1 || m == 1) {
		cout << max(n * m - 2, 1ll) << endl;
	} else {
		cout << (n - 2) * (m - 2) << endl;
	}
	return 0;
}


Measured memory_bytes: 256