akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll a, b, k;

void solve()
{
    cin >> a >> b >> k;
    if (k<=a) cout << a-k << " " <<  b << endl;
    else if (k <= a+b) cout << 0 << " " << b - (k-a) << endl;
    else cout << 0 << " " << 0 << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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


int main()
{
     int A, B;
     cin>>A>>B;
     if(A == 1) A = A + 13;
     if(B == 1) B = B + 13;

    if(A == B) cout<<"Draw"<<endl;
    if(A > B) cout<<"Alice"<<endl;
    if(A < B) cout<<"Bob"<<endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    string s; cin >> s;
    bool flag = 1;
    REP(i, a) if(s[i] == '-') flag = 0;
    if(s[a] != '-') flag = 0;
    FOR(i, a + 1, a + b + 1) if(s[i] == '-') flag = 0;
    cout << (flag ? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
N = int(input())
A = list(map(lambda x: int(x) - 1, input().split()))
C = [0] * N
for a in A:
    C[a] += 1


def comb(n):
    if n <= 1:
        return 0
    else:
        return n * (n - 1) // 2


t = sum(list(map(comb, C)))
for a in A:
    print(t - comb(C[a]) + comb(C[a] - 1))


Measured memory_bytes: 32076
import numpy as np


n = int(input())
a = n*[0]
b = n*[0]
c = n*[0]
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())

dp = np.zeros((n, 3))
dp[0] = a[0], b[0], c[0]

for i in range(1, n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i]
    dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i]
ans = max(dp[-1])
print(int(ans))



Measured memory_bytes: 27704
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	ll h,w,n;
	cin >> h >> w >> n;
	cout << min((h+n-1)/h,(w+n-1)/w) << endl;
	return 0;
}


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

