akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::iter::{self, Product, Sum};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Deref,
    DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        s: _bytes,
    }
    let r1 = s
        .iter()
        .enumerate()
        .filter(|&(i, c)| (i % 2 == 0) == (*c == b'0'))
        .count();
    let r2 = s
        .iter()
        .enumerate()
        .filter(|&(i, c)| (i % 2 == 0) == (*c == b'1'))
        .count();
    println!("{}", cmp::min(r1, r2));
}


Measured memory_bytes: 4352
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
 
//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;
//---------------------------------------------------FUNCTIONS-------------------------------------------------------
ll dp[100001] ;

void solve(){
	beg(i , 100001) dp[i] = 1e15 ;
	ll n , w ;
	cin >> n >> w;
	ll ar[n][2] ;
	dp[0] = 0 ;
	beg(i , n) cin >> ar[i][0] >> ar[i][1] ;
	beg(i , n){
		for(ll j=1000*n ; j>=0 ; j--){
			if(j>=ar[i][1]){
				if(dp[j-ar[i][1]] != 1e15){
					dp[j] = min(dp[j] , dp[j-ar[i][1]]+ar[i][0]) ;
				}
			}
		}
	} 
	ll ans ;
	for(ll i=1000*n ; i>=0 ; i--){
		if(dp[i]==1e15){
			continue ;
		}
		if(dp[i] <= w){
			ans = i ;
			break ;
		}
	}
	cout << ans ;
}
//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}	

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll dp[20][20], a, b, n, x, y;
  bool ch[20][20];
  while(cin >> a >> b && (a || b)) {
    rep(i, 20) {
      rep(j, 20) dp[i][j] = ch[i][j] = 0;
    }
    cin >> n;
    rep(i, n) {
      cin >> x >> y;
      x--, y--;
      ch[x][y] = true;
    }
    dp[0][0] = 1;
    rep(i, a) {
      rep(j, b) {
        if(ch[i + 1][j] == false) dp[i + 1][j] += dp[i][j];
        if(ch[i][j + 1] == false) dp[i][j + 1] += dp[i][j];
      }
    }
    cout << dp[a - 1][b - 1] << endl;
  }
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ans+=A.at(i)*A.at(j);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3572
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e5 + 42;
int ans[N];
vector<pair<int, int> > g[N];
void dfs(int v, int p) {
  for(auto& x : g[v])
    if(x.fi != p) {
      ans[x.fi] = (ans[v] ^ (x.se % 2));
      dfs(x.fi, v);
    }
}
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int n = 0;

  cin >> n;

  for(int i = 1; i < n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    g[u].pb(mp(v, w));
    g[v].pb(mp(u, w));
  }

  ans[0] = 0;

  dfs(0, -1);

  for(int i = 0; i < n; i++) cout << ans[i] << endl;

  return 0;
}
/*

*/


Measured memory_bytes: 12328
def main():
    from itertools import combinations as c
    while True:
        n,x=map(int,input().split())
        if n==0 and x==0:
           break
        else:
            cnt=0
            for s in c(range(1,n+1),3):
                if sum(s)==x:
                    cnt+=1
            print(cnt)
if __name__=='__main__':
    main()


Measured memory_bytes: 5636
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] a = new int[2][M];
        int[] cnt = new int[N];
        for(int i = 0; i < M; i++){
            a[0][i] = sc.nextInt();
            a[1][i] = sc.nextInt();
            cnt[a[0][i]-1]++;
            cnt[a[1][i]-1]++;
        }
        sc.close();
        for(int i = 0; i < N; i++){
            System.out.println(cnt[i]);
        }
    }
}

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

using namespace std;

bool happy(int d, int n){
    int i = 0;
    while(n % 100 == 0){
        n /= 100;
        i++;
    }
    return i == d;
}


int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20);

    int d, n, ans;
    cin >> d >> n;

    vector<int>v;
    for(int i = 1; v.size() <= n; i++)
        if(happy(d, i))
            v.push_back(i);
    //sort(v.begin(),v.end());

    cout << v[n-1] << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
