akhauriyash/Code-Regression huggingface dataset:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = float('inf')
    I = int(math.sqrt(N)) * 10
    for i in range(1, I):
        if N%i == 0:
            j = N//i
            ret = min(ret, j + i - 2)

    print(ret)


if __name__ == '__main__':
    main()


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

void dispStone(int stone[][5]){
	for(int i=9;i>=0;i--){
		for(int j=0;j<5;j++){
			cout<<stone[i][j];
		}
		cout<<endl;
	}
	cout<<endl;
}

bool isStoneDrop(int stone[][5]){
	for(int i=0;i<5;i++){
		bool flg=true;
		for(int j=0;j<10;j++){
			if(stone[j][i]==0) flg=false;
			else if(flg==false && stone[j][i]!=0) return true;
		}
	}
	return false; //これ以上落ちない
}
void drop(int stone[][5]){
	while(isStoneDrop(stone)){
		for(int i=0;i<9;i++){
			for(int j=0;j<5;j++){
				if(stone[i][j]==0 && stone[i+1][j]!=0){
					stone[i][j]=stone[i+1][j];
					stone[i+1][j]=0;
				}
			}
		}
	}
}
bool isStone(int *stone_line){
	for(int i=0;i<5;i++){
		if(stone_line[i]!=0){
			return true;
		}
	}
	return false;
}
int checkLine(int *stone_line){
	int point=0;
	int chain=0;
	for(int i=0;i<4;i++){
		if(chain>1 && stone_line[i]!=stone_line[i+1]){
			for(;chain>=0;chain--){
				point+=stone_line[i-chain];
				stone_line[i-chain]=0;
			}
			return point;
		}else if(stone_line[i]==stone_line[i+1]){
			chain++;
		}else{
			chain=0;
		}
	}
	if(chain>1){
		for(chain;chain>=0;chain--){
			point+=stone_line[4-chain];
			stone_line[4-chain]=0;
		}	
			return point;
	}else{
		return 0;
	}
}
int erase(int stone[][5]){
	int point=0,i=0;
	while(isStone(stone[i])){
		point+=checkLine(stone[i]);
		i++;
	}
	return point;
}


