akhauriyash/Code-Regression huggingface dataset:
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

// 整数用
func lowerBound(a []int, x int) int {
	l := 0
	r := len(a) - 1
	for l <= r {
		m := (l + r) / 2
		if a[m] >= x {
			r = m - 1
		} else {
			l = m + 1
		}
	}
	return l
}

func upperBound(a []int, x int) int {
	l := 0
	r := len(a)
	for l <= r {
		m := (l + r) / 2
		if len(a) == m {
			break
		}
		if a[m] <= x {
			l = m + 1
		} else {
			r = m - 1
		}
	}
	return l
}

var a []int
var edge [][]int
var dp []int
var ans []int

const inf = 1001001001001

func dfs(x, prev int) {
	pos := lowerBound(dp, a[x])
	val := dp[pos]
	dp[pos] = a[x]
	ans[x] = lowerBound(dp, inf)
	for _, v := range edge[x] {
		if v == prev {
			continue
		}
		dfs(v, x)
	}
	dp[pos] = val

}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a = make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	edge = make([][]int, N)
	for i := 0; i < N-1; i++ {
		u, v := getInt()-1, getInt()-1
		edge[u] = append(edge[u], v)
		edge[v] = append(edge[v], u)
	}

	dp = make([]int, N+1)
	ans = make([]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = inf
	}
	dfs(0, -1)

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	for i := 0; i < N; i++ {
		fmt.Fprintln(w, ans[i])
	}
}


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

const int maxn = 300;
int n, m, mod, C[maxn + 3][maxn + 3], dp[maxn + 3][maxn + 3], f[maxn + 3][maxn + 3];

int func(int x) {
	return x < mod ? x : x - mod;
}

void prework(int n) {
	for (int i = 0; i <= n; i++) {
		C[i][0] = 1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			C[i][j] = func(C[i - 1][j - 1] + C[i - 1][j]);
		}
	}
}

int main() {
	scanf("%d %d %d", &n, &m, &mod);
	prework(n);
	for (int i = 0; i <= m; i++) {
		dp[1][i] = 1;
	}
	for (int i = m; ~i; i--) {
		f[1][i] = func(f[1][i + 1] + 1);
	}
	for (int i = 2; i <= n + 1; i++) {
		for (int j = 0; j <= m; j++) {
			for (int k = 1; k < i; k++) {
				dp[i][j] = (dp[i][j] + 1ll * f[k][j + 1] * dp[i - k][j] % mod * C[i - 2][k - 1]) % mod;
			}
		}
		for (int j = m; ~j; j--) {
			f[i][j] = func(f[i][j + 1] + dp[i][j]);
		}
	}
	printf("%d\n", dp[n + 1][0]);
	return 0;
}

Measured memory_bytes: 1280
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int cnt[1000001];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n){
    cin >> a[i];
    cnt[a[i]]++;
  }
  bool pw = true;
  repr(i, 2, 1000001){
    ll c = 0;
    for(int j = i; j < 1000001; j += i){
      c += cnt[j];
    }
    if(c >= 2){
      pw = false;
      break;
    }
  }
  ll b = a[0];
  repr(i, 1, n){
    b = gcd(a[i], b);
  }
  bool sw = b == 1;
  if(pw){
    print("pairwise coprime");
  }else if(sw){
    print("setwise coprime");
  }else{
    print("not coprime");
  }
}


Measured memory_bytes: 15060
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let n = io.read::<usize>();
    let x = io.readn::<isize>(n);

    let mut ans = 242342344;
    for p in 1..101 {
        let mut ret = 0;
        for &xx in x.iter() {
            ret += (xx - p) * (xx - p);
        }
        ans = min(ret, ans);
    }
    io.writeln(ans);
}

static MOD: i64 = 1000000007;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 100

void push(int);
int pop(void);

int top = 0;
int stack[MAX];