#define srt(v) sort(v.begin(), v.end())
#define MOD 1000000007
const int INF = 1e9;
const double PI = 3.14159265358979323846;
ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}
ll spow(ll base, ll exp){
	ll ans = 1;
	for(ll i=0;i<exp;i++) ans = ans * base % MOD;
	return ans;
}
ll divide(ll a, ll b){
	return a * spow(b, MOD-2) % MOD;
}
void solve(){
	
}

struct UnionFind {
	vector<int> parent;
	
	UnionFind(int N){
		parent = vector<int> (N, -1);
	}
	int root(int x){
		if (parent[x] < 0) return x;
		return parent[x] = root(parent[x]);
	}
	bool unite(int x, int y){
		int parentA = root(x);
		int parentB = root(y);
		if (parentA == parentB) return false;
		if (parent[parentA] > parent[parentB]) swap(parentA, parentB);
		
		parent[parentA] += parent[parentB];
		parent[parentB] = parentA;
		return true;
		
	}
	int size(int x){
		return -parent[root(x)];
	}
};

int main(){
	//~ load;
	//~ int t;
	//~ cin >> t;
	//~ while(t--){
		//~ solve();
	//~ }
	
	int N, M;
	cin >> N >> M;
	UnionFind uf(N);
	for(int i=0; i<M; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		uf.unite(a, b); // 其实这里是把有关系的号码放在同一组
	}
	int res = 0;
	for(int i=0; i<N; i++){
		res = max(res,  uf.size(i)); // 我们看那个最大的组有多少个号码，我们就可以知道我们要分割成多少组， 因为组跟组之间是没有人和关系的
	}
	cout << res << "\n";
}



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


int main(){
  int y,m,d;
  char c1,c2;
  cin >> y >> c1 >> m >> c2 >> d;
  if(m>4){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
  	int a;
	char s[20];
  	cin>>a;
  	cin>>s;
  	if(a>=3200)
      	for(int i=0;i<=strlen(s)-1;i++)
          	cout<<s[i];
  	else
      	cout<<"red";
 	return 0;
}

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

int n, m[2];
vector<pair<int, int>> E;
int U[2][200010];
int find(int x, int t){ return x==U[t][x] ? x : U[t][x] = find(U[t][x], t); }
void unite(int x, int y, int t){
    x = find(x,t), y = find(y,t);
    if(x!=y) U[t][x] = y;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m[0]>>m[1];
    for(int i=1; i<=n; i++) U[0][i] = U[1][i] = i;
    for(int k=0; k<2; k++){
        for(int i=1; i<=m[k]; i++){
            int u,v; cin>>u>>v;
            unite(u,v,k);
        }
    }
    map<pair<int, int>, int> cnt;
    for(int i=1; i<=n; i++)
        cnt[{find(i,0), find(i,1)}] ++;
    for(int i=1; i<=n; i++) cout<<cnt[{find(i,0), find(i,1)}]<<' ';
    cout<<'\n';
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N,L;
	cin>>N>>L;
	vector<int> v(N);
	int ans = 0;
	int vmin = INF;
	int j = 0;
	rep(i,N){
		v[i] = L+i+1-1;
		ans+=v[i];
		if(abs(v[i])<abs(vmin)){
			vmin = abs(v[i]);
			j = i;
		}
	}
	ans -= v[j];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  char b;
  cin>>b;
  if(b=='A') cout<<'T'<<endl;
  else if(b=='T') cout<<'A'<<endl;
  else if(b=='C') cout<<'G'<<endl;
  else if(b=='G') cout<<'C'<<endl;
}

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


int main(){
    int n;
    int sum=0;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        int c;
        cin >> c;
        a[i]-=c;
    }
    rep(i,n)if(a[i]>=0) sum+=a[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,m,k,a,c[30]={},s=0,i,j;

	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&k);
		while(k--){
			scanf("%d",&a);
			c[a-1]++;
		}
	}
	for(i=0;i<m;i++)
		if(c[i]==n)
			s++;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

