akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] dp = new int[n];
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			dp[i] = -1;
		}
		dp[0] = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 1; i+j < n && j <= k; j++) {
				if(dp[i+j] < 0) {
					dp[i+j] = dp[i] + Math.abs(h[i]-h[i+j]);
				}else {
					dp[i+j] = Math.min(dp[i+j], dp[i] + Math.abs(h[i]-h[i+j]));
				}
			}
		}
		System.out.println(dp[n-1]);
		sc.close();
	}

}

Measured memory_bytes: 58820
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define N (ll)(1e17+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll t=1;
   //cin>>t;
   while(t--)
   {
       string s,t,g;
       ll sc,tc;
       cin>>s>>t>>sc>>tc>>g;
       if(g==s)
        cout<<sc-1<<" "<<tc<<"\n";
       else
        cout<<sc<<" "<<tc-1<<"\n"; 
   }
}

Measured memory_bytes: 256
import Data.List (findIndices)

main :: IO ()
main = print . solve =<< readLn

solve :: Int -> Int
solve n = succ
        . head
        . findIndices (== maximum l)
        $ l where
      l = map count [1 .. n]

count :: Int -> Int
count x = pred
        . length
        . takeWhile fst
        . iterate (\(x, y) -> (x && even y, div y 2))
        $ (even x, x)

Measured memory_bytes: 508
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() { // Yes/No
    input! {
        s: String,
        mut xy: [i64; 2],
    }

    let moves = s.split('T').map(|s| s.len() as i64).collect_vec();
    let mut move2 = vec![Vec::new(); 2];
    xy[0] -= moves[0];
    let mut get_y = true;
    for num in moves.into_iter().skip(1) {
        if get_y {
            move2[1].push(num);
        } else {
            move2[0].push(num);
        }
        get_y = !get_y;
    }
    let moves = move2;
    for (i, mv) in (0..).zip(moves) {
        let mut dp = vec![HashSet::new(); mv.len() + 1];
        dp[0].insert(0);
        for (k, &num) in (0..).zip(&mv) {
            for &v in dp[k].clone().iter() {
                dp[k+1].insert(v + num);
                dp[k+1].insert(v - num);
            }
        }
        if !dp[mv.len()].contains(&xy[i]) {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 55328
package main

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

func main() {

	A, B, M := ScanInt(), ScanInt(), ScanInt()
	a := ScanIntSlice(A)
	b := ScanIntSlice(B)
	r := math.MaxInt32
	for t := M; t > 0; t-- {
		xi, yi, ci := ScanInt(), ScanInt(), ScanInt()
		if r > a[xi-1] + b[yi-1] - ci {
			r = a[xi-1] + b[yi-1] - ci
		}
	}

	fr := Mn(a...)
	re := Mn(b...)
	if fr + re < r {
		P((fr + re))
	} else {
		P(r)
	}
	
}

/*********************** I/O ***********************/

var in *bufio.Scanner
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
}

func ScanWord() string {in.Scan(); return in.Text() }
func ScanInt() int {i, _ := strconv.Atoi(ScanWord()); return i}
func ScanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = ScanWord()}; return s}
func ScanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = ScanInt()}; return arr}

/*********************** Utils ***********************/

func S(v interface{}) string {return fmt.Sprintf("%v", v)}
func MnMx(args ...int) (int, int) {minVal, maxVal := int(math.MaxInt32), int(math.MinInt32); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int {return a / GCD(a, b) * b}
func GCD(a, b int) int {if (a == 0) {return b}; return GCD(b%a, a)}
func abs(x int) int {if x < 0 {return -x}; return x}


Measured memory_bytes: 4992
macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}
     
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};
//#[proconio::fastout]
fn main() {
    input!{
        s: String,
    }
    let (sa, sz) = (s.chars(), s.chars().rev());
    let (mut ia, mut iz) = (0usize, 0usize);
    for (i, a) in sa.enumerate() {
        if a == 'A' {
            ia = i;
            break;
        }
    }
    for (i, z) in sz.enumerate() {
        if z == 'Z' {
            iz = s.len() - i;
            break;
        }
    }
    println!("{}", s[ia..iz].len());
}


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

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	int n ,m ,x , ans;
	cin >> n;
	m = n % 15;
	m = (n - m) / 15;
	ans = n * 800 - m * 200;
	cout << ans << endl;
	return 0;
	}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll n, d; cin >> n >> d;
    ll c = 0;
    rep(i, 0, n){
        ll a, b; cin >> a >> b;
        if(a*a + b*b <= d*d){
            c++;
        }
    }
    prtl(c);
}


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

