akhauriyash/Code-Regression huggingface dataset:
N = int(input())
mi = 10**15
ans_i = 0
ans_j = 0
for i in range(2, 10**6+1):
    if N % i == 0:
        j = N // i
        if mi > (i+j-2):
            mi = i+j-2
            ans_i = i
            ans_j = j
if ans_i+ans_j != 0:print(ans_i+ans_j-2)
else:print(N-1)
        




Measured memory_bytes: 2940
#include<stdio.h>
int MAX = 100;
static int INFTY = 99999;
static int WHITE = 0;
static int GRAY = 1;
static int BLACK = 2;

int n, A[100][100];

int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];
  for(int i = 0;i < n;i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
  while(1){
    minv = INFTY;
    u = -1;
    for(int i = 0;i < n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(int v = 0;v < n;v++){
      if(color[v] != BLACK && A[u][v] != INFTY){
	if(d[v] > A[u][v]){
	  d[v] = A[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(int i = 0;i < n; i++){
    if(p[i] != -1)sum += A[i][p[i]];
  }
  return sum;
}

int main(){
  scanf("%d",&n);
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      int e; scanf("%d",&e);
       A[i][j] = (e == -1) ? INFTY : e;
    }
  }
  printf("%d\n",prim());
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <atcoder/all>

//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cerr << #x << " " << x << endl;
#define debl(x) std::cerr << #x << " " << x << " ";
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
//const ll LINF = 1001002003004005006ll;
//const int INF = 1001001001;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}


int op(int a, int b){
    return max(a,b);
}

int e() { return 0;}

constexpr int mxA = 3e5;
void solve(){
    int n, k;
    read(n,k);
    int ans = 0; 
    segtree<int, op, e> seg(mxA + 1);

    REP(i,n){
        int a;
        read(a);
        int lb = max(0, a - k);
        int rb =  min(a + k + 1, mxA + 1);
        int res = 1 + seg.prod(lb, rb);
        seg.set(a, res);
        // debl(a) debl(lb) deb(rb);
        // deb(res);
        ans = max(res, ans);
    }
    cout << ans  << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



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

#define MOD (long long)(1e9+7)

using ll = long long;

ll factmod(ll in)
{
    ll ret=1;
    for(;in>=1;in--)
    {
        ret*=in;
        ret%=MOD;
    }
    
    return ret;
}

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

    int n,m;cin>>n>>m;

    ll ans=0;

    if(abs(n-m)==1) ans=(factmod(n)*factmod(m))%MOD;
    else if(n==m) ans=(factmod(n)*factmod(m)*2)%MOD;

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3620
<?php
  list($h, $w) = explode(" ", trim(fgets(STDIN)));

  $c = [];
  for ($i=0; $i<=9; $i++) {
    $c[$i] = explode(" ", trim(fgets(STDIN)));
  }

  for ($k=0; $k<=9; $k++){
    for ($i=0; $i<=9; $i++) {
      for ($j=0; $j<=9; $j++) {
        $c[$i][$j] = min($c[$i][$j], $c[$i][$k]+$c[$k][$j]);
      }
    }
  }

  $cnt = array_fill(-1, 11, 0);
  for ($i=0; $i<$h; $i++) {
    $a = explode(" ", trim(fgets(STDIN)));
    for ($j=0; $j<$w; $j++) {
      $cnt[$a[$j]]++;
    }
  }

  $ans = 0;
  for ($i=0; $i<=9; $i++) {
//    echo $i." ".$cnt[$i]." ".$c[$i][1].PHP_EOL;
    $ans += $cnt[$i]*$c[$i][1];
  }

  echo $ans;

Measured memory_bytes: 16208
N = int(raw_input())
S = [raw_input() for _ in range(N)]

cnt = 0
flag = True

for i in S:
    if i == "A":
        cnt += 1
    else:
        cnt -= 1;
    
    if cnt < 0:
        flag = False
        break

if cnt != 0:
    flag = False

print "YES" if flag else "NO"



Measured memory_bytes: 4640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

int main() {
    int n;
    scanf("%d",&n);
    int sum=0;
    int minn=INF;
    bool flag=false;
    for(int i=1; i<=n; i++){
        int x;
        scanf("%d",&x);
        sum+=x;
        if(x%10!=0){
            flag=true;
            minn=min(minn,x);
        }
    }

    if(!flag)
        printf("0\n");
    else{
        if(sum%10!=0)
            printf("%d\n",sum);
        else
            printf("%d\n",sum-minn);
    }

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var s, w int
	fmt.Fscan(r, &s)
	fmt.Fscan(r, &w)

	if s <= w {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


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

int main()
{
	int n,m;
	long long sum=0;
	cin>>n>>m;
	int count=0;
	int a[n];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
//	cout<<sum<<" ";
	float min=(4*m);
	
	min=sum/min;
//	cout<<min<<" ";
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=min)
		{
			count++;
		}
	}
	if(count>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

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

	int count;

	if (s[0] == 'a') {
		if (s[1] == 'b') {
			if (s[2] == 'c') {
				cout << "Yes" << endl;
			}
		}
		else if (s[1] == 'c') {
			if (s[2] == 'b') {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
	else if(s[0]=='b'){
		if (s[1] == 'a') {
			if (s[2] == 'c') {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (s[1] == 'c') {
			if (s[2] == 'a') {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (s[0] == 'c') {
		if (s[1] == 'b') {
			if (s[2] == 'a') {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (s[1] == 'a') {
			if (s[2] == 'b') {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}


	return 0;
	system("pause");
}

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


int main() {

  int n;
  cin>>n;
  rep(i,n){
    cout<<"ACL";
  }
  cout<<endl;
  return 0;

}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        sc.close();

        int numHeadingOne = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                numHeadingOne++;
            } else {
                break;
            }
        }
//        System.out.println(numHeadingOne);

        if (k <= numHeadingOne) {
            System.out.println('1');
        } else {
            System.out.println(s.charAt(numHeadingOne));
        }

    }
}


Measured memory_bytes: 23124
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 998244353
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

a,b,c,d = m()

ans = 0

po = c-a

poo = d-b
dp = [[0 for i in range(poo+1)]for j in range(po+1)]
dp[0][0] = 1
for i in range(po+1):
	for j in range(poo+1):
		if i == 0:
			if j != 0:
				dp[i][j] = dp[i][j-1] * a
				dp[i][j] %= mod
		else:
			if j == 0:
				dp[i][j] = dp[i-1][j] * b
				dp[i][j] %= mod
			else:
				dp[i][j] = dp[i-1][j] * (b+j) + dp[i][j-1] * (a+i) - (a+i-1)*(b+j-1)*dp[i-1][j-1]
				dp[i][j] %= mod
print(dp[-1][-1])







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

#define ll long long
const int N = 1e5 + 5;

vector<int> adj[N];
int h[N], p[N], sz[N];

void dfs(int u, int prev){
	h[u] = h[prev] + 1;
	sz[u] = 1;
	p[u] = prev;
	for(auto v : adj[u]){
		if(v == prev)	continue;
		dfs(v, u);
		sz[u] += sz[v];
	}
}

int main(){
	int n, u, v;
	scanf("%d", &n);
	for(int i = 1; i < n; i++){
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1, 0);

	int climb = (h[n] - 2)/2;

	int tmp = n;

	while(climb--){
		tmp = p[tmp];
	}

	int black_sz = sz[1] - sz[tmp], white_sz = sz[tmp];
	if(black_sz > white_sz)	cout<<"Fennec\n";
	else cout<<"Snuke\n";
}

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

int main(){
  int a,b;
  vector<bool>exist(3);
  for(int i=0;i<3;i++)exist[i]=true;
  cin>>a;
  exist[a-1]=false;
  cin>>b;
  exist[b-1]=false;
  
  for(int i=0;i<3;i++)
    if(exist[i]==true)cout<<i+1<<endl;
  
  
  return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll N;
    cin >> N;
    ll c5 = 0;
    ll c2 = 0;
    ll cur = 5;
    while(cur <= N){
        c5 += N/cur;
        cur *= 5;
    }
    cur = 2;
    while(cur <= N){
        c2 += N/cur;
        cur *= 2;
    }
    ll c5_ = 0;
    ll c2_ = 0;
    ll n = N/2;
    cur = 5;
    while(cur <= n){
        c5_ += n/cur;
        cur *= 5;
    }
    cur = 2;
    while(cur <= n){
        c2_ += n/cur;
        cur *= 2;
    }
    c2_ += (N/2);
    if(N%2 == 0){
        cout << min(c2_, c5_) << endl;
    }else{
        // cout << c2 << ' ' << c5 << ' ' << c2_ << ' ' << c5_ << endl;
        cout << min(c2-c2_, c5-c5_) << endl;
    }
}

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

int main() {
  int N, count = 0, i = 1;
  cin >> N;
  vector<int> b(N);
  
  for (int i=0; i<N; i++) {
    cin >> b.at(i);
  }
  
  while (count <= N) {
    i = b.at(i-1);
    count++;
    if (i == 2) {
      cout << count << endl;
      break;
    }
  }
  if (i != 2){
  cout << -1 << endl;
  }
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
const int mod=1e9+7;
using namespace std;

int main(){
    int H,W;
    cin>>H>>W;
    char G[H][W];
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j) cin>>G[i][j];
    }
    int R[H+1][W+1];
    for(int i=0; i<=H; ++i){
        for(int j=0; j<=W; ++j) R[i][j]=0;
    }
    R[0][1]=1;
    for(int i=1; i<=H; ++i){
        for(int j=1; j<=W; ++j){
            if(G[i-1][j-1]!='#') R[i][j]=(R[i-1][j]%mod +R[i][j-1]%mod)%mod;
        }
    }
    cout<<R[H][W]<<"\n";
}

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

using namespace std;
using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    map<ll, ll> B;
    for (int i=0;i<N;i++) {
        // auto iter = B.find(A[i]);
        // if (iter != B.end()) B[A[i]]++;
        // else B.emplace(A[i],1);
        B[A[i]]++;
    }
    ll res = 0;
    for (auto iter = B.begin(); iter != B.end(); iter++) { 
        res += (iter->second)*(iter->second -1) / 2;         
    }   
    for (int i=0;i<N;i++){
        res -= B[A[i]]-1;
        cout << res << "\n";
        res += B[A[i]]-1;
    }
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll m = 1e18;
  ll ans = 0;
  REP(i, n) {
    cin >> a[i];
    if (a[i] <= m) {
      ans++;
      m = a[i];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

fn main() {
    let _n: usize = util::get();
    let d: Vec<usize> = util::gets();
    let _m: usize = util::get();
    let t: Vec<usize> = util::gets();

    let mut ds = HashMap::new();
    let mut ts = HashMap::new();

    for &x in &d {
        *ds.entry(x).or_insert(0) += 1;
    }
    for &x in &t {
        *ts.entry(x).or_insert(0) += 1;
    }

    if ts.iter().all(
        |(&k, &v)| ds.get(&k).cloned().unwrap_or(0) >= v,
    )
    {
        println!("YES");
    } else {
        println!("NO");
    }


}


Measured memory_bytes: 25788
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
#include <algorithm>
using namespace std;
int main(void){
    string S; cin >> S;
    int a,b;
    a = count(S.begin(), S.end(), '0');
    b = count(S.begin(), S.end(), '1');
    cout << a + b - abs(a - b) << endl;
}

Measured memory_bytes: 3768
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

int main() {
    ll N, A, B; cin >> N >> A >> B;
    vector<int> x(N);
    for (int i = 0; i < N; i++) cin >> x[i];
    ll ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ans += min((x[i + 1] - x[i]) * A, B);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
puts ceil(n,2)

Measured memory_bytes: 2044
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __ll128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}



void __sol(){
    int n,m; cin >> n >> m;
    if(m%2){
        ll s=1 , e = m;
        while(s<e){
            cout <<s <<" " << e << "\n";
            s++;
            e--;
        }
        s = m+1 , e = 2*m + 1;
        while(s<e){
            cout << s << " " << e << "\n";
            s++;
            e--;
        }
    }
    else{
        ll s=1 , e = m+1;
        while(s<e){
            cout <<s <<" " << e << "\n";
            s++;
            e--;
        }
        s = m+2 , e = 2*m + 1;
        while(s<e){
            cout << s << " " << e << "\n";
            s++;
            e--;
        }
    }
    
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search  
#define le length()
const ll max_i=1e8;
#define np(s) next_permutation(s.begin(),s.end())
//it gives the lexicographically next string

int main()
{
   ll m,n,sum=0;
   cin>>m>>n;
   for(int i=0;i<n;i++)
   {
    ll x;
    cin>>x;
    sum+=x;
   }
   if(sum>m) cout<<-1;
   else cout<<m-sum;
    return 0;
}


Measured memory_bytes: 3600
/*
 * @author      : omgursocute
 * @file        : 130/B.cpp
 * @created     : 29/12/2019
 */

#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n, x;
	cin >> n >> x;
	int d[n+1] = {0};

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

	int res = 0;
	for(int i = 0; i <= n; i++)
		if(d[i] <= x) res++;

	cout << res;
	
	return 0;
}



Measured memory_bytes: 256
<?php

$stdin = preg_split('/ /', trim(fgets(STDIN)));
$w = $stdin[0];
$h = $stdin[1];
$x = $stdin[2];
$y = $stdin[3];
$r = $stdin[4];

if (0 <= ($x - $r) && ($x + $r) <= $w) {
	if (0 <= ($y - $r) && ($y + $r) <= $h) {
		print("Yes\n");
	} else {
		print("No\n");
	}
} else {
	print("No\n");
}

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

using namespace std;

#define LL long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,x) for(reg int i=Head[x]; i; i=Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N=2e5+5,M=1e5+5,mod=998244353;

bool MOP1;

inline void Add(LL &x,int y) {
	x+=y;
	if(x<0)x+=mod;
	if(x>=mod)x-=mod;
}

struct point {
	int x,y;
} S[N];

inline bool cmp(point _,point __){
	return _.y<__.y;
}

int X[N];

struct BIT {
	int c[N];
	inline void clear(void) {
		memset(c,0,sizeof c);
	}
	inline void Add(int x) {
		for(; x<N; x+=x&-x)c[x]++;
	}
	inline int Sum(int x) {
		int res=0;
		for(; x; x^=x&-x)res+=c[x];
		return res;
	}
} tr;

int F2[N];

bool MOP2;

inline void _main(void) {
	int n =Read();
	F2[0]=1;
	rep(i,1,n)F2[i]=(1ll*F2[i-1]<<1)%mod;
	rep(i,1,n) S[i].x=X[i]=Read(),S[i].y=Read();
	sort(X+1,X+n+1);
	rep(i,1,n)S[i].x=lower_bound(X+1,X+n+1,S[i].x)-X;
	LL Ans=1ll*n*(F2[n]-1)%mod;
	rep(i,1,n) {
		Add(Ans,-(F2[i]-2));
		Add(Ans,-(F2[n-i+1]-2));
	}
	sort(S+1,S+n+1,cmp);
	rep(i,1,n) {
		Add(Ans,(F2[tr.Sum(S[i].x)]-1));
		Add(Ans,(F2[i-1-tr.Sum(S[i].x)]-1));
		tr.Add(S[i].x);
	}
	tr.clear();
	drep(i,n,1) {
		Add(Ans,(F2[tr.Sum(S[i].x)]-1));
		Add(Ans,(F2[n-i-tr.Sum(S[i].x)]-1));
		tr.Add(S[i].x);
	}
	printf("%lld\n",Ans);
}

signed main() {
#define offline1
#ifdef offline
	freopen("chessboard.in", "r", stdin);
	freopen("chessboard.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')w = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, l) for (int i = r; i >= l; --i)
#define all(x) (x).begin(), (x).end()
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))
#define mod1(x) ((x >= mod) && (x -= mod))
#define mod2(x) ((x < 0) && (x += mod))

const int inf = 1e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);
ll power(ll a, ll b) { ll res = 1; while (b) { if (b & 1)res = res * a % mod; a = a * a % mod; b >>= 1; }return res; }
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
void add(ll& a, ll b) { a += b; mod1(a); mod2(a); }
/*int len, C[N], clen;
int id(int v) {return lower_bound(C + 1, C + len, v) - C;}
void initC() { sort(C + 1, C +1+ clen); len = unique(C + 1, C + 1 + clen) - C - 1; }*/

int l[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef local
    freopen("in.txt", "r", stdin);
    int start = clock();
#endif
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    ll t = x / d;
    if (k <= t) {
        cout << x - k * d;
    }
    else {
        if ((k - t) & 1) {
            cout << abs(x - (t + 1) * d);
        }
        else {
            cout << abs(x - t * d);
        }
    }

#ifdef local
    int end = clock();
    cout << '\n' << end - start << "ms";
#endif* /
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1) a += 13;
  if(b == 1) b += 13;

  if(a > b)
    cout << "Alice";
  else if (a < b)
    cout << "Bob";
  else
    cout << "Draw";
  cout << endl;
}


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

int main(){
  int n;
  cin >> n;
  ll ans=1;
  for(int i=0;i<n;i++){
    ans*=10;
    ans%=1000000007;
  }
  ll a=1,b=1;
  for(int i=0;i<n;i++){
    a*=8;
    a%=1000000007;
  }
  for(int i=0;i<n;i++){
    b*=9;
    b%=1000000007;
  }
  ans=(ans-2*b+a)%1000000007;
  while(ans<0) ans+=1000000007;
  cout << ans << endl;
}

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

class Program {
    static void Main (string[] args) {
          

        int n = int.Parse(Console.ReadLine ());
        string[] p = Console.ReadLine ().Split(' ');

        int ans = 0;
        for(int i=1;i<n -1 ;i++){
            int bef = int.Parse(p[i-1]);
            int cur = int.Parse(p[i]);
            int aft = int.Parse(p[i+1]);
            if(bef < cur && cur < aft || aft < cur && cur < bef) ans++;
        }
        Console.WriteLine(ans);
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m;
	cin >> n >> m;
	vpll v(m);
	rep(i,m) cin >> v[i].first >> v[i].second;
	sort(all(v));
	//cout << v << endl;
	rep(i,m-1){
		if(v[i].first==v[i+1].first&&v[i].second!=v[i+1].second){
			cout << -1 << endl;
			return 0;
		}
	}
	Eunique(v);
	vll a(10,-1);
	rep(i,SIZE(v)) a[v[i].first]=v[i].second;
	//cout << v << endl;
	//cout << a << endl;
	string s="";
	rep(i,n){
		if(a[i+1]!=-1) s+=to_string(a[i+1]);
		else{
			if(i==0&&n!=1) s+="1";
			else s+='0';
		}
	}
	if(SIZE(s)>1&&s[0]=='0') cout << -1 << endl;
	else cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

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

    cout << endl;
    return 0;
}

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

const int N = 2e5 + 5;
int n,m,k;

using ll = long long;
const int mod = 1e9 + 7;
int fac[N], finv[N];

ll quick_pow(ll a, ll b) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void init_fac_mod(int nima){
    //only when mod is prime
    fac[0] = finv[0] = 1;
    for(int i = 1; i <= nima; ++i)
        fac[i]=(ll)fac[i-1]*i%mod;
    finv[nima] = quick_pow(fac[nima], mod-2);
    for(int i = nima-1; i; --i)
        finv[i] = (ll)finv[i+1]*(i+1)%mod;
}

int c(int n, int m){
    //n!/(m!(n-m)!)
    return (ll)fac[n] * finv[m] % mod * finv[n - m]% mod;
}

int c_2(int n, int m){
    ll res = 1;
    for (int i = 0; i < m; i++){
        (res *= n-i)%= mod;
        (res/= i+1)%= mod;
    }
    return res;
}



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m>>k;
    
    
    ll d = 0;
    for (int i = 1; i < n; i++){
        d += (ll)i*(n-i)%mod*m%mod*m%mod;
        d%= mod;
    }
    
    for (int i = 1; i < m; i++){
        d += (ll)i*(m-i)%mod*n%mod*n%mod;
        d %= mod;
    }
    
    init_fac_mod(n*m-2);
    cout<<d*c(n*m-2, k-2)%mod<<endl;
    
    
    
    
    
    return 0;
}



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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N;
    cin >> N;
    int H[N];
    rep(i, N) cin >> H[i];
    int ans = 0;
    int cnt = 0;
    rep(i, N-1){
        if(H[i] >= H[i+1]){
            cnt++;
        }
        else{
            if(cnt > ans) ans = cnt;
            cnt = 0;
        }
    }
    if(cnt > ans) ans = cnt;
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 998244353;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

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

    vector<ll> a(n);

    ll sum = 0;

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

    static vector<vector<ll>> dp1(n+1,vector<ll>(sum+1,0));
    static vector<vector<ll>> dp2(n+1,vector<ll>(sum*2 + 1,0));
    ll zero = sum;

    dp1[0][0] = 1;
    dp2[0][zero] = 1;

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= sum; j++){
            dp1[i+1][j] = (dp1[i][j]*2)%MOD;
        }
        for(int j = 0; j <= sum; j++){
            if(a[i] + j <= sum){
                dp1[i+1][j+a[i]] += dp1[i][j];
                dp1[i+1][j+a[i]] %= MOD;
            }
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= sum*2; j++){
            if(j - a[i] >= 0){
                dp2[i+1][j - a[i]] += dp2[i][j];
                dp2[i+1][j-a[i]] %= MOD;
            }
            if(j + a[i] <= sum*2){
                dp2[i+1][j+a[i]] += dp2[i][j];
                dp2[i+1][j+a[i]] %= MOD;
            }
        }
    }

    ll ans = mypow(3,n);

    for(int i = (sum+1)/2; i <= sum; i++){
        ans += ((MOD - dp1[n][i])*3)%MOD;
        ans %= MOD;
    }

    if(sum%2 == 0){
        ans += 3*dp2[n][zero];
    }

    cout << ans%MOD << endl;


    return 0;
}

Measured memory_bytes: 636224
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
    unsigned long long i=0, N=S.length();
    reverse(S.begin(), S.end());
    while(i<N){
        if(i+5<=N && S.compare(i,5,"maerd")==0)i+=5;
        else if(i+5<=N && S.compare(i, 5, "esare")==0)i+=5;
        else if(i+6<=N && S.compare(i, 6, "resare")==0)i+=6;
        else if(i+7<=N && S.compare(i, 7, "remaerd")==0)i+=7;
        else break;
    }
    if(i==N)cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
    int n,A[200000];
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    sort(A,A+n);
    int ans=0;
    for(int i=0;i<n-1;i++) ans+=A[i];
    ans-=A[n-1];
    if(ans>0) cout<<" Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main(){
    string s,t;
    cin>>s>>t;
    int ss=s.size();
    int ts=t.size();
    vvin dp(ss+1,vin(ts+1));
    rep(i,ss+1)dp[i][0]=i;
    rep(i,ts+1)dp[0][i]=i;
    rep(i,ss){
        rep(j,ts){
            if(s[i]==t[j])dp[i+1][j+1]=dp[i][j];
            else dp[i+1][j+1]=min(dp[i][j]+1,min(dp[i+1][j]+1,dp[i][j+1]+1));
        }
    }
    cout<<dp[ss][ts]<<endl;
}


Measured memory_bytes: 6888
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug =false;
            string[] inpt = Reader.ReadLine().Split(' ').ToArray();

            bool IsShiritori = true;
            for(int i=1; i<inpt.Length; i++) {
                if(inpt[i-1].Last() != inpt[i][0]) {
                    IsShiritori =false;
                    break;
                }
            }

            Console.WriteLine(IsShiritori?"YES":"NO");


        }

        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"




aaaaaaaaab aaaaaaaaaa aaaaaaaaab





";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e15;
const int N_MAX=1e5;

int N;
using edge=pair<int,int>;
using Graph=vector<edge>;
Graph G[N_MAX];
vector<int>A(N_MAX,0);

void dfs(int i,int x){
    //iは親、xは根
    for(auto v:G[x]){
        if(v.first!=i){
          	if(v.second%2==0)A[v.first]=A[x];
            if(v.second%2==1)A[v.first]=A[x]+1;
            dfs(x,v.first);
        }
    }
}

signed main(){
    cin>>N;
    REP(i,N-1){
        int a,b,c;cin>>a>>b>>c;a--;b--;
        G[a].eb(b,c);
        G[b].eb(a,c);
    }
    dfs(-1,0);
    REP(i,N)cout<<A[i]%2<<endl;
}

Measured memory_bytes: 10240
from collections import defaultdict


def solve(li):
    cnt = defaultdict(int)
    cnt[0] = 1
    rem = 0
    ans = 0
    for k, i in enumerate(li):
        rem = (rem + i * pow(10, k, 2019)) % 2019
        ans += cnt[rem]
        cnt[rem] += 1
    return ans


print(solve(map(int, input()[::-1])))


Measured memory_bytes: 9736
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define pii pair <int,int>
using namespace std;

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

    int T[t];

    for(int i=0;i<t;i++)cin >> T[i];

    int m; cin >> m;

    vector < pii > v;

    while(m--){
        int a,b; cin >> a >> b;
        v.pb(make_pair(a,b));
    }

    for(pii x : v){
        int i = x.first, j = x.second;

        int time = 0;

        for(int q=1;q<=t;q++){
            if(q == i)time += j;
            else time += T[q-1];
        }

        cout << time << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, a[200000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n ;
    ll sum=0;
    ll sumsub[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        sumsub[i]=sum;
    }
    ll ans=INF;
    for(int i=0;i<n-1;i++){
        ans=min(ans,abs(2*sumsub[i]-sum));
    }
    cout<<ans<<"\n";
    /* sort(a,a+n);
    ll suma=a[n-1];
    ll sumb=0;
    for(int i=n-2;i>=0;i--){
        if(suma>=sumb){
            sumb+=a[i];
        }
        else{
            suma+=a[i];
        }
    }
    cout << abs(suma-sumb)<< "\n";
    */
}

Measured memory_bytes: 2560
/*
@ author:pyyyyyy/guhl37
-----思路------

-----debug-------

*/
#include<bits/stdc++.h>
using namespace std;
char s[5];
int n,ac,wa,tle,re;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ac=wa=tle=re=0;
	cin>>n;
	while(n--)
	{
		scanf("%s",s);
		if(s[0]=='A') ac++;
		if(s[0]=='T') tle++;
		if(s[0]=='W') wa++;
		if(s[0]=='R') re++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);
	return 0;
}



Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < n - 3 + 1; i ++) {
    if (s.substr(i, 3) == "ABC") ans ++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let X: i64 = read();
    let mut now: f64 = 100.0;
    let mut ans = 0;
    while now < X as f64 {
        ans += 1;
        now = (now * 1.01).floor();
    }
    println!("{}", ans);
}


Measured memory_bytes: 2660
#include <iostream>
#include <cstdlib>
#include <climits>

/*
 * http://ttrsq.exblog.jp/24318687/
 */

const int MAX_N = 100;
int DP[MAX_N + 1][MAX_N + 1] = {0};
int *p;

int best(int r, int c) {
  int min = INT_MAX;
  int num = c - r;

  for (int i = 0; i < num; i++) {
    min = std::min(min, DP[r][r + i] + DP[r + i + 1][c] + p[r - 1] * p[r + i] * p[c]);
  }
  
  return min;
}

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

  int n = 0;
  std::cin >> n;
  
  p = (int *) std::malloc(sizeof(int) * n + 1);

  int bb = 0;

  std::cin >> p[0];
  std::cin >> p[1];
  
  for (int i = 2; i <= n; i++) {
    std::cin >> bb;
    std::cin >> p[i];
  }

  if (n == 1) {
    std::cout << "0" << std::endl;

    return 0;
  }  

  for (int i = 1; i < n; i++) {
    DP[i][i + 1] = p[i - 1] * p[i] * p[i + 1];
  }

  for (int j = 0; j <= n - 3; j++) {
    for (int i = j + 3; i <= n; i++) {
      DP[i - 2 - j][i] = best(i - 2 - j, i);
    }
  }

  std::cout << DP[1][n] << std::endl;

  return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  int64_t result = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      result += i;
    }
  }
  cout << result << endl;
  return 0;
}

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

class Abc158c
{
    static int a, b;

    static void Solve()
    {
        var xa_min = ((a * 100) % 8) == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        var xa_max = (((a + 1) * 100) % 8) == 0 ? (a + 1) * 100 / 8 : (a + 1) * 100 / 8 + 1;
        var xb_min = b * 10;
        var xb_max = (b + 1) * 10;

        var answer = -1;
        for(var i = xa_min; i < xa_max; ++i) {
            if(xb_min <= i && i < xb_max) {
                answer = i;
                break;
            }
        }

        Console.WriteLine(answer);
    }

    static void Scan()
    {
        var buf = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);
        a = buf.ElementAt(0);
        b = buf.ElementAt(1);
    }

    static void Main()
    {
        Scan();
        Solve();
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int gcp(int x,int y){
	int tmp;
	if(x<y){
		tmp = x;
		x=y;
		y=tmp;
	}
	return x%y;
}
int 
main(){
	int x,y;	
	scanf("%d%d",&x,&y);
	
	int z = gcp(x,y);
	int ans;
	while(z!=0){
		x = y;
		y = z;
		z = gcp(x,y);
	}
	printf("%d\n",y);
 return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

int main(){
      ll n;
      cin>>n;
      ll a[n];
      rep0(i,n) cin>>a[i];
      ll m=0;
      ll pos=longinf;
      rep0(i,n){
            if(a[i]<0) m++;
      }
      ll ans=0;
      rep0(i,n){
            ans+=abs(a[i]);
            if(abs(a[i])<pos) pos=abs(a[i]);
      }
      if(m%2==1){
            cout<<ans-2*pos<<endl;
      }
      else{
            cout<<ans<<endl;
      }
      return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+5;
const int MAX2=2e5+4;
const int MAAX=1e10;
const int MOD=1e9+7;
in main()
{
   int n;
   cin>>n;
   int ans=n/500*1000;
   n-=ans/1000*500;
   ans+=n/5*5;
   cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 256