long long N, M, K,a,b,c,d,e,g,mi;
long long ans[3];
long long A[200001];
long long total[200001];
bool f[601][601];
string S;
set <long long>sll;
vector <long long>vll;
typedef pair<long long, long long> pl;
pl buf;

long long summ(long long x, long long y) {
	long long l, ll;
	l = total[y];
	ll = total[x];
	return l-ll;
}

int main() {
	cin >> N;
	total[0] = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i+1];
		total[i+1] = total[i] + A[i+1];

	}

	a = 1;
	if (N == 4) {
		ans[0] = max(max(summ(0, 1), summ(1, 2)), max(summ(2, 3), summ(3, 4)));
		ans[1] = min(min(summ(0, 1), summ(1, 2)), min(summ(2, 3), summ(3, 4)));
		ans[2] = abs(ans[0] - ans[1]);
	}
	else {
		for (int i = 2; i < N - 1; i++) {
			if (i == 2) {
				d = summ(i, 3);
				e = summ(3, N);
				mi = abs(d - e);

				for (int j = 4; j < N; j++) {
					d += A[j];
					e -= A[j];
					if (abs(d - e) <= mi) {
						mi = abs(d - e);
					}
					else {
						g = j - 1;
						break;
					}
				}
			}
			else {

				d = summ(0, a);
				e = summ(a, i);
				mi = abs(d - e);
				while (a < i - 1) {
					a++;
					d += A[a];
					e -= A[a];
					if (abs(d - e) <= mi) {
						mi = abs(d - e);
					}
					else {
						a -= 1;
						break;
					}
				}

				d = summ(i, g);
				e = summ(g, N);
				mi = abs(d - e);
				while (g < N) {
					g++;
					d += A[g];
					e -= A[g];
					if (abs(d - e) <= mi) {
						mi = abs(d - e);
					}
					else {
						g -= 1;
						break;
					}
				}

			}
			ans[0] = max(max(summ(0, a), summ(a, i)), max(summ(i, g), summ(g, N)));
			ans[1] = min(min(summ(0, a), summ(a, i)), min(summ(i, g), summ(g, N)));
			if (i == 2) {
				ans[2] = ans[0] - ans[1];
			}
			else if (ans[2] > ans[0] - ans[1]) {
				ans[2] = ans[0] - ans[1];
			}

		}
	}

	cout << ans[2] << endl;
	

	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

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

    if(abs(a - b) > INF) {
        cout << "Unfair" << endl;
        return 0;
    }

    cout << (k % 2 == 0 ? a - b : b - a) << endl;
    return 0;
}


Measured memory_bytes: 256
S = gets.chomp
T = gets.chomp

len_s = S.length
len_t = T.length

same = 0

0.upto(len_s - len_t){ |i|
  tmp_same = 0
  T.length.times{ |j|
    if S[i+j] == T[j]
      tmp_same += 1
    end
  }
  if tmp_same > same
    same = tmp_same
  end
}

puts (len_t - same)


Measured memory_bytes: 14272
N = int(input())
a = list(map(int,input().split()))
na = nb = nc = 0
for num in a:
	if num % 4 == 0:
		nc+=1
	elif num % 2 == 0:
		nb+=1
	else:
		na+=1
if nb > 0:
	if nc >= na:
		print("Yes")
	else:
		print("No")
if nb == 0:
	if nc >= na-1:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 14608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int n;
char s[N];
stack <int> st;
int main(){
    scanf("%s",s);
    int l=strlen(s);
    for(int i=0;i<l;i++){
        if(!st.empty()){
            int now=st.top();
            if(now!=s[i]-'0') st.pop();
            else st.push(s[i]-'0');
        }else{
            st.push(s[i]-'0');
        }
    }
    int ans = 0;
    while(!st.empty()){
        ans++;
        st.pop();
    }
    cout<<l-ans;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N, D, X;
    cin >> N >> D >> X;
    int Total = X;
    FOR(i, 0, N) {
        int a;
        cin >> a;
        Total += 1 + (D - 1) / a;
    }

    cout << Total << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};