int main(){
  int a, b;
  char in[MAX];

  while(1){
    //printf("%c", in[i]);
    if(scanf("%s", in) == EOF) break;
    
    if(in[0] == '+'){
      push(pop() + pop());
    }
    else if(in[0] == '-'){
      a = pop();
      b = pop();
      push(b - a);
    }
    else if(in[0] == '*'){
      push(pop() * pop());
    }
    else{
      push(atoi(in));
    }
  }
  //printf("\n");

  printf("%d\n", pop());
  
  return 0;
}

void push(int x){
  top++;
  stack[top] = x;
}

int pop(){
  top--;
  return stack[top+1];
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();

        int n;
        cin>>n;
        string s;
        cin>>s;
        int c=0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A'&& s[i+1]=='B'&& s[i+2]=='C')
            c++;
    }
    cout<<c;


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int dp[2005][2005],n;
P<int,int> p[2005];
int cost(int x,int y){
	RE p[y].F*abs(x-p[y].S);
}
int dfs(int l,int r){
	if(dp[l][r]!=-1)RE dp[l][r];
	int len=l+n-r+2,re=0;
	if(len==n+1)RE dp[l][r]=re;
	re=max(dfs(l+1,r)+cost(l+1,len),dfs(l,r-1)+cost(r-1,len));
	RE dp[l][r]=re;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin>>n;
	FOR(i,1,n){
		cin>>x;
		p[i]=MP(x,i);
	}
	sort(p+1,p+n+1,greater<P<int,int>>());
	FILL(dp,-1);
	cout<<dfs(0,n+1)<<'\n';
	RE 0;
}




Measured memory_bytes: 35224
#include <stdio.h>

int main()
{   int n;
    scanf("%d",&n);
    int p[n],ans=0;
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int i;
    for(i=0;i<n-1;i++){
        if(p[i]==i+1){
            ans++;
            i++;
        }
    }
    if(p[n-1]==n&&i==n-1)ans++;
    printf("%d",ans);

    return 0;
}


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

namespace ABC130A
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力データをスペース区切りの文字形式で受け取る
            string[] input = Console.ReadLine().Split();
            //それぞれの入力データを整数型に変更して変数Xと変数Aに代入しておく
            int X = int.Parse(input[0]);
            int A = int.Parse(input[1]);

            //大きさを比べる
            //XがA未満の時、0を出力する
            //ifと入力してTabキーを2回押すと展開される

            if (X<A)
            {
                Console.WriteLine(0);
            }
            //それ以外の場合
            //XがA以上の時、10を出力する
            //elseと入力してTabキーを2回押すと展開される
            else
            {
                Console.WriteLine(10);
            }
            //実行するときは「デバッグ→デバックなしで開始」
        }
    }
}


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

int main(){
  ll n , x ,t ;
  cin >> n >> x >>t ;
  for(int i = 0;;i++){
    if(n<= i*x){
      cout << i * t <<endl ;
      return 0 ;
    }
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;



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

	set<int> s;

	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;

		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			a--;
			s.insert(a);
		}

	}

	cout << n - s.size() << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){
int a, b;
    scanf("%d %d", &a, &b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2044
N, K = map(int ,input().split())
P = list(map(int, input().split()))

PP = [(1+P[i])/2 for i in range(N)]

tmp = sum(PP[:K])
ans = tmp
for i in range(K,N):
	tmp += (PP[i]-PP[i-K])
	ans = max(ans,tmp)
print(ans)


Measured memory_bytes: 25060
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        if (a % 2 && i % 2) ans++;
    }
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 100;
vector<int> dp(100005, INF);
vector<int> h;

// int f(int i, int k){
//     if(dp[i] < INF)return dp[i];
//     else if(i == 0)return 0;
//     int res = INF;
//     int con = min(i, k);
//     for (int j = 1; j <= con; j++)
//     {
//         res = min(res, f(i-j, k) + abs(h[i]-h[i-j]));
//     }
//     return dp[i] = res;   
// }

int main() {
    int n, k;cin >> n >> k;
    h.resize(n+k+10);
    for (int i = 0; i < n; i++)cin >> h.at(i);
    
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            dp[i+j] = min(dp[i] + abs(h[i]-h[i+j]), dp[i+j]);
        }        
    }
    
    // for (int i = 0; i < n; i++){
    //     for (int j = 1; j < i; j++)f(i, k);       
    // }
    
    // // for (int j = 1; j <= k; j++)
    // // {
    // //     for (int i = j; i < n; i++)
    // //     {
    // //         dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
    // //     }        
    // // }
    cout << dp[n-1] << endl;
    
    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn mod2019(i: usize, j: usize) -> usize {
    (i * j) % 2019
}