int main(){
	int h;
	cin>>h;
	while(h!=0){
		int point=0;
		int stone[10][5]={};
		for(int i=0;i<h;i++){
			for(int j=0;j<5;j++){
				cin>>stone[h-i-1][j];
			}
		}
		while(1){
			if(int p=erase(stone)){
				point+=p;
//dispStone(stone);
			}else{
				break;
			}
			drop(stone);
//dispStone(stone);
		}
		cout<<point<<endl;
		cin>>h;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
void Main(){
    int N;cin>>N;
    vector<int> oya(N,-1);
    vector<vector<int>> ko(N);
    For(i,1,N){
        cin>>oya[i];oya[i]--;
        ko[oya[i]].push_back(i);
    }
    queue<int> que;
    vector<int> cnt(N,0),depth(N,0);
    For(i,0,N){
        if(ko[i].size()==0){
            que.push(i);
        }
    }
    while(true){
        int i=que.front();
        que.pop();
        vector<int> idepth;
        For(j,0,ko[i].size()){
            idepth.push_back(depth[ko[i][j]]);
        }
        sort(ALL(idepth));reverse(ALL(idepth));
        For(j,0,ko[i].size()){
            depth[i]=max(depth[i],idepth[j]+j+1);
        }
        /*cout<<"i= "<<i+1<<endl;
        For(t,0,N) cout<<depth[t]<<" ";
        cout<<endl;*/
        if(i==0) break;
        cnt[oya[i]]++;
        if(cnt[oya[i]]==ko[oya[i]].size()){
            que.push(oya[i]);
        }
    }
    cout<<depth[0]<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 6912
n = int(input())
s = [input() for i in range(n)]

march = [0]*5

for i in range(n):
    if s[i][0]=="M":
        march[0]+= 1
    elif s[i][0]=="A":
        march[1]+=1
    elif s[i][0]=="R":
        march[2]+=1
    elif s[i][0]=="C":
        march[3]+=1
    elif s[i][0]=="H":
        march[4]+=1

ans1 = march[0]*march[1]*(march[2]+march[3]+march[4])
ans2 = march[3]*march[4]*(march[0]+march[1]+march[2])
ans3 = (march[0]+march[1])*march[2]*(march[3]+march[4])

print(ans1+ans2+ans3)

Measured memory_bytes: 9772
n = int(input())

a = input().split()

for i in range(0, n):
    a[i] = int(a[i])

MIN = min(a[0], a[1])
MAX = max(a[0], a[1])

for i in range(2, n):
    c = a[i]
    MAX = max(MAX, c)
    MIN = min(MIN, c)

print(MAX-MIN)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
        int lcnt[4], rcnt[4], i;
        for(i=0; i<4; i++) lcnt[i] =  rcnt[i] = 0;

        double l, r;
        while(scanf("%lf %lf", &l, &r)==2){
                lcnt[(l<1.1)+(l<0.6)+(l<0.2)]++;
                rcnt[(r<1.1)+(r<0.6)+(r<0.2)]++;
        }

        for(i=0; i<4; i++) printf("%d %d\n", lcnt[i], rcnt[i]);
        return 0;
}


Measured memory_bytes: 1992
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
typedef long long ll;
const double PI = acos(-1);
using namespace std;

V<int> seen;
V<int> sen; //検知済みか

int dfs(const VVI &G,int v){
    for(auto next_v:G[v]){
        if(seen[next_v]!=-1)continue;
        seen[next_v]=seen[v]+1;
        dfs(G,next_v);
    }
}

int sch(const VVI &G,int v){
    for(auto next_v:G[v]){
        if(sen[next_v]!=-1)continue;
        sen[next_v]=sen[v]+1;
        sch(G,next_v);
    }
}

int main(void){
    ll N;
    cin>>N;
    if(N%2){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    for(ll i=10;i<=N;i*=5){
        ans+=N/i;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			int max=-1;
			int ind=-1;
			for(int i=0;i<n;i++)
			{
				int id=in.nextInt();
				int cnt=in.nextInt();
				if(cnt>=max)
				{
					if(cnt==max)
					{
						if(id<ind)
						{
							ind=id;
							max=cnt;
						}
					}
					else
					{
						ind=id;
						max=cnt;
					}
				}
			}
			System.out.println(ind+" "+max);
		}
	}

	static public void debug(Object... o)
	{
		System.err.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 17316
//http://agc005.contest.atcoder.jp/tasks/agc005_a
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <queue>
#include <stack>
#include <tuple>

using namespace std;

int main()
{
	string X;
	cin >> X;
	int S = 0;
	int ans = 0;
	for (const auto& c : X) {
		if (c == 'S') {
			S++;
		} else {
			if (S > 0)
				S--;
			else
				ans++;
		}
	}
	ans += S;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#define MAX 200000+10

int n, a[MAX];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i);
	int i = n;
	for (; i > 0; i-=2)
		printf("%d ", a[i]);
	i = (i == -1) ? 2 : 1;
	for (; i < n; i+=2)
		printf("%d ", a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1000000000;
const int maxN = 100010;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int c = a+b;
	if(a%3 == 0 || b%3==0 || c%3==0)
	{
		printf("Possible\n");
	}
	else
		printf("Impossible\n");
	return 0;
}

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

int main() {

    int n;
    cin >> n;
    vector<int> s(n);

    for(int i = 0; i < n; ++i) {
        int num;
        cin >> num;
        s[num - 1] = i + 1;

    }

    for(int i = 0; i < n; ++i) {
        if(i)
            cout << " ";
        cout << s[i];
    }

    cout << endl;

    return 0;

}

Measured memory_bytes: 1152
#![allow(non_snake_case, unused)]
use std::collections::*;
use std::cmp::{min, max};

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! debug {
	($($v: expr),*) => {
		$(eprint!("{} = {:?} ", stringify!($v), $v);)*
		eprintln!("@ {}:{}", file!(), line!());
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:ty),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let N = read!(usize);
	let ss = read!([u8]; 3);
	let mut ans = 0;
	for i in 0..N {
		if ss[0][i] != ss[1][i] || ss[0][i] != ss[2][i] {
			if ss[0][i] != ss[1][i] && ss[0][i] != ss[2][i] && ss[1][i] != ss[2][i] {
				ans += 2;
			} else {
				ans += 1;
			}
		}
	}
	println!("{}", ans);
}


Measured memory_bytes: 8572
(n,k)=gets.split.map(&:to_i)
s=gets.chars


lr= s.each_cons(2).select{|ss| ss==["L","R"] }.size
rl= s.each_cons(2).select{|ss| ss==["R","L"] }.size
h0=s.each_cons(2).select{|a,b| a==b }.size

p h0+[lr,k].min + [rl,k].min

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    ll n, k; cin >> n >> k;

    n %= k;
    ll ans = abs(n - k);
    if(ans < n){
        OP(ans);
    }else{
        OP(n);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
const long long mod = 998244353;
//Range_Minimum_Query
//(0-indexed)
const int max_n = 300000;
const long long int_max = 1e9+7;
int nn;
long long dat[2 * max_n - 1];
void rmq_init(int initn){
    nn = 1;
    while(nn < initn) nn *= 2;
    for(int i = 0; i < 2 * nn - 1; i++) dat[i] = int_max;
}
//k番目の値(0-indexed)をaに変更
void update(int k, long long a){
    k += nn-1;
    dat[k] = a;
    while(k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

//[a,b)の最小値を求める
//query(a, b, 0, 0, n)で呼ぶ
long long query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return int_max;
    if(a <= l && r <= b) return dat[k];
    else{
        long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}

int main() {
    // your code goes here
    ll n,x,d,dp[200005]={0},sw[200005]={0},swm[200005]={0},pb=n-1;
    vector<pair<ll,ll>> v;
    vector<ll> zh;
    cin >> n;
    rmq_init(n);
    rep(i,0,n-1){
        cin >> x >> d;
        v.push_back({x,d});
        zh.push_back(x);
    }
    sort(v.begin(),v.end());
    sort(zh.begin(),zh.end());
    rep(i,0,n-1){
        auto it=lower_bound(zh.begin(),zh.end(),v[i].first+v[i].second);
        it--;
        sw[i]=it-zh.begin();
        update(i,-sw[i]);
    }
    swm[n-1]=n-1;
    repr(i,n-2,0){
        swm[i]=-query(i,sw[i]+1,0,0,nn);
        update(i,-swm[i]);
    }
    dp[n]=1;
    dp[n-1]=2;
    repr(i,n-2,0){
        dp[i]=(dp[i+1]+dp[swm[i]+1])%mod;
    }
    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 16880
using System;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		var xs = ps.Select(p => p[0]).ToArray();
		var xy = ps.Select(p => p[1]).ToArray();
		Array.Sort(xs, xy);
		for (int i = 0; i < n; i++)
			xs[i] = i;
		Array.Sort(xy, xs);
		var yx = new int[n];
		Array.Copy(xs, yx, n);
		for (int i = 0; i < n; i++)
			xy[i] = i;
		Array.Sort(xs, xy);

		int ss = 64, sc = n / ss + 1;
		var s = new int[sc, sc];
		for (int i = 0; i < n; i++)
			s[i / ss, xy[i] / ss]++;
		for (int i = 0; i < sc; i++)
			for (int j = 1; j < sc; j++)
				s[i, j] += s[i, j - 1];
		for (int j = 0; j < sc; j++)
			for (int i = 1; i < sc; i++)
				s[i, j] += s[i - 1, j];

		var c = MInt(n * MPow(2, n) - n);
		for (int i = 0; i < n; i++)
		{
			var v = xy[i];

			var li = i >= ss && v >= ss ? s[i / ss - 1, v / ss - 1] : 0;
			var ix = i - i % ss;
			for (int i2 = ix; i2 < i; i2++)
				if (xy[i2] < v) li++;
			for (int j2 = v - v % ss; j2 < v; j2++)
				if (yx[j2] < ix) li++;

			c -= MPow(2, i) + MPow(2, n - 1 - i) + MPow(2, v) + MPow(2, n - 1 - v);
			c += MPow(2, li) + MPow(2, i - li) + MPow(2, v - li) + MPow(2, n - 1 + li - i - v);
			c = MInt(c);
		}
		Console.WriteLine(c);
	}

	const int M = 998244353;
	static long MPow(long b, long i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
	static long MInt(long x) => (x %= M) < 0 ? x + M : x;
}


Measured memory_bytes: 72076
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"4
hoge
english
hoge
enigma"# => r#"No"#,

r#"9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly"# => r#"Yes"#,

r#"8
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaa
aaaaaaa"# => r#"No"#,
}

fn solve(src: &str) -> String {

    input! {
        source = src,
        n: usize,
        w: [chars; n],
    }

    let mut ans = "Yes";
    let mut map = std::collections::HashMap::new();
    for i in 0..n {
        let count = map.entry(w[i].clone()).or_insert(0);
        *count += 1;
        if *count > 1 || (i > 0 && w[i - 1].last().unwrap() != w[i].first().unwrap()) {
            ans = "No";
            break;
        }
    }

    // println!("{:?}", map);
    ans.to_string()
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void) {

	int N;
	long long sum = 0;
	cin >> N;

	rep(i,N) {
		if ((i+1) % 3 == 0 || (i+1) % 5 == 0);
		else {
			sum += (i+1);
		}
	}
	cout << sum << endl;

	return 0;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int a[200000], dist[200000];

int main()
{
  int k, n, result = 0;
  cin >> k >> n;

  REP(i, n)
  {
    cin >> a[i];
  }
  dist[0] = k - a[n - 1] + a[0];
  FOR(i, 1, n)
  {
    dist[i] = a[i] - a[i - 1];
  }
  sort(dist, dist + n);
  result = k-dist[n-1];

  cout << result << endl;
}

Measured memory_bytes: 5156
#include <iostream>

typedef long long ll;

const int MAX_NDIGIT = 16;

int main(){
   ll N;
   std::cin >> N;

   ll M = N;
   int ndigit = 1;
   int maxdigit = M%10;
   bool nine = true;
   if(M%10!=9) nine = false;
   for(int i=0; i<MAX_NDIGIT; ++i){
      M /= 10;
      if(M>0) ++ndigit;
      else break;
      maxdigit = M%10;
      if(M>9 && M%10!=9) nine = false;
   }

   if(maxdigit<9){
      int sum = 9 * (ndigit-1);
      if(ndigit>1){
	 if(nine) sum += maxdigit;
	 else sum += maxdigit - 1;
      }else sum += maxdigit;
      std::cout << sum << std::endl;
      return 0;
   }else{
      int digit[ndigit];
      int index = -1;
      while(true){
	 M = 0;
	 for(int i=0; i<ndigit; ++i){
	    if(i==index) digit[i] = 8;
	    else digit[i] = 9;
	 }
	 ll tenth = 1;
	 for(int i=0; i<ndigit; ++i){
	    M += digit[i]*tenth;
	    tenth *= 10;
	 }
	 if(N>=M){
	    int sum = 0;
	    for(int i=0; i<ndigit; ++i)
	       sum += digit[i];
	    std::cout << sum << std::endl;
	    return 0;
	 }
	 ++index;
      }
   }

   return -1;
}


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

int main() {
  int N;
  cin >> N;
    
  vector<int>vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  int A = N;
  
  for(int j = 0; j < N - 1; j++) {
    if(vec.at(j) == vec.at(j + 1)) {
      A--;
    }
    
    else {
      continue;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
inline void write(int x)
{
    if(x<0){
    	putchar('-');
		x=-x;
	}
    if(x>9) 
		write(x/10);
    putchar(x%10+'0');
}
int n;
int a[1000001];
int main(){
	n=read();
	
	for(int i=1;i<=n;++i)a[i]=read();
    for(int i=n;i>0;i-=2)printf("%d ",a[i]);
    for(int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2944
# https://atcoder.jp/contests/abc049/tasks/arc065_a

CANDS = %w(dream dreamer erase eraser)

s = gets.chomp

valid = true
while s.size > 0
  seven = s[-7..-1]
  six = s[-6..-1]
  five = s[-5..-1]
  # p [seven, six, five]
  if CANDS.include?(seven) && seven.size == 7
    s = s[0..-8]
  elsif
    CANDS.include?(six) && six.size == 6
    s = s[0..-7]
  elsif CANDS.include?(five)
    s = s[0..-6]
  else
    valid = false
    break
  end
  # p s
end
puts valid ? 'YES' : 'NO'


Measured memory_bytes: 71804
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#define modulus 1000000007
using namespace std;

int n, m, x;
vector<vector<int>> brr(13, vector<int>(13));
vector<int> costs(13);

void subsetsUtil(vector<int>& A, vector<vector<int> >& res, 
                 vector<int>& subset, int index){ 
    res.push_back(subset); 
    for (int i = index; i < A.size(); i++) {
        subset.push_back(A[i]);
        subsetsUtil(A, res, subset, i + 1);
        subset.pop_back(); 
    }
    return; 
} 

vector<vector<int> > subsets(vector<int>& A){
    vector<int> subset; 
    vector<vector<int> > res;
    int index = 0; 
    subsetsUtil(A, res, subset, index);
    return res; 
}

bool check(vector<int> arr){
    for(int i = 0; i < m; i++){
        long long curr = 0;
        for(int j = 0; j < arr.size(); j++){
            curr += brr[arr[j]][i];
        }
        if(curr < x) return false;
    }
    return true;
}

int main(){
    vector<int> arr(12);
    for(int i = 0; i < 12; i++) arr[i] = i;
    vector<vector<int>> subs = subsets(arr);
    cin >> n >> m >> x;
    for(int i = 0; i < n; i++){
        cin >> costs[i];
        for(int j = 0; j < m; j++) cin >> brr[i][j];
    }
    long long mini = -1;
    bool ok = false;
    for(int i = 0; i < subs.size(); i++){
        if(subs[i].size() == 0) continue;
        bool okc = check(subs[i]);
        if(okc){
            long long curr = 0;
            for(int j = 0; j < subs[i].size(); j++){
                curr += costs[subs[i][j]];
            }
            if(!ok){
                mini = curr;
                ok = true;
            }
            else{
                if(curr < mini) mini = curr;
            }
        }
    }
    cout << mini << endl;
}

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

int N,M,L,R;
int main(void){
  cin>>N>>M;
  L=1; R=N;
  for(int i=0;i<M;i++){
    int l,r;
    cin>>l>>r;
    if(r<R) R=r;
    if(l>L) L=l;
  }
  if(R-L+1<0) cout<<0<<endl;
  else        cout<<R-L+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class topological_sort {
private:
	int V;
	vector<vector<int>> edges;
	vector<int> used;
public:
	topological_sort(int n) :V(n), edges(n), used(n) {}
	topological_sort(vector<vector<int>> &edges) :V(edges.size()), used(edges.size()) { this->edges = edges; }

	void add_edge(int from, int to) { edges[from].emplace_back(to); }

	vector<int> build() {

		vector<int> res, in(V);
		for (int i = 0; i < V; i++) for (const auto &e : edges[i]) in[e]++;

		res.reserve(V);
		queue<int> que;
		for (int i = 0; i < V; i++) {
			if (in[i] == 0 && !used[i]) {
				used[i] = 1;
				que.emplace(i);
			}
		}
		while (!que.empty()) {
			int now = que.front();
			DMP(now, in);
			que.pop();
			res.emplace_back(now);
			for (const auto &e : edges[now]) {
				in[e]--;
				if (in[e] == 0) {
					if (used[e]) return vector<int>(); // unable to sort
					used[e] = used[now] + 1;
					que.emplace(e);
				}
			}
		}

		return res;
	}

	int longest_path() {
		if (none_of(used.begin(), used.end(), [](int u) { return u > 0; })) build();
		return *max_element(used.begin(), used.end());
	}

};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	topological_sort ts(N);
	for (int i = 0; i < M; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		ts.add_edge(s, t);
	}

	cout << ts.longest_path() - 1 << "\n";

	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
	cin >> n;
	FOR(b,1,3501){
		FOR(c,1,3501){
			if(4*b*c-n*c-n*b <= 0)continue;
			if((n*b*c)%(4*b*c-n*c-n*b) == 0){
				cout << b << " " << c << " " << (n*b*c)/(4*b*c-n*c-n*b) << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    LR = [
        list(map(int, input().split()))
        for _ in range(M)
    ]

    ans = f(N, M, LR)
    ans1 = cumsum(N, M, LR)
    assert ans == ans1
    # ans = WA(N, M, LR)
    # ans = TLE(N, M, LR)
    print(ans)


def cumsum(N, M, LR):
    a = [0] * (N + 1)
    for L, R in LR:
        a[L-1] += 1
        a[R] -= 1

    from itertools import accumulate
    a = accumulate(a)
    ans = sum(x == M for x in a)
    return ans


def WA(N, M, LR):
    import numpy as np
    a = np.zeros(N, dtype=int)
    for L, R in LR:
        a[L-1:R] += 1
    ans = (a == M).sum()
    return ans


def f(N, M, LR):
    l_max = max(L for L, _ in LR)
    r_min = min(R for _, R in LR)

    ans = r_min - l_max + 1
    ans = max(ans, 0)
    return ans


def TLE(N, M, LR):
    ans = 0
    for i in range(1, N+1):
        g = 0
        for L, R in LR:
            if L <= i <= R:
                g += 1
        if g == M:
            ans += 1

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 28336
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

using namespace std;

int main(){
	cin.sync_with_stdio(0);

	string s; cin >> s;
	
	FOR(i, 0, sz(s)) {
		char c = s[i];
	
		if(i % 2 == 1) {
			if(c != 'L' && c != 'U' && c != 'D') {
				cout << "No" << endl;
				return 0;
			}
		} else {
			if(c != 'R' && c != 'U' && c != 'D') {
				cout << "No" << endl;
				return 0;
			}
		}
	
	}
	
	cout << "Yes" << endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  while (true) {
    int n;
    cin >> n;
    if(n == 0) break;
    int cnt = 0;
    FOR(i, 1, n) {
      int sum = 0;
      FOR(j, 1, i) sum += j;
      FOR(j, i, n) {
        sum += j;
        sum -= (j - i);
        if (sum == n) {
          //cout << i << " " << j << endl;
          cnt++;
        }
      }
    }

    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 3000
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    std::cout<<"ABC" + std::to_string(n)<<std::endl;
    return 0;
}

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

int bubbleSort(int A[],int N){
int sw=0;
bool flag=1;
for(int i=0;flag;i++){
flag=0;
for(int j=N-1;j>=i+1;j--){
if(A[j]<A[j-1]){
swap(A[j],A[j-1]);
flag=1;
sw++;
}
}
}
return sw;
}
int main(){
int A[100],N,sw;
cin >>N;
for(int i=0;i<N;i++) cin >>A[i];
sw=bubbleSort(A,N);
for(int i=0;i<N;i++){
if(i) cout <<" " ;
cout <<A[i];
}
cout <<endl;
cout <<sw<<endl;
return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    int m = max({a[0], a[1] , a[2]});
    int v[3] = {};
    int ans = 0;
    rep(i, 3){
        v[i] = m - a[i];  
    }
    sort(v, v+3);

    ans = v[1];
    int t = v[2] - v[1];

    if(t % 2 == 0){
        cout << ans + t / 2 << endl;
    }
    else{
        cout << ans + (t / 2) + 2 << endl;
    }

    return 0;
}

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

int main() {

  int i,j;

  int A, B, C, D, E, F;
  vector<int> water,sugar;

  cin >> A >> B >> C >> D >> E >> F;

  for(i = 0; i <= F/(100*A); i++) {
    for(j=0; j<=(F-(100*A*i))/(100*B); j++) {
      if(i!=0 || j!=0)
	water.push_back(100*A*i+100*B*j);
    }
  }

  for(i=0; i<=F/C; i++) {
    for(j=0; j<=F/D; j++) {
      sugar.push_back(C*i+D*j);
    }
  }
  //vector<int>::iterator citer = find(sugar.begin(), sugar.end(), 934);
  //vector<int>::iterator diter = find(sugar.begin(), sugar.end(), 932);

  long double max_den = -1;
  int max_sugar = 0;
  int max_water = 0;

  for(vector<int>::iterator iter_w = water.begin(); iter_w != water.end(); iter_w++) {
    for(vector<int>::iterator iter_s = sugar.begin(); iter_s != sugar.end(); iter_s++) {
      if(*iter_w + *iter_s <= F && *iter_w*E >= *iter_s*100) {
	if(max_den*(*iter_w+*iter_s)< (100.0*(*iter_s))) {
	  max_den = (100.0*(*iter_s))/(*iter_w+*iter_s);
	  max_sugar = *iter_s;
	  max_water = *iter_w;
	}
      }
    }
  }

  cout << (max_water+max_sugar) << " " << max_sugar << endl;

  return 0;
}



Measured memory_bytes: 2420
using System;

class main{
	static void Main(){
		string[] str = new string[3];
		for(int i = 0; i < 3; i++){
			str[i] = Console.ReadLine();
		}
		for(int i = 0; i < 3; i++){
			Console.Write(str[i][i]);
		}
		Console.WriteLine();
	}
}

Measured memory_bytes: 11092
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.array;
import std.range;
import std.regex;

void main(){
	auto a=readln.chomp.to!int;
	if(a<1200)writeln("ABC");
	else if(a>=1200&&a<2800)writeln("ARC");
	else writeln("AGC");
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

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

    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) { cin >> a[i]; }
    vector<int> ans(N);
    for (int i = N - 1; i >= N / 2; i--) {
        ans[i] = a[i];
        debug("initial", i + 1, ans);
    }

    for (int i = N / 2 - 1; i >= 0; i--) {
        int pos = i + 1;
        int accum = 0;
        while (pos <= N) {
            accum += ans[pos - 1];
            pos = pos + (i + 1);
        }
        debug("later", i + 1, ans, accum);
        if (accum % 2 == a[i]) {
            ans[i] = 0;
        } else {
            ans[i] = 1;
        }
    }

    ll sm = accumulate(ans.begin(), ans.end(), 0);
    cout << sm << endl;
    if (sm != 0) {
        rep(i, N) {
            if (ans[i] == 1) {
                cout << i+1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String[] s = new String[n];
		int[] t = new int[n];
		for(int i = 0; i < n; i++){
		    s[i] = sc.next();
		    t[i] = sc.nextInt();
		}
		String x = sc.next();
		
		// 計算
		int result = 0;
		int index = 0;
		for(int i = 0; i < n; i++){
		    if(s[i].equals(x)) index = i;
		}
		for(int i = index + 1; i < n; i++){
		    result += t[i];
		}
		
		// 出力
		System.out.println(result);
	}
	
}




Measured memory_bytes: 21716
#include <iostream>

int main()
{
	int a, b, c;
	int count = 0;

	std::cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {
		if (c%i == 0) {
			count++;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;


int main() {
  string s; cin >> s;
  deque<char> v(s.size());
  deque<char> vr(s.size());
  rep(i, s.size()) v[i] = s[i];
  rep(i, s.size()) vr[i] = s[s.size()-i-1];
  bool fl = 0;

  ll q; cin >> q;
  rep(i, q) {
    int a; cin >> a;
    if(a == 2) {
      int b; cin >> b;
      if(!fl) {
      if(b == 1) {
        char c; cin >> c;
        v.push_front(c);
        vr.push_back(c);
      }
      else {
        char c; cin >> c;
        v.push_back(c);
        vr.push_front(c);
      }
      }
      else {
        if(b == 1) {
        char c; cin >> c;
        vr.push_front(c);
        v.push_back(c);
      }
      else {
        char c; cin >> c;
        vr.push_back(c);
        v.push_front(c);
      }
      }
    }
    else {
      if(fl) fl = 0;
      else fl = 1;
    }
  }
  if(!fl) {
    rep(i, v.size()) cout << v[i];
    cout << endl;
  }
  else {
    rep(i, vr.size()) cout << vr[i];
    cout << endl;
  }
}


Measured memory_bytes: 1408
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main{
	static Map<Long,Long> map= new TreeMap<>();
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long a=sc.nextLong(),v=sc.nextLong(),b=sc.nextLong(),w=sc.nextLong(),t=sc.nextLong();
	  long s=Math.abs(a-b),h=v-w;
	  if(h*t>=s) {
		  System.out.println("YES");
	  }else {
		  System.out.println("NO");
	  }
  }
}



Measured memory_bytes: 35824
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n; cin >> n;
    set<int> a;
    for(int i = 0; i < n; ++i) {
        int t; cin >> t;
        if(a.count(t)) {cout << "NO\n"; return;}
        a.insert(t);
    }
    cout << "YES\n";
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll h,n; cin >> h >> n;
  for(ll i=0; i<n; i++){
    ll tmp; cin >> tmp;
    h -= tmp;
  }
  if(h<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int, input().split()))
dp = []
for k in range(n+1):
    dp.append(0)

for i in range(2, n+1):
    if i == 2:
        dp[i] = abs(lis[i-1]-lis[i-2])
        #print(i, dp[i])
    else:
        #print(i)
        dp[i] = min(abs(lis[i-1]-lis[i-2])+dp[i-1], abs(lis[i-1]-lis[i-3])+dp[i-2])
        #print(i, dp[i])
print(dp[n])

Measured memory_bytes: 13980
#include <stdio.h>

int main(void) {
	int n, i, x;
	
	scanf("%d", &n);
	
	for(i = 1; i <= n; i++) {
		x = i;
		if(x % 3 == 0) {
			printf(" %d", i);
		} else {
			while(1) {
				if(x % 10 == 3) {
					printf(" %d", i);
					break;
				} else if(x < 10) {
					break;
				}
				
				x /= 10;
			}
		}
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  set<int> st;
  REP(i, n) {
    int a; cin >> a;
    st.emplace(a);
  }
  cout << (st.size() == n ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=2e5+5;
int n,q;
int sum[mx],ans[mx];
vector <int> v[mx];
void dfs(int x,int top){
	ans[x]+=sum[x]+top;
	for(int i=0;i<v[x].size();++i){
		dfs(v[x][i],top+sum[x]);
	}
}
int main(){
	/*freopen(".gir", "r", stdin);
	freopen(".cik", "w", stdout); 
    */ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> n >> q;
	rep(i,n-1){
		int x,y;
		cin >> x >> y;
		v[x].pb(y);
	}
	rep(i,q){
		int x,y;cin >> x >> y;
		sum[x]+=y;
	}
	dfs(1,0);

	rep(i,n){
		cout << ans[i+1] <<" ";
	}
	cout << endl;
}
	

Measured memory_bytes: 24192
n = int(input())
h = list(map(int, input().split()))
cnt = 0
l = []
for i in range(n - 1):
    if h[i] < h[i + 1]:
        l.append(cnt)
        cnt = 0
    else:
        cnt += 1
l.append(cnt)
print(max(l))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H,vector<char>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> S[i][j];
    }
  }
  vector<set<int>> E(H * W);
  for (int i = 0; i < H; i++){
	for (int j = 0; j < W; j++){
      if (S[i][j] == '.'){
        if (i > 0){
          if (S[i - 1][j] == '.') E[i * W + j].insert((i - 1) * W + j);
        }
        if (i < H - 1){
          if (S[i + 1][j] == '.') E[i * W + j].insert((i + 1) * W + j);
        }
        if (j > 0){
          if (S[i][j - 1] == '.') E[i * W + j].insert(i * W + j - 1);
        }
        if (j < W - 1){
          if (S[i][j + 1] == '.') E[i * W + j].insert(i * W + j + 1);
        }
      }
    }
  }
  //WF
  vector<vector<int>> d(H * W, vector<int>(H * W, 1000));
  //初期化
  for (int i = 0; i < H * W; i++){
    d[i][i] = 0;
  }
  for (int i = 0; i < H * W; i++){
    for (int j = 0; j < H * W; j++){
      if (E[i].count(j)){
        d[i][j] = 1;
      }
    }
  }
  //WF
  for (int k = 0; k < H * W; k++){
    for (int i = 0; i < H * W; i++){
      for (int j = 0; j < H * W; j++){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  //最大値を求める
  int M = 0;
  for (int i = 0; i < H * W; i++){
    for (int j = 0; j < H * W; j++){
      if (M < d[i][j] && d[i][j] < 1000){
        M = d[i][j];
      }
    }
  }
  cout << M;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long
using namespace std;
int n1,n2,sz[50];
char s[li],t[li];
vector<int> v[50];
main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	n1=strlen(s+1);
	n2=strlen(t+1);
	for(int i=1;i<=n1;i++){
		int q=s[i]-'a';
		v[q].pb(i);
	}
	for(int i=0;i<=25;i++){
		sz[i]=(int)v[i].size();
	}
	int cev=0,konum=0;
	for(int i=1;i<=n2;i++){
		int harf=t[i]-'a';
		if(sz[harf]==0){
			printf("-1\n");
			return 0;
		}
		int boy=sz[harf];
		if(v[harf][boy-1]<=konum){
			cev+=n1-konum;
			konum=0;
		}
		int bas=0,son=boy-1;
		while(bas<=son){
			int mid=(bas+son)/2;
			if(v[harf][mid]<=konum) bas=mid+1;
			else son=mid-1;
		}
		int git=v[harf][bas];
		cev+=git-konum;
		konum=git;
	}
	printf("%lld\n",cev);
	return 0;
}




Measured memory_bytes: 1656
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}

Measured memory_bytes: 1792
#![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 H: usize = read();
    let W: usize = read();
    let mut c: Vec<Vec<i32>> = vec![vec![-1; 10]; 10];
    for i in 0..=9 {
        for j in 0..=9 {
            c[i][j] = read();
        }
    }
    for k in 0..=9 {
        for i in 0..=9 {
            for j in 0..=9 {
                if c[i][j] > c[i][k] + c[k][j] {
                    c[i][j] = c[i][k] + c[k][j];
                }
            }
        }
    }
    let mut ans = 0;
    for _ in 0..H {
        for _ in 0..W {
            let a: i32 = read();
            if a == -1 {
                continue;
            }
            let a = a as usize;
            ans += c[a][1];
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2124