Measured memory_bytes: 256
nums = input()
nums = nums.split()
satu_num = int(nums[0])
sum_money = int(nums[1])

judge = True
count_one = -1
count_two = -1
count_three = -1

for a in range(0,satu_num+1):
  man = 10000*a
  for b in range(0,satu_num+1):
    go_senn = 5000*b
    senn = 1000*(satu_num-a-b)
    if satu_num-a-b<0:
      break
    else:
      ans = man+go_senn+senn
      if ans == sum_money:
        count_one = a
        count_two = b
        count_three = (satu_num-a-b)
        break
      else:
        pass
print(count_one,count_two,count_three)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 100005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(int N, int pos){return (bool)(N & (1<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    ll h;
    cin>>h;
    //ll ans = 1;
    ll cnt = 0;
    while(h>0)
    {
        cnt++;
        h = h / 2;
    }
    //error(cnt);
    cout<<(1LL<<cnt)-1LL<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    cin >> S;
    cout << count( ALL( S ), '1' ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int n; cin >> n;
    vector<ll> As(n);
    rep(i,n) cin >> As.at(i);
    sort(As.begin(), As.end());
    ll ans = 0;
    rep(i,n-1){
        if(i==0){
            ans += As.at(n-1);
        } else {
            ans += As.at(n - 1 - (i + 1) / 2);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}




int main(){
  int n,a,b,c;
  string s;
  cin >> a >> b >> c;
  cout << a+b+c-max(a,max(b,c)) << endl;

  
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> A;
  rep (i, H) {
    string s;
    cin >> s;
    A.push_back(s);
  }

  vector<int> h_ok;
  vector<int> w_ok;

  rep (h, H) {
    bool ok = false;
    rep (w, W) {
      ok |= A[h][w] == '#';
    }
    h_ok.push_back(ok);
  }
  rep (w, W) {
    bool ok = false;
    rep (h, H) {
      ok |= A[h][w] == '#';
    }
    w_ok.push_back(ok);
  }

  rep (h, H) {
    if (!h_ok[h]) continue;
    rep (w, W) {
      if (w_ok[w]) {
        cout << A[h][w];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n,l,g=0,sum=0;
  cin>>n>>l;
  int a[n],i;
  for(i=0;i<n;i++){
    a[i]=l+i;
    if(a[i]==0) g++;
  }
  if(g==0&&a[0]>0){
     for(i=1;i<n;i++){
        sum+=a[i];
     }
  }
 
  if(g==0&&a[0]<0){
    for(i=0;i<n-1;i++){
        sum+=a[i];
    }
  }
  if(g==1){
   for(i=0;i<n;i++){
    sum+=a[i];
   }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
string s;
string t;
int main()
{
    cin>>s>>t;
    if(s.size() != t.size())
    {
        puts("No");
        return 0 ;
    }
    bool flag=false;
    int len=s.size();
    int same = 0;
    int i=0,j=0;
    for(int i=0;i<len;i++)
    {
        if(t[i]==s[0])
        {
            bool temp=true;
            for(int j=i,k=0;k<len;j=(j+1)%len,k++)
            {
                if(t[j]!=s[k])
                {
                    temp=false;
                    break;
                }
            }
            if(temp)
            {
                flag=true;
                break;
            }
        }
    }
    if(flag)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 256
w_min = 5
w_max = 50
shop_infos = [[2, 380, 5, 0.8], [3, 550, 4, 0.85], [5, 850, 3, 0.88]].map {|i|
  {weight: i[0], cost: i[1], bundle_num: i[2], bundle_cost: (i[1] * i[2] * i[3]).to_i}
}

min_costs = Array.new(w_max + 1, 2<<32)
a_range, b_range, c_range = *shop_infos.map {|i| (0..(w_max / i[:weight] + 1)) }
a_range.each {|a|
  b_range.each {|b|
    c_range.each {|c|
      weight = shop_infos.zip([a, b, c]).map {|(i, n)| i[:weight] * n }.reduce(:+)
      break if weight > w_max
      next if weight < w_min
      cost = shop_infos.zip([a, b, c]).map {|(i, n)| (n / i[:bundle_num]) * i[:bundle_cost] + (n % i[:bundle_num]) * i[:cost] }.reduce(:+)
      min_costs[weight] = [min_costs[weight], cost].min
    }
  }
}

until (weight = gets.to_i / 100) == 0
  puts min_costs[weight]
end

Measured memory_bytes: 6120
from collections import deque

H, W = map(int, input().split())

G = []
for i in range(H):
    G.append(list(input()))


move = [[0, 1], [0, -1], [-1, 0], [1, 0]]
saidai = 0
for sy in range(H):
    for sx in range(W):
        if G[sy][sx] == ".":
            queue = deque([[sy, sx]])
            visited = [[-1]*W for i in range(H)]
            visited[sy][sx] = 0
            while queue:
                y, x = queue.popleft()
                for i in move:
                    iy, ix = i[0], i[1]
                    if 0<=iy+y<H and 0<=ix+x<W and G[iy+y][ix+x] =="." and visited[iy+y][ix+x] == -1:
                        visited[iy+y][ix+x] = visited[y][x] + 1
                        queue.append([iy+y, ix+x])
        
            for i in range(H):
                for j in range(W):
                        saidai = max(saidai, visited[i][j])
            queue = []
            visited = [[0]*W for i in range(H)]
print(saidai)

Measured memory_bytes: 3316
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
public class Hello{
    public static void Main(){
        // Your code here!
        //var n = int.Parse(Console.ReadLine());
        var str = Console.ReadLine();
        //var t = Console.ReadLine();
        int ans = 0;
        for(int i = 0; i < str.Length; i++){
            if(str[i] == 'R'){
                ans++;
            }
        }
        if(ans == 0){
            ans = 0;
        }else if(str[1] != 'R'){
            ans = 1;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17536
#include <stdio.h>
#include <math.h>

long max(long, long);
long div(long, long);

int main(){
    long n, t[1000], a[1000], i, r_t[1000], r_a[1000], p;
    
    scanf("%ld", &n);
    for (i=0; i<n; i++){
        scanf(" %ld %ld", &t[i], &a[i]);
    }
    
    r_t[0] = t[0]; r_a[0] = a[0];
    for (i=1; i<n; i++){
        p = max(div(r_t[i-1], t[i]), div(r_a[i-1], a[i]));
        r_t[i] = t[i] * p; r_a[i] = a[i] * p;
    }
    
    printf("%ld\n", r_t[n-1] + r_a[n-1]);
    
    return 0;
}

long max(long a, long b){
    return (a > b)? a : b;
}

long div(long c, long d){
    return c / d + (c % d == 0 ? 0 : 1);
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;
use std::collections::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        sa: Chars,
        sb: Chars,
        sc: Chars,
    }
    let mut sa_deq: VecDeque<char> = VecDeque::new();
    let mut sb_deq: VecDeque<char> = VecDeque::new();
    let mut sc_deq: VecDeque<char> = VecDeque::new();
    for i in sa {
        sa_deq.push_back(i);
    }
    for i in sb {
        sb_deq.push_back(i);
    }
    for i in sc {
        sc_deq.push_back(i);
    }

    // let mut turn: char = sa_deq.pop_front().unwrap();
    let mut turn: char = 'a';
    loop {
        if sa_deq.is_empty() && turn=='a' {
            println!("A");
            return;
        }
        if sb_deq.is_empty() && turn=='b' {
            println!("B");
            return;
        }
        if sc_deq.is_empty() && turn=='c' {
            println!("C");
            return;
        }
        match turn {
            'a' => turn = sa_deq.pop_front().unwrap(),
            'b' => turn = sb_deq.pop_front().unwrap(),
            'c' => turn = sc_deq.pop_front().unwrap(),
            _ => return,
        }
    }

}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 28;
const long long MOD = 1000000000 + 7;

int main()
{
	long long n,m;
	cin >> n>>m;
	long long ans=0;
	long long first=min(n,m/2);
	ans=first;
	n-=first;
	m-=first*2;
	//cout << n <<" "<<m<<endl;
	//cout <<ans<<endl;
	if(m>=3){
		ans+=m/4;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  int sum;
  
  if (K < A) {
  	sum = K;
    cout << sum << endl;
    return 0;
  }
  sum = A;
  K -= A;
  if (K < B) {
    cout << sum << endl;
    return 0;
  }
  K -= B;
  sum -= K;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long
#define maxn 1000010
using namespace std ;
struct dy {
    int y , next ;
}A[maxn];
int n , num , cnt , tot, ans ;
int head[maxn] , a[1010][1010] , vis[1010][1010] ;
int in[maxn] , t[maxn] , day[maxn] ;
void add(int u,int v) {
    A[++cnt].y = v ;
    A[cnt].next = head[u] ;
    head[u] = cnt ;
    return ;
}
void topsort() {
    for(int i = 1 ; i <= tot ; i ++) {
        int u = t[i] ;
        for(int j = head[u] ; j ; j = A[j].next) {
            int v = A[j].y ;
            day[v] = day[u] + 1 ;
            in[v] -- ;
            if(!in[v])
                t[++tot] = v ;
        }
    }
    for(int i = 1 ; i <= num ; i ++)
         ans=max(ans,day[i]);
    return;
}
signed main() {
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; i ++) {
        for(int j = 1 ; j < n ; j ++) {
            scanf("%d",&a[i][j]) ;
            if(!vis[i][j]&&!vis[j][i]) 
                vis[i][j] = vis[j][i] = ++num ;
        }
    }
    for(int i = 1 ; i <= n ; i ++) {
        for(int j = 2 ; j < n ; j ++) {
            add(vis[i][a[i][j-1]],vis[i][a[i][j]]);
            in[vis[i][a[i][j]]] ++ ;
        }
    }
    for(int i = 1 ; i <= num ; i ++)
      if(!in[i]) {
        t[++tot] = i ;
        day[i] = 1 ;
      }
    topsort() ;
    if(tot != num) puts("-1");
    else printf("%d\n",ans);
    return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

    int N, L;
    cin >> N >> L;
    vector<int> v(N);
    vector<pair<int, int>> length_idx;
    FOR(i, 0, N) {
        cin >> v[i];
        length_idx.emplace_back(make_pair(v[i], i));
    }

    sort(ALL(length_idx));
    vector<int> t(N);
    FOE(p, length_idx) {
        int idx = p.second;

        int time = L - v[idx];
        int left = 0, right = 0;
        if (idx - 1 >= 0) {
            left = t[idx - 1];
        }
        if (idx + 1 < N) {
            right = t[idx + 1];
        }
        t[idx] = time + max(left, right);
    }

    print(MAX(t));

	return 0;
}


Measured memory_bytes: 4456
#include <cstdio>

typedef long long ll;

ll N;
ll F[100][10];
ll P[100][11];

ll benefit(ll x)
{
  ll res = 0;
  ll with[100] = {};
  for (int t = 0; t < 10; t++) {
    if (x % 2 == 1)
      for (int i = 0; i < N; i++)
	with[i] += F[i][t];
    x /= 2;
  }
  for (int i = 0; i < N; i++)
    res += P[i][with[i]];
  return res;
}

int main()
{
  scanf("%lld", &N);
  for (int i = 0; i < N; i++)
    for (int t = 0; t < 10; t++)
      scanf("%lld", &F[i][t]);
  for (int i = 0; i < N; i++)
    for (int t = 0; t <= 10; t++)
      scanf("%lld", &P[i][t]);

  ll max = benefit(1);
  for (ll x = 2; x < 1024; x++) {
    ll b = benefit(x);
    max = max < b ? b : max;
  }

  printf("%lld\n", max);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define ff first
#define ss second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define pb emplace_back
#define mp make_pair
#define getchar_unlocked getchar
# define TMP template<typename
#ifdef LOCAL 
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
    
    ~debug() { cerr << endl; }
    template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return * this; }
    template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return * this << range(begin(i), end(i)); }
    template < class c, class b > debug & operator <<(pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }};
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cout << name << ": " << arg1 << "\n";}
TMP Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{const char *comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);
}
void in(int &x){
    cin  >> x;
}
#else
inline void in(int &x)
    {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }
inline void uin(ulli &n){
    register ulli c=gc();
    n=0;
    while(c<'0'||c>'9')
    c=gc();
    while(c<='9'&&c>='0'){
    n=n*10+c-'0';
    c=gc();}
}
#endif
/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
    int sum;
    cin >> sum;
    frie(i,1,9){
        frie(j,1,9){
            if(i*j == sum) { cout << "Yes"; return 0;}
        }
    }
    cout << "No";
}















Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
public class Main{
    
    public static boolean keta(int k){
        int ans =0;
        while(k>0){
            k /=10;
            ans++;

        }
        if(ans%2==0){
            return false;

        }
        else{
            return true;
        }
    }
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int [] a = new int [1+2*(k-1)];
        int j = x-k+1;
        for(int i =0;i<1+2*(k-1);i++){
          
            System.out.print(j+" ");
            j++;

        }
        System.out.println();

        
        
    }
   
    
       
    
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(a) cout<<#a<<":"<<a<<endl;
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,k;
int arr[N];
int dp[N];

int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		scanf("%d",arr+i);
	} 
	for(int i=2;i<=n;i++){
		dp[i]=INF;
		for(int j=1;i-j>=1&&j<=k;j++){
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		} 
	}
	cout<<dp[n]<<endl; 
		

	return 0;
}





Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

string s[1002];
lli dp[1002][1002];
int fx[2] = {0,1};
int fy[2] = {1,0};
 int n,m;
lli dfs(int i,int j)
{
    if(i==n-1 && j==m-1)
        return 1;
    if(dp[i][j]!=-1)
        return dp[i][j];
    lli ret = 0;
    for(int k=0;k<2;k++)
    {
        int dx = i+fx[k];
        int dy = j+fy[k];
        if(dx<n && dy<m && s[dx][dy]=='.')
        ret += dfs(dx,dy);
        ret%=mod;
    }
    return dp[i][j] = ret;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    for(int i=0;i<n;i++)
        cin >> s[i];
    mem(dp,-1);
    lli ans = dfs(0,0);
    cout << ans << endl;

    return 0;

}



Measured memory_bytes: 12708
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
 
ll dp[3005][3005][2];
ll v[3005];
bool mark[3005][3005][2];
 
ll f(int l, int r, int p) {
	if(l == r) return v[l];
	if(mark[l][r][p]) return dp[l][r][p];
	mark[l][r][p] = true;
 
	ll ret = max(-f(l+1, r, p^1) + v[l], -f(l, r-1, p^1) + v[r]);
	return dp[l][r][p] = ret;
}
 
int main() {
	int n;
	scanf("%d", &n);
 
	for(int i = 1; i <= n; i++)
		scanf("%lld", &v[i]);
 
	printf("%lld\n", f(1,n,0));
	
    return 0;
}

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

int n, k, a[200005];

int main(){
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }
    for (int i = 0; i + k < n; ++i){
        if (a[i] < a[i + k]) printf("Yes\n");
        else printf("No\n");
    }
}


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

int main() {
	int N;
	char color;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> color;
		if (color == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}


Measured memory_bytes: 256
let step (t1, x1, y1) (t2, x2, y2) =
  if t2-t1 >= Pervasives.abs(x1-x2) + Pervasives.abs(y1-y2) && (t1+t2+x1+x2+y1+y2)mod 2 = 0
  then (t1, x1, y1)
  else -1000000, 0, 0

let () =
  Scanf.scanf "%d\n" @@ fun n ->
  Array.init n (fun _ -> Scanf.scanf "%d %d %d\n" (fun t x y -> t,x,y)) 
  |> Array.fold_left step (0,0,0)
  |> function | -1000000,_,_ -> Printf.printf "No" | _ -> "Yes"
  |> Printf.printf "%s\n"

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

int main()
{
    int x,n,v;
    scanf("%d %d",&x,&n);
    vector<bool> has(102,false);
    for(int i=0;i<n;i++){
        scanf("%d",&v);
        has[v] = true;
    }
    int best = 0;
    for(int i=0;i<=101;i++)
        if(!has[i] && abs(x-i) < abs(x-best))
            best = i;
    printf("%d\n", best);
}


Measured memory_bytes: 3784
D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]
T = [int(input()) for _ in range(D)]

# print(D)
# print(C)
# print(*S,sep='\n')
# print(T)

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i+1
    return 0

score = 0
t = 0
for d in range(D):
    t = T[d] - 1
    # print('t',t)
    O[d][t] = 1
    # print(O)
    dw = 0
    for i in range(26):
        # print('lday',last(d,i))
        dw += C[i]*((d+1) - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
    # print(t+1,end=' ')
    # print(S[d][t],end=' ')
    # print(dw,end=' ')
    print(score)
    # t = (t+1) % 26



Measured memory_bytes: 9664
import java.util.*;
import java.io.*;
class Main
{
  public static void main (String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	int n = Integer.parseInt(br.readLine());
        int[][] arr = new int[n][3];
        for(int i = 0; i < n; i++)
        {
			String[] ss = br.readLine().split("\\s");
          	arr[i][0] = Integer.parseInt(ss[0]);
          	arr[i][1] = Integer.parseInt(ss[1]);
          	arr[i][2] = Integer.parseInt(ss[2]);
      	}
      	int[][] dp = new int[n][3];
      	dp[0][0] = arr[0][0];
      	dp[0][1] = arr[0][1];
      	dp[0][2] = arr[0][2];
      	for(int i = 1; i < n; i++)
      	{
      		dp[i][0] = arr[i][0] + Math.max(dp[i-1][1], dp[i-1][2]);
      		dp[i][1] = arr[i][1] + Math.max(dp[i-1][0], dp[i-1][2]);
      		dp[i][2] = arr[i][2] + Math.max(dp[i-1][0], dp[i-1][1]);
      	}
      	System.out.println(Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2])));
    }
}

Measured memory_bytes: 67712
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
    if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
    for (typename std::vector<T>::const_iterator it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
    std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
    if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
    std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(T N) {
    std::vector<T> vec(N);
    for (typename std::vector<T>::iterator it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
    return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
    for (typename std::vector<T>::iterator it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
    const int N = inputVal<int>();
    vector<int> vec = inputVec<int>(N);

    for (int i = 0; i < N; ++i) {
        const int thisNb = vec[i];
        int j = i -1;
        for ( ; j >= 0; --j) {
            if ( vec[j] > thisNb ) {
                vec[j+1] = vec[j];
            }
            else {
                break;
            }
        }
        vec[j+1] = thisNb;
        outputVec(vec);
    }

}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    return 0;
}


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

int main() {
  int N, K, distance = 0;

  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x < K - x) distance += x * 2;
    else distance += (K - x) * 2;
  }
  cout << distance << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s[3];
  for (int k = 0; k < 3; ++k) cin >> s[k];
  string ret;
  for (int k = 0; k < 3; ++k) {
    ret += s[k][0] - 'a' + 'A';
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 384