int main(){
    int s[4];
    cin >> s[0] >> s[1] >> s[2] >> s[3];

    int cnt1=0;
    int cnt2=0;
    int cnt3=0; 
    int cnt4=0;

    for(int i = 0; i < 4; i++) {
        if(s[i] == 1) {
            cnt1++;
        } else if (s[i] == 9) {
            cnt2++;
        } else if (s[i] == 7) {
            cnt3++;
        } else if (s[i] == 4) {
            cnt4++;
        }
    }

    if(cnt1 == 1 && cnt2 == 1 && cnt3 == 1 && cnt4 == 1) {
        cout <<  "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}  

Measured memory_bytes: 256
A, B = map(int, input().split())
A -= 1
B -= 1

print('100 100')

ans = [['#' for i in range(100)] for j in range(100)]
for i in range(1, 99):
    for j in range(50, 99):
        ans[i][j] = '.'

i = 3
j = 3
while A > 0:
    ans[i][j] = '.'
    A -= 1
    i += 2
    if i > 93:
        i = 3
        j += 2

i = 3
j = 53
while B > 0:
    ans[i][j] = '#'
    B -= 1
    i += 2
    if i > 93:
        i = 3
        j += 2

for s in ans:
    print(''.join(s))


Measured memory_bytes: 3188
a,b,c=map(int,input().split())

N5=0
N7=0

if a==5:
  N5 +=1
elif a==7:
    N7 +=1

if b==5:
  N5 +=1
elif b==7:
    N7 +=1
    
if c==5:
  N5 +=1
elif c==7:
    N7 +=1
    
if (N5==2)*(N7==1):
  print('YES')
else:
    print('NO')


Measured memory_bytes: 9068
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int N;
map<int,vector<int> > toList;
map<int, int> parent;
struct edge{
  int from,to,index,color;
  edge(int a, int b, int i, int c):from(a),to(b),index(i),color(c){};
};
vector<edge> edges;
map<pii,int> color;

void input(){
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N;
  REP(i,N-1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    toList[a].push_back(b);
    parent[b] = a;
    edges.emplace_back(a,b,i,0);
  }
}

int K=0;

void bfs(int x){  
  int col=1;
  for(auto node:toList[x]){
    if(color[make_pair(parent[x],x)]==col) col++;
    color[make_pair(x,node)] = col;
    K = max(K,col);
    col++;
    bfs(node);
  }
}

int solve(){
  input();
  parent[0] = -1;
  bfs(0);
  cout << K << endl;
  for(auto elem:edges){
    cout << color[make_pair(elem.from,elem.to)] << endl;
  }

  return 0;
}

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


Measured memory_bytes: 22384
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  double s = (a+b+c)/2;
  double v = sqrt(s*(s-a)*(s-b)*(s-c));
  cout << v << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string O,E;
int main(){
  cin >> O >> E;
  if(O.size()-E.size()==1){
    for(int i=0;i<O.size()-1;i++){
      cout << O[i] << E[i];
    }
    cout << O[O.size()-1];
  }
  else{
    for(int i=0;i<O.size();i++){
      cout << O[i] << E[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int m,n,x=0,i,j;
    long int a[4];
    cin>>n;

    for(i=0;i<4;i++){
            m=n%10;
        a[i]=m;
    n=n/10;
    }
    for(i=0;i<3;i++)
    {
        for(j=i+1;j<4;j++){
            if(a[i]==a[j])
                x=1;
            break;
        }
        if(x==1)break;
    }
    if(x==0)cout<<"Good"<<endl;
    else cout<<"Bad"<<endl;




}


Measured memory_bytes: 256
import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = solve <$> B.words <$> B.getLine >>= print

solve :: [ByteString] -> Int
solve [bs] = let l = B.length bs
                 z = B.length $ B.filter (== '0') bs
                 o = l - z
             in 2 * min z o


Measured memory_bytes: 764
#include <stdio.h>
#define MOD 1000000007
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	long long int sum = 0;
	for(int i=b;i<=a+1;i++)
	{
		long long int min = (long long int)(i-1)*i/2;
		long long int max = (long long int)(2*a-i+1)*i/2;
		sum += (max-min+1), sum%=MOD;
	}
	printf("%lld",sum);
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int f[n];
	f[0] = 0;
	f[1] = abs(h[0]-h[1]);
	for(int i=2; i<n; i++){
		f[i] = min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<f[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main()
{
    long i, n, dt, dx, dy;
    long t[100001], x[100001], y[100001];
    scanf("%ld", &n);
    t[0] = x[0] = y[0] = 0;
    for (i = 1; i <= n; i++)
    {
        scanf("%ld %ld %ld", &t[i], &x[i], &y[i]);
        dt = t[i] - t[i - 1];
        dx = abs(x[i] - x[i - 1]);
        dy = abs(y[i] - y[i - 1]);
        if (dt < (dx + dy))
        {
            printf("No\n");
            return 0;
        }
        if ((dt - dx - dy) % 2 == 1)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

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

int main() {
  char s;
  cin >> s;
  string ans="consonant";
  if (s=='a') {
    ans="vowel";
  } else if (s=='e'){
    ans="vowel";
  } else if (s=='i'){
    ans="vowel";
  } else if (s=='o'){
    ans="vowel";
  } else if (s=='u'){
    ans="vowel";
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353LL;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}

void solve()
{
    double n;
    cin >> n;
    (n >= 30) ? puts("Yes") : puts("No");
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3716
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

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

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

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

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

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

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

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let n = read!(usize);
    let a = read!([i64]);
    let mut map : HashMap<i64,i64> = HashMap::new();
    let mut ans = 0_i64;
    for i in 0..n {
        ans += *map.get(&(i as i64 - a[i])).unwrap_or(&0);
        *map.entry((i as i64 + a[i])).or_insert(0) += 1;
    }
    println!("{}", ans);
}

fn run() {
    solve();
}


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

int main() {
  char c;
  cin >> c;

  char vowel[] = {'a', 'o', 'i', 'u', 'e'};

  bool flag = false;
  for(int i = 0; i < 5; ++i) {
    if (c == vowel[i])
      flag = true;
  }

  cout << (flag ? "vowel" : "consonant") << endl;;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    string s1,s2;
    cin >> s1 >> s2;

    // 0:空、1:縦一個1、2:横２個
    ll ptn_l = 0;
    ll ans = 1;
    REP(i,N){
        int ptn_r = (s1[i]==s2[i]?1:2);
        if(ptn_r==2) i++;

//        cout << ptn_l << ":" << ptn_r << endl;

        if(ptn_l == 0){
            if(ptn_r==1) mulM(ans,3LL);
            else mulM(ans,6LL);
        } else if (ptn_l == 1) {
            if(ptn_r==1) mulM(ans,2LL);
            else mulM(ans,2LL);
        } else {
            if(ptn_r==1) mulM(ans,1LL);
            else mulM(ans,3LL);
        }

        ptn_l = ptn_r;
    }

    pl(ans)

    return 0;
}


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

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

int main() {
  string s;
  cin >> s;
  if (s.size() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  rep(i, s.size()) {
    if (i % 2 == 0 && s[i] == 'h')  {
      continue;
    }
    if (i % 2 == 1 && s[i] == 'i') {
      continue;
    }
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

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

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

typedef unsigned long long ull;
typedef long long ll;

#define F first
#define S second
#define all(x) begin(x), end(x)

using namespace std;

const int mod = 1e9 + 7;

void exec()
{
	int h, w;
	cin >> h >> w;

	vector<vector<char>> grid(h, vector<char>(w));
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			cin >> grid[i][j];

	vector<vector<long>> dp(h, vector<long>(w, 0));
	for (int i = 0; i < h; ++i) {
		if (grid[i][0] == '#') break;
		dp[i][0] = 1;
	}
	
	for (int i = 0; i < w; ++i) {
		if (grid[0][i] == '#') break;
		dp[0][i] = 1;
	}
		

	for (int i = 1; i < h; ++i) {
		for (int j = 1; j < w; ++j) {
			if (grid[i][j] == '#') continue;

			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}

	cout << dp.back().back() << endl;
}

















int main()
{
	exec();

	return 0;
}

Measured memory_bytes: 9088
from functools import reduce
import operator as op

def mapAccumL(f, acc, xs):
    ys = []
    for x in xs:
        (acc, y) = f(acc, x)
        ys.append(y)
    return (acc, ys)

def unfoldl(f, init, finish):
    acc = init
    while not finish(acc):
        acc, y = f(acc)
        yield y

n = int(input().split(' ')[0])
ds_str = input().split(' ')
ds = set(map(int, ds_str))

for m in range(n, 100000):
    mlist = list(unfoldl(lambda acc: (acc//10, acc%10), m, lambda acc: acc == 0))
    if reduce(op.or_, map(lambda x:x in ds, mlist)):
        continue
    else:
        print(m)
        break


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int x,y,a,b,c;

vector<ll> v1,v2,v3;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>x>>y>>a>>b>>c;
    v1.resize(a);
    v2.resize(b);
    v3.resize(c);
    for (int i=0; i<a; i++) {
	cin>>v1[i];
    }
    for (int i=0; i<b; i++) {
	cin>>v2[i];
    }
    for (int i=0; i<c; i++) {
	cin>>v3[i];
    }

    sort(v1.rbegin(), v1.rend());
    v1.resize(x);
    sort(v2.rbegin(), v2.rend());
    v2.resize(y);

    v3.insert(v3.end(), v1.begin(), v1.end());

    v3.insert(v3.end(), v2.begin(), v2.end());

    sort(v3.rbegin(), v3.rend());

    v3.resize(x+y);

    ll ans = 0;
    for (auto x: v3) ans += x;
    out(ans);
  

    return 0;
}


Measured memory_bytes: 5872
N=int(input())
S=input()
T=input()
s=[str(c) for c in (S)]
t=[str(c) for c in (T)]
flag=0
score=N
for i in range (N,2*N):
  flag=0
  for j in range(N+N-i):
    if s[i-N+j]!=t[j]:
      flag=1
  if flag==0:
    score=i
    flag=2
  if flag==2:
    break
if flag==1:
  score=2*N
print(score)

Measured memory_bytes: 3064
/* C - Repsept */

#include <bits/stdc++.h>
using namespace std;

int main(){
  int K, L, ans = -1;
  cin >> K;
  if(K % 2 != 0 && K % 5 != 0){
    if(K % 7 == 0){
      L = 9 * K / 7;
    }else{
      L = 9 * K;
    }
    int num = 10;
    for(int i = 1; ; i++){
      if(num % L == 1){
        ans = i;
        break;
      }
      num = (num % L) * 10;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
const int inf = 1000000000; // 10^9 Ten to the power of nine.
 
 
 
int main(){
 string S;
 cin>>S;
 string x;
 cin>>x;

  x.erase( --x.end() );
  string K =x;
 

  size_t size =S.length();
 
 if(S==x&&size==x.length()){cout<<"Yes";}
else{cout<<"No";}}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n - 1) cin >> c[i];

  int ans = 0;
  rep(i, n) {
    ans += b[a[i] - 1];
    if (i != 0 && a[i - 1] + 1 == a[i]) ans += c[a[i - 1] - 1];
  }

  cout << ans << endl;
}


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

typedef long long ll;
const int N = 2e5 + 10;
ll n, K, a[N], f[N], l, r, ans;

bool cmp(ll a, ll b) {
    return a > b;
}

bool chk(ll lim) {
    ll cnt = 0;
    rep(i, 1, n) {
        cnt += max(0ll, a[i] - lim / f[i]);
    }
    // printf("%lld %lld\n", lim, cnt);
    return cnt <= K;
}

int main() {
    cin >> n >> K;
    rep(i, 1, n) scanf("%lld", &a[i]);
    rep(i, 1, n) scanf("%lld", &f[i]);
    sort(a + 1, a + n + 1);
    sort(f + 1, f + n + 1, cmp);
    rep(i, 1, n) r = max(r, a[i] * f[i]);

    while (l <= r) {
        ll mid = (l + r) >> 1;
        if (chk(mid)) r = mid - 1, ans = mid;
        else l = mid + 1;
    }
    printf("%lld\n", ans);
    return 0;
}
// 最大值最小！最大值最小！最大值最小！

Measured memory_bytes: 3328
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll a,b; cin >> a >> b;
	int r = b%4;
	if(r==0)b=b;
	else if(r==1)b=1;
	else if(r==2)b++;
	else b=0;
	if(a>0){
		a--;
		r = a%4;
		if(r==0)a=a;
		else if(r==1)a=1;
		else if(r==2)a++;
		else a=0;
	}
	cout << ll(a^b) << endl;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
signed main(){
	int a,b,c,d,z;
	cin>>a>>b;
	f(i,a){
		cin>>c;
		int x=c,cnt=0;
		while(x%2==0){
			x/=2;
			cnt++;
		}
		if(i==0)z=cnt;
		else if(z!=cnt){
			puts("0");
			return 0;
		}
		if(i)d=lcm(d,c);
		else d=c;
	}
	cout<<(b+d/2)/d<<endl;
}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  vector< int > d(n);
  for (int i=0; i<n; ++i) cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[n/2]-d[n/2-1] << endl;
  return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> A(n);
  for(int i = 0; i < m; i++) cin >> A.at(i);
  
  for(int i = 0; i < m; i++){
    n -= A.at(i);
    if(n < 0){
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 7228
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

int main(){
    
    int n;
    long cnt = 0, r = 0, g = 0, b = 0;
    cin >> n;
    
    string s;
    cin >> s;
    
    vector<int> v(n,0);
    rep(i,n){
        if(s[i] == 'R'){
            v[i] = 0;
            r++;
        } else if(s[i] == 'G'){
            v[i] = 1;
            g++;
        } else if(s[i] == 'B'){
            v[i] = 2;
            b++;
        }
    }
    
    for(int i = 1; i < n - 1; i++){
        int a = min(i, n - 1 - i);
        
        for(int j = 1; j <= a; j++){
            if(v[i] != v[i-j] && v[i] != v[i+j] && v[i-j] != v[i+j]) cnt++;
        }
    }
    
    long ans = r * g * b - cnt;
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 3148
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

int main(){
    vector<llong> table(26, 0);
    string w;
    cin >> w;
    for(int i=0; i<w.size(); i++){
        table[w[i]-'a'] += 1;
    }
    for(int i=0; i<table.size(); i++){
        if(table[i]%2!=0){
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
    using namespace std;
    #define int long long
    #define endl '\n'
    int count(string s )
    {
         int res=0;
         for(int i=0;i<s.length()-1;i++)
          if(s[i]=='A'&&s[i+1]=='B')
            res++;
        return res;
    }
    signed main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      int res=0;
      int n;
      cin>>n;
      int a,b,ba;
      a=b=ba=0;
      for(int i=0;i<n;i++)
      {
           string s;
           cin>>s;
           res+=count(s);
           if(s[0]!='B'&&s.back()=='A')
            a++;
           if(s[0]=='B'&&s.back()!='A')
            b++;
           if(s[0]=='B'&&s.back()=='A')
            ba++;
      }
      res+=min(a,b)+ba;
      if(a==0&&b==0&&ba>=1)
        res--;
      cout<<res<<endl;
     
    }

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

int main(){
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  s1[0] = toupper(s1[0]);
  s2[0] = toupper(s2[0]);
  s3[0] = toupper(s3[0]);
  cout << s1[0] << s2[0] << s3[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
int h,n;
int sum=0;
int a[200000];
signed main(){
    cin>>h>>n;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	int x,y;
	while(~scanf("%s %s",&x,&y))
	{	
		if( x > y ) printf(">\n");
		if( x < y ) printf("<\n");
		if( x == y ) printf("=\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

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

#include <queue>
#include <set>
#include <stack>
using namespace std;

struct Number{
  vector<int> cand;
  Number(int s, int e){
    for(int i = s; i <= e; i++)
      cand.push_back(i);
  }
  Number(int n){
    cand.push_back(n);
  }
  Number(){}
};

Number operator + (const Number &lhs, const Number &rhs){
  Number ret;
  REP(i,lhs.cand.size()) REP(j,rhs.cand.size()){
    ret.cand.push_back((lhs.cand[i] + rhs.cand[j]) % 256);
    sort(ret.cand.begin(), ret.cand.end());
    ret.cand.erase(unique(ret.cand.begin(), ret.cand.end()), ret.cand.end());
  }
  return ret;
}

Number operator - (const Number &lhs, const Number &rhs){
  Number ret;
  REP(i,lhs.cand.size()) REP(j,rhs.cand.size()){
    ret.cand.push_back((lhs.cand[i] - rhs.cand[j] + 256) % 256);
    sort(ret.cand.begin(), ret.cand.end());
    ret.cand.erase(unique(ret.cand.begin(), ret.cand.end()), ret.cand.end());
  }
  return ret;
}

Number operator * (const Number &lhs, const Number &rhs){
  Number ret;
  REP(i,lhs.cand.size()) REP(j,rhs.cand.size()){
    ret.cand.push_back((lhs.cand[i] * rhs.cand[j]) % 256);
    sort(ret.cand.begin(), ret.cand.end());
    ret.cand.erase(unique(ret.cand.begin(), ret.cand.end()), ret.cand.end());
  }
  return ret;
}

Number operator / (const Number &lhs, const Number &rhs){
  Number ret;
  REP(i,lhs.cand.size()) REP(j,rhs.cand.size()){
    if(rhs.cand[j] == 0) throw 0;
    ret.cand.push_back((lhs.cand[i] / rhs.cand[j]) % 256);
    sort(ret.cand.begin(), ret.cand.end());
    ret.cand.erase(unique(ret.cand.begin(), ret.cand.end()), ret.cand.end());
  }
  return ret;
}

int main(){
  stack<Number> st;
  const int m = getInt();
  map<string, Number> v;

  REP(i,m){
    char buff[256];
    int lb, ub;
    scanf("%s%d%d", buff, &lb, &ub);
    v[buff] = Number(lb, ub);
  }

  const int n = getInt();

  try{
    REP(i,n){
      char buff[256];
      scanf("%s", buff);
      if(v.count(buff)){
        st.push(v[buff]);
      }else if(!isdigit(*buff)){
        const Number rhs = st.top(); st.pop();
        const Number lhs = st.top(); st.pop();
        switch(*buff){
        case '+': st.push(lhs + rhs); break;
        case '-': st.push(lhs - rhs); break;
        case '*': st.push(lhs * rhs); break;
        case '/': st.push(lhs / rhs); break;
        }
      }else{
        int d; sscanf(buff, "%d", &d);
        st.push(d);
      }
    }
    puts("correct");
  }catch(int e){
    puts("error");
  }

  return 0;
}

Measured memory_bytes: 1336
#include <string>
#include <fstream>
#include <streambuf>
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    string s;
    cin>>s;
    string s2=string(s.begin(),s.begin()+4);
    string s3=string(s.begin()+4,s.end());
    cout<<s2<<" "<<s3<<endl;
    
    return 0;
}


Measured memory_bytes: 256
N,D=map(int,input().split())
cnt=0
X=[list(map(int,input().split())) for i in range(N)]
for i in range(N):
    for j in range(i):
        cnt+=(sum((a-b)**2 for a,b in zip(X[i],X[j]))**0.5).is_integer()
print(cnt)

Measured memory_bytes: 3060
a = list(map(int,input().split()))
b = []
ans = 0
cnt = a[1]
for i in range(a[0]):
  c = list(map(int,input().split()))
  b.append(c)
b = sorted(b)
for i in b:
  if cnt == 0:
    break
  ans += i[0]*min(cnt,i[1])
  cnt -= min(cnt,i[1])
print(ans)
    
  
  



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

int main() {
  set<int> a;
  map<int, int> b;
  set<int> c;
  string s;
  int ans = 0;
  bool pre = true;
  while (getline(cin, s)) {
    if (s == "") {
      pre = false;
      continue;
    }
    stringstream ss(s);
    int x; ss >> x;
    if (pre) {
      a.insert(x);
    } else {
      if (a.count(x) > 0) c.insert(x);
    }
    b[x]++;
  }
  for (int x: c) {
    cout << x << ' ' << b[x] << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct
  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m <> i then begin
        let tmp = t.node.(i) in t.node.(i) <- t.node.(m); t.node.(m) <- tmp;
        max_heapify m
      end in
    max_heapify 1;
    ret

  let push x t =
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      if i > 1 && M.compare t.node.(parent i) t.node.(i) < 0 then begin
        let tmp = t.node.(i) in t.node.(i) <- t.node.(parent i); t.node.(parent i) <- tmp;
        doit (parent i)
      end in
    doit t.size
end

module H = MakeBinaryHeap(struct type t = (int * int) let compare x y = snd x - snd y end)

let dijkstra g n =
  let h = H.make 100000 (0, 0) in
  let d = Array.make n max_int in
  let b = Array.make n false in
  d.(0) <- 0;
  b.(0) <- true;
  H.push (0, 0) h;
  let rec duduwa u = function
    | [] -> ()
    | (v, c) :: tl when b.(v) = true || d.(v) <= d.(u) + c -> duduwa u tl
    | (v, c) :: tl ->
      d.(v) <- d.(u) + c;
      H.push (v, -d.(v)) h;
      duduwa u tl
  and doit () =
    if not (H.empty_p h) then begin
      let (u, x) = H.pop h in
      b.(u) <- true;
      if d.(u) >= -x then duduwa u g.(u);
      doit ()
    end in
  doit ();
  d

let rec make_pair acc = function
  | [] -> acc
  | v :: c :: tl -> make_pair ((v, c) :: acc) tl
  | _ -> exit 1

let () =
  let n = read_int () in
  let g = Array.make n [] in
  let rec read i =
    if i < n then
      begin match List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) with
      | u :: _ :: l -> (g.(u) <- make_pair [] l; read (i + 1))
      | _ -> exit 1
      end
  in read 0;
  Array.iteri (fun i e -> Printf.printf "%d %d\n" i e) (dijkstra g n)

Measured memory_bytes: 5068
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import Data.List (sortBy)

main :: IO ()
main = do
  let
    f :: Int -> [Int]
    f = (:) <$> id <*> pure
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  a : as <- sortBy (flip compare) . map unsafeTextToInt . T.words <$> T.getContents :: IO [Int]
  print . sum . (a :) . take (n - 2) . concatMap f $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 32248
#include <bits/stdc++.h>
#define ll long long int
#define Fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

int main() {
    Fast
    
    int n,k; cin>>n>>k;
    int arr[n], dp[n]; for(int &i:arr) cin>>i;
    for(int &i:dp) i=INT_MAX;

    if(n==1) {cout<<0; return 0;}
    if(n==2) {cout<<abs(arr[0]-arr[1]); return 0;}

    dp[0]=0, dp[1]=abs(arr[0]-arr[1]);

    for(int i=0; i<n; i++) {
        for(int j=max(0, i-k); j<=i; j++) {
            dp[i]=min(dp[i], dp[j]+abs(arr[j]-arr[i]));
        }
    }

    cout<<dp[n-1];

}

Measured memory_bytes: 1024
#include <cstdio>

const int MOD=1e9+7;

int cs[200005];
int dp[200005]={1};

void addmod(int& x,int y){
  x=(x+y)%MOD;
}

int main(){
  int N;
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    scanf("%d",&cs[i]);
  }
  for(int i=1;i<=N;i++){
    if(cs[i]!=cs[i-1]){
      addmod(dp[cs[i]],dp[cs[i-1]]);
    }
  }
  printf("%d\n",dp[cs[N]]);
  return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a+b >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21844
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        int flag = 0;
        for(int i=0;i<n;i++){
            int d1 = sc.nextInt();
            int d2 = sc.nextInt();
            if(d1==d2){
                count++;
                if(count==3)flag=1;
            }else{
                count = 0;
            }
        }
        if(flag==1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 36040
#include<stdio.h>
int main(){
  char *w[4]={"dreamer","dream","eraser","erase"};
  char s[100001];
  int i=0,j,k,l;
  scanf("%s",s);
  while(s[i]!='\0'){
    l=k=0;for(j=0;w[l][j]!='\0';j++)k+=w[l][j]==s[i+j];
    if(j==k&&s[i+j]!='a'){l=4;i+=j;}
    l++;
    while(l<4){
      k=0;for(j=0;w[l][j]!='\0';j++)k+=w[l][j]==s[i+j];
      if(j==k){l=5;i+=j;}
      l++;
    }
    if(l==4){printf("NO");return 0;}
  }
  printf("YES");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, L; 
	cin >> N >> L; int S = N * L + (N-1)*N / 2; 
	int mn = 1145141919; int ans = 1145141919; 
	for(int i = 0; i < N; i++){
		if(abs(L+i) < mn){
		    mn = abs(L+i); ans = S - L - i; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=Integer.parseInt(sc.nextLine());
		Integer[] A=Arrays.asList(sc.nextLine().split(" "))
				.stream().map(Integer::valueOf).toArray(Integer[]::new);
		Integer[] B=Arrays.asList(sc.nextLine().split(" "))
				.stream().map(Integer::valueOf).toArray(Integer[]::new);
		Integer[] C=Arrays.asList(sc.nextLine().split(" "))
				.stream().map(Integer::valueOf).toArray(Integer[]::new);
		int result=0;
		for(int i=0;i<N;i++) {
			result+=B[A[i]-1];
			if(i<(N-1)&&A[i+1]==A[i]+1) {
				result+=C[A[i]-1];
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 28500
#!/usr/bin/env python3
N = int(input())
A = list(map(int, input().split()))
cnt = [0]*N
for i in range(N):
    cnt[A[i]-1] += 1
c_sum = 0
for i in range(N):
    c_sum += cnt[i] * (cnt[i]-1) // 2
for i in range(N):
    print(c_sum - cnt[A[i]-1] + 1)

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

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> a((N - 1) >> 1), b((N - 1) >> 1);
  
  for(int i = 1; i <= (N - 1) >> 1; i++){
    a[i - 1] = i;
    b[((N - 1) >> 1) - i] = ((N - 1) >> 1) + i;
  }
  
  if((N ^ 1) & 1){
    for(int i = 0; i < ((N - 1) >> 2); i++){
      ++b[i];
    }
  }
  
  for(int i = 0; i < M; i++){
    cout << a[i] << ' ' << b[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3864
num = gets.to_i
ary = gets.split.map(&:to_i)
 
count = 0
 
for i in 0 .. num-2
 
  min = ary[i]
  min_index = i
 
  for j in i .. num-1
 
    if min > ary[j]
      min = ary[j]
      min_index = j
    end
  end
 
  if ary[i] != ary[min_index]
    ary[i], ary[min_index] = ary[min_index], ary[i]
    count += 1
  end
end
 
(num-1).times{ |j| print "#{ary[j]} "}
print "#{ary[-1]}\n"
puts count


Measured memory_bytes: 6876
import itertools

N, M, X = map(int, input().split())

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

saisyo = float("inf")
for i in itertools.product(range(2), repeat=N):
    a = [0]*M
    gokei = 0
    for j in range(N):
        if i[j] == 1:
            gokei += A[j][0]
            for k in range(1, M+1):
                a[k-1] += A[j][k]
    if min(a) >= X:
        saisyo = min(saisyo, gokei)

print(saisyo if saisyo != float("inf") else -1)

Measured memory_bytes: 9252
#include <iostream>
using namespace std;
int main(){
	bool flag=false;
	char c;
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> c;
		if(c=='Y')flag=true;
	}
	if(flag) cout << "Four" <<endl;
	else cout << "Three" <<endl;
	return 0;
}


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

int main() {
	int N;
	int a[1000000];
	int tmp;
	cin >> N;
	for (int i = 1; i <= N; i++)
		cin >> a[i];
	for (int j = 1; j < N; j++) {
		for(int i =1; i<N; i++)
		if (a[i] < a[i + 1]) {
			tmp = a[i];
			a[i] = a[i + 1];
			a[i + 1] = tmp;
		}
	}
	cout << a[1] - a[N];
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int i = scan.nextInt();
		System.out.println(n - i + 1);
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 35652
N = int(input())
A = list(map(int, input().split()))

ct = 0
flag = 0
while True:
    for i in range(len(A)):
        if A[i] % 2 == 0:
            A[i] //= 2
        else:
            flag = 1
            break
    if flag == 1:
        break
    ct += 1
print(ct)


Measured memory_bytes: 2940
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>

using namespace std;

int n;
long long ans = 0;
const long long N = 1e6 + 5;
const long long mod = 1e9 + 7;
long long fact[3 * N];
long long a[N];
long long ps[N];

void pre()
{
	fact[0] = 1;
	for (long long i = 1; i < N; i++)
	{
		fact[i] = fact[i - 1] * i;
		fact[i] = fact[i] % mod;
	}
}

long long power(long long a, long long b)
{
	if (b == 0)
	{
		return 1;
	}
	long long ans = power(a, b / 2);
	ans = ans * ans;
	ans = ans % mod;
	if (b % 2)
	{
		ans = ans * a;
	}
	ans = ans % mod;
	return ans;
}

long long choose(long long a, long long b)
{
	if (b < 0 || a < b)
	{
		return 0;
	}
	long long ans = fact[a];
	ans = ans * power(fact[b], mod - 2);
	ans = ans % mod;
	ans = ans * power(fact[a - b], mod - 2);
	ans = ans % mod;
	return ans;
}



int main() 
{

	pre();
	cin >> n;
	if (n == 2)
	{
		cout << 1;
		exit(0);
	}
	for (int i = 2; i < n; i++) 
	{
		a[i] = choose(i - 1, n - 1 - i);
		a[i] *= fact[n - i - 1];
		a[i] %= mod;
		a[i] *= fact[i];
		a[i] %= mod;
		a[i] -= ps[i - 1];
		a[i] += mod;
		a[i] %= mod;
		ps[i] = ps[i - 1] + a[i];
		ps[i] %= mod;
		ans += a[i] * i;
		ans %= mod;
	}
	cout << ans << endl;




	

}


Measured memory_bytes: 24832
#include <cstdlib>
#include <iostream>
#include <typeinfo>
//#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int &i : b)
  {
    cin >> i;
  }
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> a.at(i).at(j);
    }
  }

  int ans = 0;

  for (int i = 0; i < n; i++)
  {
    int sum = c;
    for (int j = 0; j < m; j++)
    {
      sum += a.at(i).at(j) * b.at(j);
    }
    if (sum > 0)
    {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    a_lst = list(map(int, input().split()))
    count = 0

    for i in range(N):
        if i % 2 != 0:
            continue

        if a_lst[i] % 2 != 0:
            count += 1

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := scanner.Text()
	fmt.Println(reverse(input))
}


Measured memory_bytes: 1052