int main()
{
    char str[4] = {'\0', '\0', '\0', '\0'};
    for (int i=0; i < 3; ++i)
    {
        for (int j=0; j < 3; ++j)
        {
            char ch;
            cin >> ch;
            if (i == j)
            {
                str[i] = ch;
            }
        }
    }
    cout << str << std::endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
array = []

for i in range(N-1):
    array.append(H[i]-H[i+1])

cnt = 0
ans = 0
for i in range(N-1):
    if array[i]>=0:
        cnt+=1
        if i==N-2 and ans<cnt: ans=cnt
    else:
        if ans<cnt: ans=cnt
        cnt=0

print(ans)


Measured memory_bytes: 14252
#!/usr/bin/env python3

def main():
    N = int(input())
    h = list(map(int, input().split()))

    INF = 1 << 60
    
    h.append(INF)
    h.append(INF)

    dp = [INF] * 100010

    dp[0] = 0

    for i in range(N):
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

    print(dp[N-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 20496
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<string>

using namespace std;

//We have a bag that contains N hina arare. (From here, we call them arare.)
int n,ans=0;
int a[300];
int main()
{
	cin >> n;
	char c;
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		if (a[c] == 0)
		{
			ans++;
			a[c]++;
		}
	}
	if (ans == 3)
	{
		cout << "Three";
	}
	else
	{
		cout << "Four";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector< pair<string, int> > st;
  rep(i, n) {
    string s;
    int t;
    cin >> s >> t;
    st.push_back(make_pair(s, t));

  }
  string s;
  cin >> s;
  int ans = 0;
  int index = 0;
  rep(i, n){
    if (st[i].first == s) {
      index = i+1;
      break;
    }
  }
  repd(i, index, n) ans += st[i].second;
  cout << ans << endl;
  return 0;
}


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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const int MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll dp[101][4][4];

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");

    auto solve = [](int _) {
        int n;
        cin >> n;
        vector<int> p(n + 1);
        for (int i = 1; i <= n; ++i) {
            cin >> p[i];
        }
        int ans = 0;
        for (int i = 1; i <= n;) {
            if (p[i] == i) {
                if (i == n) {
                    swap(p[i], p[i - 1]);
                    ++ans;
                    ++i;
                } else {
                    swap(p[i], p[i + 1]);
                    ++ans;
                    i += 2;
                }
            }
            else{
                ++i;
            }
        }
        cout<<ans;
    };


    fast_io();
    cout.precision(9);
    cout << fixed;

    solve(1);


}


Measured memory_bytes: 640
from queue import Queue

def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    visited = [False] * N
    visited[0] = True
    p = [1]
    l = []
    r = []

    while(len(p) < N):
        v = p[-1] - 1
        n = A[v] - 1

        if(visited[n]):
            d = p.index(n+1)
            l = p[0:d]
            r = p[d:]
            break

        p.append(A[v])
        visited[n] = True

    if(len(l) == 0 and len(r) == 0):
        print(p[K%len(p)])
    else:
        if(K < len(p)):
            print(p[K])
        else:
            k = K - len(l)
            k %= len(r)
            print(r[k])
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 32172
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

int cmp(void *, void *);
void print_array(char (*A)[3], u32 N);
void bubbleSort(void *A, u32 N, int (*)(void *, void *));
void selectionSort(void *A, u32 N, int (*)(void *, void *));
int checkStable(char (*A)[3], char (*B)[3], u32 N);

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

    u32 n;
    char A[36][3];
    char B[36][3];
    char C[36][3];

    cin >> n;

    char str[3];
    rep (i, n)
    {
        cin >> str;
        strcpy(A[i], str);
        strcpy(B[i], str);
        strcpy(C[i], str);
    }

    bubbleSort((void *)B, n, cmp);
    selectionSort((void *)C, n, cmp);

    print_array((char (*)[3])B, n);
    cout << "Stable\n";
    print_array((char (*)[3])C, n);
    if (checkStable(B, C, n))
    {
        cout << "Not stable\n";
    }
    else
    {
        cout << "Stable\n";
    }

    return 0;
}

int cmp(void *x, void *y)
{
    return ((char *)y)[1] - ((char *)x)[1];
}

void print_array(char (*A)[3], u32 N)
{
    rep (i, N)
    {
        if (i)
        {
            cout << " ";
        }
        cout << A[i];
    }
    cout << "\n";
}

void bubbleSort(void *A, u32 N, int (*comp)(void *, void *))
{
    char (*a)[3] = (char (*)[3])A;
    bool flag = true;
    for (int i = 0; flag; ++i)
    {
        flag = false;
        for (int j = N - 1; j > i; --j)
        {
            if ((*comp)((void *)a[j], (void *)a[j - 1]) > 0)
            {
                swap(*(a + j), *(a + j - 1));
                flag = true;
            }
        }
    }
}

void selectionSort(void *A, u32 N, int (*comp)(void *, void *))
{
    char (*a)[3] = (char (*)[3])A;
    rep (i, N)
    {
        int minj = i;
        for (int j = i; j < N; ++j)
        {
            if ((*comp)((void*)a[j], (void *)a[minj]) > 0)
            {
                minj = j;
            }
        }
        if (minj != i)
        {
            swap(*(a + i), *(a + minj));
        }
    }
}

int checkStable(char (*A)[3], char (*B)[3], u32 N)
{
    rep (i, N)
    {
        if (strcmp(A[i], B[i]))
        {
            return 1;
        }
    }
    return 0;
}



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

int main(){
	string W, text;
	int count = 0;

	cin>>W;
	for(int i=0;i<W.length();i++){
		if(isupper(W[i])) W[i] = tolower(W[i]);
	}

	while(cin>>text && text != "END_OF_TEXT"){
		for(int i=0;i<text.length();i++){
			if(isupper(text[i])) text[i] = tolower(text[i]);
		}

		if(W == text) count++;
	}

	cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 1192
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#include <map>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef unsigned long long Hash;
typedef long long lolong;
inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 100005;
char s[15];
std::map<Hash, int> tot;

int main() {
	int n = input();
	lolong ans = 0;
	for(int i = 1; i <= n; i ++) {
		scanf("%s", s + 1);
		std::sort(s + 1, s + 11);
		Hash now = 0;
		for(int j = 1; j <= 10; j ++)
			now = now * 27 + s[j] - 'a';
		ans += tot[now];
		tot[now] ++;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 6528
#include <cstdio>
#include <utility>
#include <algorithm>
 
using std::scanf;
using std::printf;
using std::max;
using std::min;
using std::pair;
using std::make_pair;
 
template <typename T, typename U>
inline void chmin(T& a,U b){a=min<T>(a,b);}
template <typename T, typename U>
inline void chmax(T& a,U b){a=max<T>(a,b);}
 
typedef int loop_int_;
#define REP(i,n) for(loop_int_ i=0;i<(loop_int_)n;i++)
#define FOR(i,a,b) for(loop_int_ i=(loop_int_)a;i<(loop_int_)b;i++)
#define FORR(i,a,b) for(loop_int_ i=(loop_int_)b-1;i>=(loop_int_)a;i--)
 
#define AL16 __attribute__((aligned(16)))
 
namespace sparse_table{
  const int ST_MAX = 5000;
  const int ST_K = 13;  // 2^12 = 4096 < 5000
  const int ST_2K = 4096;
  unsigned long long st[ST_K][ST_MAX + ST_2K/2];
 
  short mylog[ST_MAX+1];
  void precalc(){
    // mylog[0] = 0;
    mylog[1] = 0;
    FOR(i,2,ST_MAX+1)mylog[i]=mylog[i/2]+1;
  }
 
  inline unsigned long long zip(unsigned int v,unsigned int p){
    return ((unsigned long long)v<<32) | ((unsigned long long)p);
  }
  const int MASK = 4294967295;
  inline void unzip(long long z,unsigned int &v,unsigned int &p){
    v = (unsigned int)(z>>32);
    p = (unsigned int)(z&MASK);
  }
 
  // O(nlogn)
  void init(int n, int *arr){
    REP(i,n)st[0][i] = zip((unsigned int)(arr[i]),(unsigned int)i);
    FOR(i,n,ST_MAX)st[0][i] = 0;
    int base = 1;
    FOR(k,1,ST_K){
      REP(i,ST_MAX)st[k][i] = max(st[k-1][i], st[k-1][i+base]);
      base <<= 1;
    }
  }
  // O(1)
  // [l,r)
  long long rmq(int l,int r){
    int lg = mylog[r-l];
    return max(st[lg][l], st[lg][r-(1<<lg)]);
  }
}
 
int n,m;
long long a[5000];
int b[200][5000];
 
long long imos[5004][5004];
pair<short,short> stack[5000];
int stack_tail;
 
int main(){
  scanf("%d%d",&n,&m);
  REP(i,n-1)scanf("%lld",a+i+1);
  REP(i,n)REP(j,m)scanf("%d",&b[j][i]);
  // REP(i,n-1)a[i+1] = 1;
  // REP(i,n)REP(j,m)b[j][i] = 1;
 
  REP(i,n-1)a[i+1] += a[i];
  
  sparse_table::precalc();
 
  REP(i,m){
    sparse_table::init(n, b[i]);
    stack_tail = 0;
    stack[stack_tail++] = make_pair<short,short>(0,n);
    REP(_,n){
      // printf("stacktail %d\n",stack_tail);
      stack_tail--;
      int l = stack[stack_tail].first;
      int r = stack[stack_tail].second;
      // printf("(l,r) = (%d,%d)\n",l,r);
      unsigned int v,p;
      sparse_table::unzip(sparse_table::rmq(l,r), v, p);
      // printf("(v,p) = (%u,%u)\n",v,p);
      imos[l  ][p] += v;
      imos[p+1][p] -= v;
      imos[l  ][r] -= v;
      imos[p+1][r] += v;
      if(l<p)stack[stack_tail++] = make_pair<short,short>(l,p);
      if(p+1<r)stack[stack_tail++] = make_pair<short,short>(p+1,r);
    }
  }
 
  REP(i,n)FOR(j,max(0,i-1),n)imos[i][j+1] += imos[i][j];
  REP(i,n)FOR(j,max(0,i-1),n)imos[i+1][j] += imos[i][j];
 
  long long ans = 0;
  REP(i,n)FOR(j,i,n)chmax(ans,imos[i][j]-a[j]+a[i]);
  printf("%lld\n",ans);
}

Measured memory_bytes: 121472
#include<bits/stdc++.h>
using namespace std;
long long n,k,i,j,t,book[20];
int main(){
	
	cin>>n>>k;
	for(i=1;i<=k;i++){
		cin>>t;
		book[t]=1;
	}
	for(i=n;i<=1000000;i++){
		long long x=i,f=0;
		while(x!=0){
			if(book[x%10]==1)f=1;
			x/=10; 
		}
		if(f==0){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+50;
typedef long long ll;
int n;
ll a[maxn],dp[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;++i) cin>>a[i];
    dp[1]=1000;
    for(int i=1;i<=n;++i){
        dp[i+1]=max(dp[i],dp[i]/a[i]*a[i+1]+dp[i]%a[i]);
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 3632
### SNIPPET
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

a,b,c = gets.split.map(&:to_i)
k = gets.to_i

count = 0
while a >= b
  b = b * 2
  count += 1
end

while b >= c
  c = c * 2
  count += 1
end

puts count <= k ? "Yes" : "No"

Measured memory_bytes: 14328
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int r = 0;
    long pairs = 0;
    for (int i=0; i<n; i++) {
        long a;
        cin >> a;
        pairs += (a + r) / 2;
        if (a > 0) r = (a + r) % 2;
        else r = 0;
    }
    cout << pairs << '\n';
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

public class Main{

	public static void main(String[] args) {

		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


			String line = br.readLine();
			int N = Integer.parseInt(line);
			line = br.readLine();
			String[] strs = line.split(" ");//区切りで変える
			int A = Integer.parseInt(strs[0]);
			int B = Integer.parseInt(strs[1]);
			line = br.readLine();
			strs = line.split(" ");

			int[] Ps = Stream.of(strs).mapToInt(Integer::parseInt).toArray();
			Arrays.sort(Ps);
			int[] judge_array = new int[3];
			int judge_a = 0;
		    int judge_b = 0;
			int judge_c = 0;

			for(int i = 0;i<N;i++) {
				int judge = Ps[i];

				if(judge<=A) {
					judge_a++;
				}else if(A+1<=judge && judge<=B) {
					judge_b++;
				}else if(B+1<=judge) {
					judge_c++;
				}

			}
			judge_array[0] = judge_a;
			judge_array[1] = judge_b;
			judge_array[2] = judge_c;
			int ans = judge_a;
			for(int i = 0;i<judge_array.length;i++) {
				ans = Math.min(ans, judge_array[i]);

			}

			System.out.println(ans);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}


	}

}


Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
int N,M;
int L,R;
int ans=0;
int main(){
    cin >> N >> M;
    vector<int> le(M+1);
    vector<int> ri(M+1);
    for(int i=0;i<M;i++){
        cin >> le.at(i) >> ri.at(i);
    }
    L=le[0];
    R=ri[0];
    for(int i=0;i<M;i++){
//        if(ri.at(i)>=L || le.at(i)<=R){
            if(L<le.at(i)){
                L=le.at(i);
            }
            if(R>ri.at(i)){
                R=ri.at(i);
            }
        }
//    }
    if(L<=R){
        ans=R-L+1;
    }
    cout << ans;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

    sort(v.begin(), v.end());
    double val = v[0];
    for (int i = 1; i < N; i++) {
        val = (val + v[i])/2;
    }

    cout << fixed << setprecision(5);
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  cin >>N;
  int x=N/15;
  int y=N*800-x*200;
  cout << y<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int> pll;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    string s,t;
    bool valido=true;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            valido=false;
            break;
        }
    }
    if(s.size()+1!=t.size()) valido=false;
    if(valido) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n; cin >> n;
    vll x(n), xcp(n);
    rep(i, n){
        cin >> x[i];
        xcp[i] = x[i];
    }

    sort(all(xcp));
    ll l = xcp[n/2-1];
    ll r = xcp[n/2];

    rep(i, n){
        if(x[i]<xcp[n/2]){
            cout << r << endl;
        }
        else{
            cout << l << endl;
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    string s;
    cin>>n>>m;
    ll ans=-1;

    if(n<10&&m<10){
        ans = n*m;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from math import factorial

n = int(input())
mod = 10**9+7

# if n == 1
# fac = [1]
# for i in range(2, n+2):
#     fac.append(fac[-1]*i % mod)

tens = [1]
for i in range(1, n+2):
    tens.append(tens[-1]*10 % mod)
nines = [1]
for i in range(1, n+2):
    nines.append(nines[-1]*9 % mod)
eights = [1]
for i in range(1, n+2):
    eights.append(eights[-1]*8 % mod)


# ans = 10**n - 8**n - (9**n-8**n)*2
ans = tens[n] - eights[n] - (nines[n]-eights[n])*2


print(ans % mod)


Measured memory_bytes: 127648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            String s = in.next();
            if (s.charAt(a) != '-') {
                out.println("No");
                return;
            }
            String[] split = s.split("-");
            if (split.length != 2 || split[0].length() != a || split[1].length() != b) {
                out.println("No");
                return;
            }
            out.println("Yes");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,R;cin >> n >> m >> R;
	vector<int> r(R);
	rep(i,R){
		cin >> r.at(i);
		r.at(i)--;
	}
	struct edge{
		int to, cost;
	};
	int inf = 1000000000;
	vector<vector<int>> g(n,vector<int>(n,inf));
	rep(i,m){
		int a,b,c;cin >> a >> b >> c;
		a--;b--;
		g[a][b] = c;
		g[b][a] = c;
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
	int ans = inf;
	vector<int> a(R);
	rep(i,R) a.at(i) = i;
	do{
		int sum = 0;
		rep(i,R - 1){
			sum += g[r.at(a.at(i))][r.at(a.at(i + 1))];
		}
		ans = min(ans, sum);
	}while(next_permutation(a.begin(),a.end()));
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

vector<bool> IsPrime(100100,1);

void sieve(size_t max){
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i){ // 0からsqrt(max)まで調べる
        if(IsPrime[i]){ // iが素数ならば
            for(size_t j=2; i*j<=max; ++j){ // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
            }
        }
    }
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    sieve(100100);
    vector<int> V(100100,0);
    int Q;cin >> Q;
    REPP(i,1,100100){
        V[i] = V[i-1];
        if(i % 2 == 0) continue;
        int A = (i + 1)/2;
        if(IsPrime[i] && IsPrime[A]) V[i]++;
      //cout << i << ' ' << IsPrime[i] << ' ' << IsPrime[A]<< endl;
    }
    REP(i,Q){
        int l,r; cin >> l >> r;l--;
        cout << V[r] - V[l] << endl;
    }
}

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

int n;

struct az
{
	int a;
	int b;
}q[200005];

bool cmp(az x , az y)
{
	return x.b < y.b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	   scanf("%d%d",&q[i].a,&q[i].b);
	long long now=0;
	sort(q+1,q+1+n,cmp);
	for(int i=1;i<=n;++i)
	{
		now+=q[i].a;
		if(now > q[i].b ) 
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 5304
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char> > c(h, vector<char>(w));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> c[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << h); ++i) {
    for (int j = 0; j < (1 << w); ++j) {
      vector<vector<char> > copy = c;
      for (int y = 0; y < h; ++y) {
        for (int x = 0; x < w; ++x) {
          if ((i >> y) & 1 || (j >> x) & 1) {
            copy[y][x] = '.';
          }
        }
      }
      int cnt = 0;
      for (int y = 0; y < h; ++y) {
        for (int x = 0; x < w; ++x) {
          if (copy[y][x] == '#') cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;
#define N 3030
int i,l,n;
long long v[N],a[N][N][2],x,y,z,t;
int main()
{
    cin >> n;
    for (i = 0; i < n; ++i)
        cin >> v[i];
    for (i = 0; i < n; ++i)
        a[i][i][n & 1] = v[i];
    for (l = 1; l < n; ++l){
        for (i = 0; i + l < n; ++i){
            if ((n - l) & 1){
                x = v[i] + a[i + 1][i + l][1];
                y = a[i + 1][i + l][0];
                z = v[i + l] + a[i][i + l - 1][1];
                t = a[i][i + l - 1][0];
                if (x > z){
                    a[i][i + l][0] = y;
                    a[i][i + l][1] = x;
                }
                else{
                    a[i][i + l][0] = t;
                    a[i][i + l][1] = z;
                }
            }
            else{
                x = v[i] + a[i + 1][i + l][0];
                y = a[i + 1][i + l][1];
                z = v[i + l] + a[i][i + l - 1][0];
                t = a[i][i + l - 1][1];
                if (x > z){
                    a[i][i + l][1] = y;
                    a[i][i + l][0] = x;
                }
                else{
                    a[i][i + l][1] = t;
                    a[i][i + l][0] = z;
                }
            }
        }
    }
    cout << a[0][n - 1][1] - a[0][n - 1][0];
    return 0;
}


Measured memory_bytes: 143616
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  string s; cin >> s;
  string a[] = {"abc", "acb", "bac", "bca", "cab", "cba"};
  REP(i, 6){
    if(s == a[i]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

string s;
int dp[1000010][2];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>s;s="0"+s;
	dp[1][0]=0;dp[1][1]=1;
	for(int i=2;i<=s.size();i++){
		int num=s[i-1]-'0';
		dp[i][0]=min(dp[i-1][0]+num,dp[i-1][1]+10-num);
		dp[i][1]=min(dp[i-1][0]+num+1,dp[i-1][1]+10-num-1);
	}
	cout<<dp[s.size()][0]<<endl;
	return 0;
}

Measured memory_bytes: 9160
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        double d = sc.nextInt();
        double n = sc.nextInt();
        double ans = 0;
        
        if(n == 100){
             ans = (n+1)*Math.pow(100, d);
        }else{
            ans = (n)*Math.pow(100, d);
        }
        
        System.out.println((int)ans);

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 32588
import sys
input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10 ** 7)  # NOQA


def dfs(N, a, i, procedure):
    if i == 0:
        return procedure

    for j in reversed(range(1, i+1)):
        if a[j-1] == j:
            l = a[:]
            del l[j-1]
            p = procedure[:]
            p.append(j)
            ret = dfs(N, l, i-1, p)
            if ret is not None:
                return ret
            break


def main():
    N = int(input())
    b = list(map(int, input().split()))

    res = dfs(N, b, N, [])
    if res is None:
        print(-1)
    else:
        print(*res[::-1], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
n = int(input())
a = [0] + list(map(int, input().split()))
ans = [0]*(n+1)
for i in range(n, n//2, -1) : ans[i] = a[i]
for i in range(n//2, 0, -1) :
    tmp = 0
    for j in range(i+i, n+1, i) : tmp += ans[j]
    ans[i] = (tmp+a[i])%2
print(sum(ans))
for i in range(1, n+1) : ans[i] *= i
print(" ".join(map(str, list(filter(lambda x:x!=0, ans)))))

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

int main() {
  string S,T;
  cin >> S >> T;
  long long N,M;
  N=size(S);
  M=size(T);
  vector<long long> c(N-M+1);
  for (long long i=0;i<N-M+1;i++) {
    for (long long j=i;j<i+M;j++) {
      if (S.at(j)!=T.at(j-i)) {
        c.at(i)+=1;
      }
    }
  }
  sort(c.begin(), c.end());
  cout << c.at(0) << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int arr[1000000];
int main()
{
	int n,i,m,j,count;
	long long sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
	}
	sort(arr,arr+n,greater<int>());
	m=n-1;
	sum+=arr[0];
	m--;
	if(m==1)
	sum+=arr[1];
	else if(m>1)
	{
		j=m/2;
		count=m%2;
		for(i=1;i<=j;i++)
		{
			sum=sum+(2*arr[i]);
		}
		if(count==1)
		sum+=arr[j+1];
	}
	printf("%lld",sum);
}

Measured memory_bytes: 4544
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 100000001
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dp[120][1050];
bool my_compare(pair<ll, string> a, pair<ll , string> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         //return a.first < b.first; // 昇順
        return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    int maxi=0,f=0,sum=0,mini=INF;
    string str,str1,str2;
    int i;
    int n;
    int a,b,d,c;
    int e,weight;
    vector<pair<ll,string>> p;
    cin>>str;
    char last='A';
    rep(i,str.length()){
        if(last!=str[i]) {
            sum++;
            if(f==1) last='A';
            else last=str[i];
            f=0;
            }
        else {
            f=1;
            last='A';
            }
        //else i++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
int n, ans;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			for(int k = 1; k <= n; k++) {
				int dd = __gcd(i, j);
				dd = __gcd(dd, k);
				ans += dd;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,mn,ans=1; scanf("%d %d", &n,&mn);
	for(int i=1;i<n;i++){
		int x; scanf("%d",&x);
		if(x<mn){
			ans++;
			mn=x;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    string s;
    cin>>s;
    string ans="No";
    if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0])ans="Yes";
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int down=0;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];

	}
	int count=0;
	for(int i=0;i<n;i++)
	{
	if(a[i]!=(i+1))
		count++;
	}

	//cout<<count<<endl;
	if(count==0||count==2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N, Y;
    cin >> N >> Y;
    for (int i = 0; i <= N; i++)
    {
        if (10000 * i > Y) break;
        for (int j = 0; j <= N - i; j++)
        {
            if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y)
            {
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }
    
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    N = int(input())
    D = defaultdict(int)
    for d in input().split():
        D[int(d)] += 1
    M = int(input())
    T = defaultdict(int)
    for t in input().split():
        T[int(t)] += 1
    
    for diff,num in T.items():
        if D[diff]>=num:
            pass
        else:
            print("NO")
            exit()
    print("YES")

    

if __name__ == "__main__":
    main()

Measured memory_bytes: 126932