#[allow(non_snake_case)]
fn main() {
    input![L: usize, R: usize];
    let mut ans = std::usize::MAX;
    for l in L..R {
        for r in L + 1..R + 1 {
            ans = std::cmp::min(ans, mod2019(l, r));
            if ans == 0 {
                println!("{}", ans);
                std::process::exit(0);
            }
        }
    }
    println!("{}", ans);
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

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

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

	if(sum>=h){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
n=input()
L=[9,0,900,0,90000]
ans=0
if len(n)==1:ans=int(n)
else:
    for i in range(len(n)-1):
        ans+=L[i]
    if len(n)%2!=0:ans+=int(n)-int("9"*max(0,len(n)-1))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll a,b,c;
    cin >> a >> b >> c;
    int n = 0;
    while(n <= 10000000){
        if((a&1) || (b&1) || (c&1)){
            pr(n);
            return 0;
        }
        ll ta = a;
        ll tb = b;
        ll tc = c;
        a = tb/2 + tc/2;
        b = ta/2 + tc/2;
        c = tb/2 + ta/2;

        n++;
    }
    pr(-1);
}

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

int main(void){
    int n;
    cin >> n;
    int a[110];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    for(int k=0; k<n-1; k++){
        cout << a[k] << " ";
    }
    cout << a[n-1] << endl;

    for(int i=1; i<n; i++){
        int v = a[i];
        int j = i-1;
        while(j >= 0  && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        for(int k=0; k<n-1; k++){
            cout << a[k] << " ";
        }
        cout << a[n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll ar[10],sum=600,rate=8,br[10];
  	for(ll i=0;i<9;i++)
    {ar[i]=sum;sum+=200;br[i]=rate;rate--;}
  	ll x,i;cin>>x;
  	for(i=0;i<9;i++)
    {
    	if(x<ar[i])break;
    }
  	cout<<br[i]<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

vector<P> G[100000];
int colors[100000];

void dfs(int node, int from, int from_color){
  int color = 1;
  for (auto e : G[node]){
    int to = e.first, cur = e.second;
    if (to == from) continue;
    if (color == from_color) color++;
    colors[cur] = color;
    dfs(to, node, color);
    color++;
  }
}

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

  int n;
  cin >> n;

  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }

  int max_edge = 0;
  for(auto g : G)chmax(max_edge, (int)g.size());

  dfs(0,-1,-1);
  cout<<max_edge<<endl;
  rep(i,0,n-1)cout<<colors[i]<<endl;
}


Measured memory_bytes: 12508
s=input()
flg=False

for i in range(len(s)):
  if (i+1)%2==0 and s[i]=='R':
    flg=True
  if (i+1)%2==1 and s[i]=='L':
    flg=True
if flg:
  print('No')
else:
  print('Yes')


Measured memory_bytes: 2940
TEST = true
def pt(obj)
  p obj if TEST
end

n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)

dp = [0, (h[0] - h[1]).abs]

(2..(n-1)).each do |i|
  dp.push [dp[i-2] + (h[i-2] - h[i]).abs, dp[i-1] + (h[i-1] - h[i]).abs].min
end

#p dp
puts dp.last


Measured memory_bytes: 11908
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

vi edge[100001];
int vis[100001]={0},ans;
int dp[100001]={0},x[100001]={0};
void dfs(int root)
{
	if(edge[root].size()==0) dp[root]=0;
	
	vi::iterator itr;
	
	for(itr=edge[root].begin();itr!=edge[root].end();itr++)
	{
		if(!vis[*itr]) dfs(*itr);
		dp[root]=max(dp[root],dp[*itr]+1);
		ans=max(ans,dp[root]);
	}
	vis[root]=1;
}

void solve()
{
	int m,n;
	cin>>n>>m;
	
	while(m--)
	{
		int a,b;
		cin>>a>>b;
		edge[a].pb(b);
		x[b]++;
	}
	rep(i,1,n+1)
	{
		if(x[i]==0) dfs(i);
	}
	
	cout<<ans<<endl;
}


signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t=1;
		while(t--)
		{
			solve();
		}
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(3*N);
    REP(i,0,3*N) cin >> A[i];
    
    ll sum = 0;
    DESC(A);
    REP(i,0,N) sum += A[i*2+1];
    PR(sum);


    return 0;
}

/*



*/

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

int main() {
  vector<char> a(3);
  vector<char> b = {'a', 'b', 'c'};
  for(int i = 0; i < 3; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  if(a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 500005
using namespace std;
typedef long long ll;
int n,D,a[N],d[N],m,ans[N],cnt,w[N],sum[N];
ll mx[N];
pair<int,int> b[N];
int main(){
	scanf("%d%d",&n,&D);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	d[1]=D;
	for(int i=2;i<=n;i++){
		if(a[i-1]<=d[i-1]) d[i]=d[i-1]-a[i-1];
		else d[i]=min(d[i-1],a[i-1]-d[i-1]);
	}
	mx[n+1]=1;
	for(int i=n,p=0;i;i--){
		if(a[i]>=2*mx[i+1]) mx[i]=mx[i+1];
		else mx[i]=mx[i+1]+a[i];
	}
	scanf("%d",&m);
	for(int i=1,x;i<=m;i++){
		scanf("%d",&x);
		if(d[x]>=mx[x+1]) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 13440
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

ll n, x, ans;

ll calc(ll len, ll p) {
	if (len == 0 || p == 0) {
		return 0;
	}

	ll ret, t = len / p;

	if (len == t * p) {
		ret = (2 * t - 1) * p;		
	}
	else {
		ret = (2 * t) * p + calc(p, len - t * p);
	}
	
	return ret;
}

void solve() {                   
	scanf("%lld %lld", &n, &x);
    printf("%lld\n", n + calc(n - x, x));
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e6 + 10; 

int val[N];

inline int add(int a, int b, int mod = MOD) {
  a += b; return a >= mod ? a - mod : a;
}
inline int sub(int a, int b, int mod = MOD) {
  a -= b; return a < 0 ? a + mod : a;
}
inline int mul(int a, int b, int mod = MOD) {
  return int((long long) a * b % mod);
}
inline int power(int base, long long ex, int mod = MOD) {
  int res = 1;
  for (; ex > 0; ex >>= 1) {
    if (ex & 1) res = mul(res, base, mod);
    base = mul(base, base, mod);
  }
  return res;
}
inline int inv(int a, int mod = MOD) {
  return power(a, mod - 2, mod);
}
inline int mdiv(int a, int b, int mod = MOD) {
  return mul(a, power(b, mod - 2,  mod));
}
inline void adds(int &a, int b, int mod = MOD) {
  a += b; if (a >= mod) a -= mod;
}
inline void subs(int &a, int b, int mod = MOD) {
  a -= b; if (a < 0) a += mod;
}
inline void muls(int &a, int b, int mod = MOD) {
  a = int((long long) a * b % mod);
}
inline void mdivs(int &a, int b, int mod = MOD) {
  a = mdiv(a, b, mod);
}
vector<int> fact,ifact;
void prep_fact(int mx = 1e6 + 40) {
  fact.assign(mx,0);
  ifact.assign(mx,0);
  fact[0] = 1;
  for (int i = 1; i < mx; ++i) fact[i] = mul(i, fact[i - 1]);
  ifact[mx - 1] = inv(fact[mx - 1]);
  for (int i = mx - 1; i > 0; --i) ifact[i - 1] = mul(i, ifact[i]);
}
inline int ncr(int n, int r) {
  if (n < r || r < 0 || n < 0) return 0;
  return mul(fact[n], mul(ifact[n - r], ifact[r]));
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   val[0] = 1;
   f(i,1,N){
      int b = __builtin_popcount(i);
      val[i] = val[i%b]+1;
   }
   string s;
   cin >> s;
   int cnt = count(all(s),'1');
   debug(cnt);
   if(cnt == 0){
      int sm = 0;
      f(i,0,n){
         cout << "1\n";
      }
   }else if(cnt == 1){
      int sm = 0;
      f(i,0,n){
         if(s[i] == '1'){
            sm = power(2,n-i-1,2);
         }
      }
      f(i,0,n){
         if(s[i] == '0'){
            int v = power(2,n-i-1,2);
            adds(sm,v);
            cout << val[sm] << '\n';
            subs(sm,v);
         }else{
            cout << "0\n";
         }
      }
   }else{
      int ff = 0, ss = 0;
      f(i,0,n){
         if(s[i] == '1'){
            adds(ff,power(2,n-i-1,cnt+1),cnt+1);
            adds(ss,power(2,n-i-1,cnt-1),cnt-1);
         }
      }
      f(i,0,n){
         if(s[i] == '0'){
            int v = power(2,n-i-1,cnt+1);
            adds(ff,v,cnt+1);
            cout << val[ff] << '\n';
            subs(ff,v,cnt+1);
         }else{
            int v = power(2,n-i-1,cnt-1);
            subs(ss,v,cnt-1);
            cout << val[ss] << '\n';
            adds(ss,v,cnt-1);
         }
      }
   }
   return 0;
} 


Measured memory_bytes: 11580
#include <bits/stdc++.h>
long long n;
int main(){
	scanf("%lld",&n);
	int x=(int)sqrt(n)+1;
	for (int i=x;i>=1;i--){
		if (n%i==0){
			long long ans=i;
			ans=ans+n/i;
			printf("%lld\n",ans-2);
			break;
		} 
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n);
    for(int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i) {
        cin >> b[i];
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            sum += a[i] + min(b[i] - a[i], a[i + 1]);
            a[i + 1] = max((a[i + 1] - (b[i] - a[i])), 0LL);
        }
        else
            sum += b[i];
    }
    cout << sum << "\n";
}

Measured memory_bytes: 1792
class Node:
    def __init__(self, v=None, l=None, r=None):
        self.value = v
        self.left = l
        self.right = r

class Tree:
    def __init__(self):
        self.root = Node()
    
    def insert(self, v):
        if self.root.value is None:
            self.root.value = v
            return
        node = self.root
        while node is not None:
            if v < node.value:
                if node.left is None:
                    node.left = Node(v)
                    return
                node = node.left
            else:
                if node.right is None:
                    node.right = Node(v)
                    return
                node = node.right

    def find(self, v):
        node = self.root
        while node != None:
            if v == node.value:
                print "yes"
                return
            elif v < node.value:
                node = node.left
            else:
                node = node.right
        print "no"
        return

    def print_tree(self, order):
        ans = []
        def rec(node):
            if node is None:
                return
            if order == "pre":
                ans.append(str(node.value))
            if node.left is not None:
                rec(node.left)
            if order == "in":
                ans.append(str(node.value))
            if node.right is not None:
                rec(node.right)
        rec(self.root)
        print " " + " ".join(ans)

tree = Tree()
N = int(raw_input())
for _ in range(N):
    d = raw_input().split()
    cmd = d[0]
    if cmd == "insert":
        tree.insert(int(d[1]))
    elif cmd == "find":
        tree.find(int(d[1]))
    elif cmd == "print":
        tree.print_tree("in")
        tree.print_tree("pre")



Measured memory_bytes: 223756
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
using namespace std;

bool isAllDead(long long attacks,long long A,long long B,vector<long long> hitpoints){
    long long i,ACount = 0;
    for (i=0;i<hitpoints.size();i++){
        long long hitpoint = hitpoints[i] - attacks * B;
        if (hitpoint > 0){
            ACount += hitpoint / (A - B) + (hitpoint % (A - B) != 0);
        }
    }
    return ACount <= attacks;
}

int main()
{
    // 整数の入力
    long long i,N,A,B,temp,upper,lower;
    upper = 1000000001;
    lower = 0;
    vector<long long> hitpoints;
    cin >> N >> A >> B;

    for (i=0;i<N;i++){
        cin >> temp;
        hitpoints.push_back(temp);
    }


    while (lower != (upper + lower)/2){
        if (isAllDead((upper + lower)/2,A,B,hitpoints)){
            upper = (upper + lower)/2;
        }else{
            lower = (upper + lower)/2;
        }
    }
    cout << upper << endl;
    return 0;
}

Measured memory_bytes: 1908
function Main(input) {
    const lines = input.split("\n");
    const cache = [];
    let result = 'YES';

    lines[1].split(' ').some(a => {
        if (cache[a]) {
            result = 'NO';
            return true;
        }
        cache[a] = true;
    });
    
    console.log(result);
}

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

Measured memory_bytes: 64824
def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    nums = []
    nums.extend([a, b, c, d, e])
    nums.reverse()

    if (nums[0] - nums[4]) > k:
        print(':(')
    else:
        print('Yay!')

main()

Measured memory_bytes: 9128
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;

ll h,n,a[1010],b[1010];
ll dp[1010][20100];

int main(){
    cin>>h>>n;
    REP(i,n){
      cin>>a[i]>>b[i];
    }
    REP(i,n+1)REP(j,h+a[i]+2){
      dp[i][j]=INF;
    }
    ll ans=INF;
    dp[0][0]=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<=h+a[i];j++){
        if(j<a[i]){
          dp[i+1][j]=dp[i][j];
        }else {
          dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i]);
        }
        if(j>=h)ans=min(ans,dp[i+1][j]);
      }
    }

    cout<<ans<<endl;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int cnt[212345];

int32_t main(){
  DESYNC;
  int n;
  cin >> n;
  set<int> ans;
  int v[n];
  for(int i=1; i<=n; i++){
    cin >> v[i];
  }
  for(int i=n; i>=1; i--){
    int cur = 0;
    for(int j=i; j<=n; j+=i){
      cur += cnt[j];
    }
    if(cur%2 != v[i]){
      ans.insert(i);
      cnt[i]++;
    }
  }
  cout << ans.size() << endl;
  if(ans.size() > 0) for(int x : ans) cout << x << " ";
  if(ans.size() > 0) cout << endl;     
}



Measured memory_bytes: 9600
#pragma region Header
#define _CRT_SECURE_NO_WARNINGS
#define FOR(i,s, e) for(int i = s; i<e; ++i)
#define rFOR(i,s, e) for(int i=s-1; i>=e; --i)
#define loop(len) for(int i=0; i<len; ++i)
#define rloop(len) for(int i=len-1; i>=0; --i)
#define iPair pair<int,int>
#define LPair pair<ll,ll>
#define vecP(t,t2) vector<pair<t,t2>>
#define uoMP(t, t2) unordered_map<t, t2>
#define pb push_back
#define pp pop_back
#define beg_end(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define MrN ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long  ll;
typedef long double  ld;
#include<bits/stdc++.h>
using namespace std;
#pragma endregion

int n, k;
vector<ll> h;
const int SIZE = 1e5+5;
ll DP[SIZE];

ll solve(){
	DP[n-1] = 0;

	rFOR(i, n, 0){
		FOR(j, 0, k){
			int nxt = max(i-j-1, 0);
			ll cost = DP[i] + abs(h[i] - h[nxt]);
			DP[nxt] = min(DP[nxt], cost);
		}
	}

	return DP[0];
}

int main() {
	MrN;
	// freopen("input.txt", "r", stdin);

	loop(SIZE)
		DP[i] = INT_MAX;

	cin >> n >> k;
	h.resize(n);

	loop(n){
		cin >> h[i];
	}

	cout << solve() << '\n';

  return 0;
}


Measured memory_bytes: 4708
from collections import deque
import collections
import math
"""
#n = int(input())
#A = [int(i) for i in input().split()]
n = 10**5
A = [int(i)+1 for i in range(10**5,0,-1)]
A.sort()
ans = 0
ans_list = []
kaburi = {}
for i in A:
    Flag = True
    for j in ans_list:
        if i==j:
            kaburi[i]=True
            Flag = False
            break
        if i%j==0:
            Flag = False
            break
    if Flag:
        ans_list.append(i)
        ans += 1
print(ans-len(kaburi))
"""


n = int(input())
A = [int(i) for i in input().split()]
Max = max(A)
cnt_dict = collections.Counter(A)
#Dict[i]はi未満の約数がAに存在しなければTrue
Dict = {a:True for a in A}
for a in A:
    times = 2
    while a*times<=Max:
        Dict[a*times]=False
        times +=1
ans = 0
for a in A:
    if cnt_dict[a]==1 and Dict[a]:
        ans +=1
print(ans)


Measured memory_bytes: 104644
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
const int maxn = 400000;
struct seg{
	int l, r;
	ll v;
	friend bool operator < (const seg &a, const seg &b){
		return a.r < b.r;
		return a.r == b.r ? a.l < b.l : a.r < b.r;
		return a.l != b.l ? a.l < b.l : a.r < b.r;
	}
	friend istream& operator >> (istream& c, seg &a){
		return c >> a.l >> a.r >> a.v;
	} 
}se[maxn];
int n, m;
struct sgt{
	ll v[maxn << 1], tag[maxn << 1];
	void push(int i){
		v[i] += tag[i];
		if((i<<1|1) < (maxn<<1)){
			tag[i<<1] += tag[i];
			tag[i<<1|1] += tag[i];
		}
		tag[i] = 0;
	}
	void add_max(int ml, int mr, ll nv, int l = 0, int r = n, int i = 1){
		push(i);
		if(ml > r || mr < l)return;
		if(ml <= l and mr >= r)tag[i] += nv, push(i);
		else{
			add_max(ml, mr, nv, l, (l+r)/2, i<<1);
			add_max(ml, mr, nv, (l+r)/2+1, r, i<<1|1);
			v[i] = max(v[i<<1], v[i<<1|1]);
		}
	}
	ll qmax(int ml, int mr, int l = 0, int r = n, int i = 1){
		if(ml > r || mr < l)return -(1ll << 59);
		push(i);		
		if(ml <= l and mr >= r)return v[i];
		return max(qmax(ml, mr, l, (l+r)/2, i<<1), qmax(ml, mr, (l+r)/2+1, r, i<<1|1));
	}
}dp;
vector<seg> ss[maxn];
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	for(int i = 0;i < m;++i)cin >> se[i];
	for(int i = 0;i < m;++i)ss[se[i].r].push_back(se[i]);
	for(int i = 1;i <= n+1;++i){
		for(auto &k : ss[i-1])dp.add_max(k.l, i-1, k.v);
		ll nv = dp.qmax(0, i-1);
		if(i == n+1)cout << nv << '\n';
		else dp.add_max(i, i, nv);
	}
}

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

int main() 
{
    int a[3],c=0,i;
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<3;i++)
    {
        if(a[0]==a[i])
        {
            c++;
        }
    }
    if(c==2)
    {
        cout<<"No";
    }
    if(c==1)
    {
        cout<<"Yes";
    }
    if(c==0)
    {
        if(a[1]==a[2])
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    if(n==1 || m==1) cout << 1;
    else cout << n*m/2+n*m%2;
    return 0;
}


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

int main (){
	int n, t, k, l, h;
	cin >> n >> t;
	h = n * t;
	for(int i = 0; i < n; i++){
		if(i > 0){
			cin >> l;
			if(l - k < t){
				h -= t - (l - k);
			}
			k = l;
		}else{
			cin >> k;
		}
	}
	cout << h << endl;
	return 0;
} 

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin>>N;
	vector<int> H(N);
	rep(i,0,N)cin>>H[i];

	vector<int> DP(N,INF);
	DP[0]=0;

	rep(i,0,N-1)
	{
		rep(j,1,3)
		{
			int ni=i+j;
			if(ni>=N)continue;
			chmin(DP[ni],DP[i]+abs(H[ni]-H[i]));
		}
	}

	cout<<DP[N-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
import java.io.*
import java.util.*

fun solve(s: Array<String>){
    s.map{ it[0] }.joinToString(separator="").toUpperCase().let{ println(it) }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val s = StringArray(3.toInt())
    for (i in 0 until 3.toInt()) {
        s[i] = sc.next()
    }
    solve(s)
}



Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n+1,0);
    v[n] = LONG_LONG_MAX;
    rep(i,n)cin >> v[i];
    ll ans = 0;
    repl(i,0,n){
        while(i+1 < n && v[i] == v[i+1])i++;
        if(i+1 < n && v[i] < v[i+1])while(i+1 < n && v[i] <= v[i+1])i++;
        else if(i+1 < n && v[i] > v[i+1])while(i+1 < n && v[i] >= v[i+1])i++;
        ans++;
    }
    cout << ans << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int FindSumOfDigits(int num){
    int sum = 0;
    while(num>0){
        sum += num%10;
        num /= 10;
    }
    return sum;
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int total = 0;
    for(int i=1; i<=N; i++){
        if(FindSumOfDigits(i)<=B && FindSumOfDigits(i)>=A){
            total += i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include<cstdio>
const int mod=998244353;
int x[201],y[201],p[201];
int main(){
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d%d",&x[i],&y[i]);
    p[0]=1;
    for(int i=0;i<n;i++)p[i+1]=(p[i]<<1)%mod;
    int ans=p[n]-n-1;
    for(int i=0;i<n;i++)
        for(int j=0;j<i;j++){
            int cnt=0;
            for(int k=0;k<j;k++)if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))cnt++;
            ans=(ans-p[cnt]+mod)%mod;
        }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000
typedef long long i64;

int n;
int a[5];

int input() {
	for (int i=0; i<5; i++) 
		if (scanf("%d",&a[i])<0) return 0;
	return 1;
}

void init() {
}

int solve() {
	int r = 0, m = 0;
	for (int i=0; i<5; i++) {
		r += (a[i] + 9) / 10 * 10;
		if (a[i] % 10)
			m = max(m, 10 - a[i] % 10);
	}
	return r - m;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 128
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll dp[100001][4],q=0,res=0,MOD=1000000007,a=0,b=0,ab=0,abc=0;
  string s;
  cin >> s;
  REP(i,100001)REP(j,4)dp[i][j]=0;
  dp[0][0] = 1;
  REP(i,s.size()){
    REP(j,4){
    if(s[i] == '?'){
      dp[i+1][j] = (3*dp[i][j]) % MOD;
      continue;
    }else
      dp[i+1][j] = ( dp[i][j]) % MOD;
    }
    if(s[i] == 'A' || s[i] == '?')
      dp[i+1][1] = (dp[i+1][1] + dp[i][0]) % MOD;
    if(s[i] == 'B' || s[i] == '?')
      dp[i+1][2] = (dp[i+1][2] + dp[i][1]) % MOD;
    if(s[i] == 'C' || s[i] == '?')
      dp[i+1][3] = (dp[i+1][3] + dp[i][2]) % MOD;
    }
  cout << dp[s.size()][3] << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 3584
d,n = map(int,input().split())

if n == 100:
    if d == 0:
        print(101)
    elif d == 1:
        print(10100)
    else:
        print(1010000)
else:
    if d == 0:
        print(n)
    elif d == 1:
        print(n*100)
    else:
        print(n*(100**2))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  for(int i=0; i<(int)s.size(); i+=2){
    cout << s[i];
  }
  return 0;
}


Measured memory_bytes: 592
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N, R):
    if N >= 10:
        return R
    else:
        # R = ans - 100 * (10 - N)
        # ans = R + 100 * (10 - N)
        return R + 100 * (10-N)


if __name__ == "__main__":

    # N R
    #
    N, R = map(int, input().split())
    ans = solv(N, R)

    print(ans)


Measured memory_bytes: 2940