akhauriyash/Code-Regression huggingface dataset:
/*
    Created by Rahul Goel.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*******************************************************************************/
using namespace std;
using namespace __gnu_pbds;
template < typename T >
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*******************************************************************************/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
ll mod_sum() { return 0LL; }
template < typename T, typename... Args >
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%MOD + MOD)%MOD; }
/*******************************************************************************/
ll mod_prod() { return 1LL; }
template< typename T, typename... Args >
T mod_prod(T a, Args... args) { return (a * mod_prod(args...))%MOD; }
/*******************************************************************************/
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
/*******************************************************************************/
//.-.. . -. -.- .- .. ... .-.. --- ...- .
/*
    Code begins after this.
*/

ll solve() {
    string str;
    cin >> str;
    if (count(all(str), 'R') == 3) {
        cout << 3 << endl;
    } else {
        if (str[0] == str[1] && str[0] == 'R') {
            cout << 2 << endl;
        } else if (str[2] == str[1] && str[1] == 'R') {
            cout << 2 << endl;
        } else if (count(all(str), 'R') == 1) {
            cout << 1 << endl;
        } else if (count(all(str), 'R') == 2) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}

signed main() {
    fastio;

    ll t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vct vector<ll>
ll n,m;
ll mod=1LL*1000000007;
void deb(string s, ll vl){
  cout<<s<<" : "<<vl<<"\n";
}
void prv(vct v){
  for(ll i=0;i<v.size();i++)cout<<v[i]<<" ";
  cout<<"\n";
}

vct dp;

ll sol(ll s){
  if(s==0)return 1;
  if(s<3)return 0;
  if(dp[s]!=-1)return dp[s];
  ll cr=0;
  for(ll i=3;i<=s;i++){
    cr=(cr+sol(s-i))%mod;
  }
  dp[s]=cr%mod;
  return dp[s];

}

void solve(){
  cin>>n;
  dp.assign(n+1,-1);
  cout<<sol(n)<<"\n";
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll t;
  t=1;
  // cin>>t;
  while(t--){
    solve();
  }
}

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

bool change(string &A,int s,string c){
    int id = s;
    while(id<(int)A.size()){
        if(id+2<(int)A.size() && A.substr(id,3)=="ABC"){
            A.replace(id,3,c);
        }else if(A[id]==c[0]) return false;
        id++;
    }
    return true;
}

int main(){
    cin >> S;
    bool ok = true;
    while(true){
        if(S.size()<=2){
            ok = false;
            break;
        }
        if(S.size()==3){
            if(S=="ABC") break;
            else{
                ok = false;
                break;
            }
        }
        string T = S;
        bool update = false;
        if(S.substr(0,3)=="ABC"){
            ok = change(T,0,"A");
            update = true;
        }else if(S.substr(S.size()-3,3)=="ABC"){
            ok = change(T,0,"C");
            update = true;
        }else{
            for(int i=1;i<S.size()-3;i++){
                if(S.substr(i,3)=="ABC"){
                    ok = change(T,0,"B");
                    update = true;
                    break;
                }
            }
        }
        if(!update){
            ok = false; break;
        }
        S = T;
        if(!ok) break;
    }
    cout << (ok? "Yes":"No") << endl;
}


Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		int sum = 1;
		for (int i = 0; i < n; i++) {
			if (sum > k) {
				sum += k;
			} else {
				sum *= 2;
			}
		}
		System.out.println(sum);


	}

}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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...);
}


bool fr(int z, int a[10]){
	
	int r;
	while(z){
		r=z%10;
		if(a[r]) return true;
		z/=10;
	}
	return false;
}
int f(int z,int a[10]){
	int ans=z;
	while(fr(ans,a)) ans++;
	return ans;
}


int main(){
	int n,k,x;
	int a[10]={0,0,0,0,0,0,0,0,0,0};
	cin >> n >> k;
	FOR(i,k){ 
		cin >> x;
		a[x]++;	
	}
	cout << f(n,a);

	return 0;
}

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;

  vector<int> vec;

  for (int i = 1; i <= min(A, B); i++){
    if (A % i == 0 && B % i == 0){
      vec.push_back(i);
    }
  }

  cout << vec.at(vec.size() - K) << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
const ll mod = 998244353;
int main() {
    ios::sync_with_stdio(0);
    int n;
    map<string,int>mp;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size()<<endl;
    return 0;
}


Measured memory_bytes: 19184
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) repi(i, 0, n)
#define rep1(i, n) repi(i, 1, n + 1)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)

typedef long long ll;

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

Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    mcf_graph<int, int> g(n * m + 2);
    int tmp = 0;
    rep(i, n) {
        rep(j, m) {
            if(s[i][j] != '#') {
                if(j > 0)
                    g.add_edge(i * m + j - 1, i * m + j, 100, 0);
                if(i > 0)
                    g.add_edge((i - 1) * m + j, i * m + j, 100, 0);
            }
            if(s[i][j] == 'o') {
                tmp += n + m - i - j - 2;
                g.add_edge(n * m, i * m + j, 1, 0);
            }
            g.add_edge(i * m + j, n * m + 1, 1, n + m - i - j - 2);
        }
    }
    cout << tmp - (g.flow(n * m, n * m + 1)).second << endl;
    return 0;
}


Measured memory_bytes: 4156
// 解説
// 先手は、葉の隣にある頂点を優先的に選んで塗る
// すると、後手は、葉を塗らざるをえない
// この戦略で先手が負ける場合、先手は他の戦略をとっても負ける

#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

vector<set<int>> edges;
vector<int> degrees;
vector<int> degree_ones;
vector<int> deleted;

void delete_v(int v, vector<int>& new_degree_ones) {
    for (auto v_nei: edges[v]) {
        edges[v_nei].erase(v);
        degrees[v_nei] -= 1;
        if (degrees[v_nei] == 1) {
            new_degree_ones.pb(v_nei);
        }
    }
    edges[v].clear();
    degrees[v] = 0;
    deleted[v] = 1;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;

    edges.resize(N);
    degrees.resize(N);
    deleted.resize(N);

    REP(n,N-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        edges[a].insert(b);
        edges[b].insert(a);
        ++degrees[a];
        ++degrees[b];
    }

    REP(i, N) {
        if (degrees[i] == 1) {
            degree_ones.pb(i);
        }
    }
    
    while(SIZE(degree_ones) > 0) {
        vector<int> new_degree_ones;
        vector<int> dummy;
        for(auto i: degree_ones) {

            // 頂点を消す過程で次数が1でなくなるかもしれないので毎回チェックする
            if (degrees[i] != 1) continue;

            auto j = *edges[i].begin();

            delete_v(i, dummy);

            // cout << "-----------" << endl;
            // cout << i << " is deleted." << endl;
            // REP(i, N) {
            //     cout << "degrees of " << i << ": " << degrees[i] << endl;
            // }

            delete_v(j, new_degree_ones);

            // cout << "-----------" << endl;
            // cout << j << " (pair of i) is deleted." << endl;
            // REP(i, N) {
            //     cout << "degrees of " << i << ": " << degrees[i] << endl;
            // }

            // cout << "now new_degree_ones size:" << SIZE(new_degree_ones) << endl;
            // for(auto v : new_degree_ones) cout << v << ",";
            // cout << endl;
        }

        degree_ones = new_degree_ones;
    }

    REP(i, N) {
        if (deleted[i] == 0) {
            cout << "First" << endl;
            return 0;
        }
    }
    cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long 
#define MAX 2020
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf =  2*pow(10,9);
ll modulo = pow(10,9) + 7;



ll recurs(string& k, ll ind, ll need, ll d, vector<vector<ll> >& dp){
	ll len = (ll)k.length() - 1 - ind;
	if(len < (ll)0)
		return (need == 0);
	ll sum = 0;
	for(ll i = 0; i<(k[ind]-'0'); i++){
		sum+=dp[len][((need-i)%d + d)%d];
//		cout<<"we added "<<dp[len][((need-i)%d + d)%d]<<endl;
		sum%=modulo;
	}
//	cout<<"sum for now at "<<ind<<" "<<sum<<endl;
	need = ((need-(k[ind]-'0') )%d + d)%d;
	sum+=recurs(k, ind+1, need, d, dp);
	sum%=modulo;
	return sum;
}

void deal(){
	string k;
	ll d;
	cin>>k>>d;
	ll n = k.length() + 3;
	vector<vector<ll> > dp(n,vector<ll>(d,0) );
	dp[0][0] = 1;
	for(ll i = 1;i<n; i++){
		for(ll j =1; j<10; j++){
			fork(d){
				ll ind = (k+j)%d;
				dp[i][ind]+=dp[i-1][k];
				dp[i][ind]%=modulo;
			}
		}
		fork(d)
			dp[i][k]+=dp[i-1][k], dp[i][k]%=modulo;
	}
//	cout<<"we here "<<endl;
	cout<<(recurs(k, 0, 0, d, dp)+modulo-1)%modulo<<endl;
	
//	cout<<"yay "<<endl;
}

int main()  
{
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
} 









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

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

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

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

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

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

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

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

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

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

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

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

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

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

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"5 3 2"# => "NO",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }

    if i64::abs(a - c) <= d || (i64::abs(a - b) <= d && i64::abs(b - c) <= d) {
        "Yes"
    } else {
        "No"
    }.to_string()
}

Measured memory_bytes: 4352
#include <iostream>
#include <set>
#include <queue>
using namespace std;
int N;
int H[16],W[16];
int ne[16][7][7] = {};
int ok[16][7][7][3] = {};
int dist[1<<16] = {};
char C[7][7];

bool in(int x,int y){
    return 3<=x && x<=6 && 3<=y && y<=6;
}

int to_line(int x,int y){
    return 4*(x-3)+(y-3);
}

int main(){
   cin >> N;
   for(int i=0;i<N;i++) cin >> H[i] >> W[i];
   for(int i=3;i<7;i++){
      for(int j=3;j<7;j++){
         cin >> C[i][j];
      }    
   }
   for(int i=0;i<7;i++){
      for(int j=0;j<7;j++){
         for(int k=0;k<N;k++){
            ne[k][i][j] = -1;
            for(int l=0;l<3;l++) ok[k][i][j][l] = 0;
            int T = (1<<16)-1;
            for(int r=0;r<H[k];r++){
               for(int c=0;c<W[k];c++){
                  if(in(i+r,j+c)){
                     T ^= (1<<to_line(i+r,j+c));
                     if(C[i+r][j+c]=='R'){ok[k][i][j][1] ^= (1<<to_line(i+r,j+c)); ok[k][i][j][2] ^= (1<<to_line(i+r,j+c));}
                     if(C[i+r][j+c]=='B'){ok[k][i][j][0] ^= (1<<to_line(i+r,j+c)); ok[k][i][j][2] ^= (1<<to_line(i+r,j+c));}
                     if(C[i+r][j+c]=='G'){ok[k][i][j][1] ^= (1<<to_line(i+r,j+c)); ok[k][i][j][0] ^= (1<<to_line(i+r,j+c));}
                  }
               }
            }
            ne[k][i][j] = T;
         }
      }
   }
   for(int i=0;i<(1<<16);i++) dist[i] = -1;
   dist[(1<<16)-1] = 0;
   queue<int> Q;
   Q.push((1<<16)-1);
   while(!Q.empty()){
      int S = Q.front(); Q.pop();
      for(int i=0;i<7;i++){
         for(int j=0;j<7;j++){
            for(int k=0;k<N;k++){
               for(int l=0;l<3;l++){
                  if((ne[k][i][j]==(1<<16)-1) || (S & ok[k][i][j][l])!=0) continue;
                  int T = (S & ne[k][i][j]);
                  if(dist[T]==-1){
                     dist[T] = dist[S]+1;
                     Q.push(T);
                  }
               }
            }
         }
      }
   }
   cout << dist[0] << endl;
}


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

using namespace std;


#define rep(i,m,n) for(int i=m;i<n;i++)

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

const ll inf=1000000000000000;
 struct edge{ll to,cost;};

void dijkstra(ll s,vector<vector<edge>> &G, vector<ll> &d){
priority_queue<P,vector<P>,greater<P>> que;
d[s]=0;
que.push(P(0,s));
while(!que.empty()){
 P p=que.top(); que.pop();
ll v=p.second;
if(d[v]<p.first) continue;
for(int i=0;i<G[v].size();i++){
 edge e=G[v][i];

if(d[e.to]>d[v]+e.cost){
d[e.to]=d[v]+e.cost;
que.push(P(d[e.to],e.to));
}
}
}
}
  
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n,m,s,t;
  cin >> n >> m >> s >> t;
  s--;
  t--;
  vector<vector<edge>> G(n),H(n);
  
  rep(i,0,m){
   ll u,v,a,b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
   G[u].push_back(edge{v,a});
   G[v].push_back(edge{u,a});
   H[u].push_back(edge{v,b});
   H[v].push_back(edge{u,b});
  }
  
  vector<ll> d(n,inf),e(n,inf);
  dijkstra(s,G,d);
  dijkstra(t,H,e);
  

  
  vector<ll> res(n);
    res[n-1]=d[n-1]+e[n-1];
  for(int i=n-2;i>=0;i--) res[i]=min(res[i+1],d[i]+e[i]);
  
  rep(i,0,n) cout << inf-res[i] << endl;
}


Measured memory_bytes: 19016
H, W = map(int, input().split())

s = [list(map(lambda c: c == "#", input())) for _ in range(H)]
for h in range(H):
    for w in range(W):
        if s[h][w] \
                and (h == 0 or not s[h - 1][w]) \
                and (h == H - 1 or not s[h + 1][w]) \
                and (w == 0 or not s[h][w - 1]) \
                and (w == W - 1 or not s[h][w + 1]):
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		System.out.println(N % 500 <= A ? "Yes" : "No");
	}
}


Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal[] inputLongArray = Console.ReadLine().Split(' ').Select(i => decimal.Parse(i)).ToArray();
            decimal A = inputLongArray[0];
            decimal B = inputLongArray[1];
            Console.WriteLine(Math.Floor(A*B));
        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();


Measured memory_bytes: 28260
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def X(): return list(input())
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

a = L()
b = "".join(a)
b = int(b)
for i in range(1000):
    if b == i**2:
        print("Yes")
        sys.exit()

print("No")


Measured memory_bytes: 10020
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
    int x = 0, f = 1, c = getchar();
    for (; !isdigit(c); c = getchar())
        if (c == '-')
            f = -1;
    for (;  isdigit(c); c = getchar())
        x = x * 10 + c - '0';
    return x * f;
}

const int MAXN = 1000005;
const int mod = 998244353;

int n, m, ans, sum, fac[MAXN], inv[MAXN];

inline int C(int n, int m)
{
    return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
#ifdef wxh010910
    freopen("data.in", "r", stdin);
#endif
    n = Read(), m = Read();
    if (n < m)
        swap(n, m);
    ans = n;
    fac[0] = fac[1] = inv[0] = inv[1] = 1;
    for (int i = 2; i <= n + m; i ++)
        fac[i] = 1LL * fac[i - 1] * i % mod, inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
    for (int i = 2; i <= n + m; i ++)
        inv[i] = 1LL * inv[i] * inv[i - 1] % mod;
    for (int i = 1; i <= m; i ++)
        sum = (1LL * C(i << 1, i) * C(n + m - (i << 1), n - i) + sum) % mod;
    return printf("%d\n", (1LL * sum * inv[2] % mod * inv[n + m] % mod * fac[n] % mod * fac[m] + ans) % mod), 0;
}

Measured memory_bytes: 8064
W, H, N = map(int, input().split())

x_lt = 0
x_rt = W

y_lt = 0
y_rt = H

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x_lt = max(x, x_lt)
    elif a == 2:
        x_rt = min(x, x_rt)
    elif a == 3:
        y_lt = max(y, y_lt)
    else:
        y_rt = min(y, y_rt)

res = max(x_rt - x_lt, 0) * max(y_rt - y_lt, 0)

print(res)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;

  int domestic = 0, foreign = 0;

  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'c') {
      cout << "No" << endl;
    } else if (s.at(i) == 'a') {
      if (domestic + foreign < a + b) {
        cout << "Yes" << endl;
        domestic++;
      } else {
        cout << "No" << endl;
      }
    } else {
      if (domestic + foreign < a + b && foreign < b) {
        cout << "Yes" << endl;
        foreign++;
      } else {
        cout << "No" << endl;
      }
    }
  }
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	
	n *= 3;
	int a[300100];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	sort(a, a + n);
	
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		n--;
		int y = a[n-1];
		n--;
		ans += y;
	}
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 1536
N = int(input())

tree = {}

for _ in range(N-1):
  A, B, C = [int(i) for i in input().split()]
  if A not in tree:
    tree[A] = []
  if B not in tree:
    tree[B] = []
  tree[A].append((B, C))
  tree[B].append((A, C))


c = {}
q = []
visited = set()

def dfs(a, acc):
  q.append((a, acc))

  while q:
    n, r = q.pop()
    c[n] = r
    visited.add(n)
    for b, cost in ((b, cost) for b, cost in tree[n] if b not in visited):
      q.append((b, cost + r))


Q, K = [int(i) for i in input().split()]
dfs(K, 0)

for _ in range(Q):
  x, y = [int(i) for i in input().split()]
  print(c[x] + c[y])


Measured memory_bytes: 67056
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n,m,q,i,corr=0;
    string s;
    cin>>n>>m;
    int a[n],pen[n];
    memset(a,0,sizeof(a));
    memset(pen,0,sizeof(pen));
    for(i=0;i<m;++i)
    {
        cin>>q>>s;
        if(s == "AC" && a[q-1] == 0)
        {
            ++corr;
            a[q-1] = 1;
        }
        else if(s == "WA" && a[q-1] == 0)
        {
            ++pen[q-1];
        }
    }
    q = 0;
    for(i=0;i<n;++i)
    {
        if(a[i])    q += pen[i];
    }
    cout<<corr<<" "<<q;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ll N = 300005;
const ll M = 100005;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[N] = {}, b[N] = {}, c[N] = {};
        vll v;
        rep(i, 3 * n){
            cin >> a[i];
        }
        sort(a, a + 3 * n);
        rep(i, n, 3 * n){
            ans += a[i], i++;
        }
        print(ans);
    }
}


Measured memory_bytes: 2560
N, X = map(int, input().split())


def f(n):
    # レベルnの総数
    if n == 0:
        return 1
    else:
        return 2 * f(n - 1) + 3


def g(n):
    # レベルnのpの数
    if n == 0:
        return 1
    else:
        return 2 * g(n - 1) + 1


def dfs(n, x):
    # 総数
    m = f(n)
    # 真ん中
    a = (m + 1) // 2

    if n == 0:
        return 1
    elif x == 1:
        return 0
    elif x < a:
        return dfs(n - 1, x - 1)
    elif x == a:
        return g(n - 1) + 1
    elif x >= a:
        return g(n - 1) + 1 + dfs(n - 1, x - a)
    elif x == m:
        return 2 * g(n - 1) + 1


ans = dfs(N, X)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using vvp = vector<vector<P>>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

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

    ll n, m;
    cin >> n >> m;
    vvll e(n, vll(n, inf));
    ll a, b, c;
    REP(i, m) {
        cin >> a >> b >> c;
        e[a][b] = c; // 有向
    }
    vvll d(n, vll(n, inf));
    REP(i, n) {
        d[i][i] = 0;
        REP(j, n) {
            chmin(d[i][j], e[i][j]);
        }
    }

    REP(k, n) {
        REP(i, n) {
            REP(j, n) {
                if (d[i][k] == inf || d[k][j] == inf) continue;
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    REP(i, n) {
        if (d[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    REP(i, n) {
        REP(j, n) {
            if (d[i][j] == inf) cout << "INF";
            else cout << d[i][j];
            if (j != n - 1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3352
import math

K,X=list(map(int,input().split()))
imin = X-K+1
imax = X+K-1
rmin = -1000000
rmax = 1000000
if imin >= rmin and imax <=rmax:
    for i in range(imin,imax+1):
        print(i,end=" ")
elif imin < rmin and imax <=rmax:
    for i in range(rmin,imax):
        print(i,end=" ")
elif imin >= rmin and imax >rmax:
    for i in range(imin,rmax):
        print(i,end=" ")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<int> edges[110];
vector<int> u, v;
int main(){
	int n;
	cin >> n;
	int dist[n][n];
	vector<int> deg(n, 0);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			dist[i][j] = 10000;
		}
		dist[i][i] = 0;
	}
	for(int i = 0; i < n-1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
		dist[a][b] = dist[b][a] = 1;
		deg[a]++; deg[b]++;
		u.push_back(a);
	}
	for(int k = 0; k < n; k++){
		for(int j = 0; j < n; j++){
			for(int i = 0; i < n; i++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	vector<int> maxdist(n, 0);
	int minmaxdist = n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			maxdist[i] = max(maxdist[i], dist[i][j]);
		}
		minmaxdist = min(minmaxdist, maxdist[i]);
	}
	vector<int> cents;
	for(int i = 0; i < n; i++){
		if(maxdist[i] == minmaxdist){
			cents.push_back(i);
		}
	}
	if(cents.size() == 1){
		cout << minmaxdist + 1 << " ";
	} else {
		cout << minmaxdist << " ";
	}
	if(cents.size() == 2){
		// deg - 1 for al;
		vector<int> stuff(minmaxdist, 1);
		LL ans = 1;
		for(int j = 0; j < n; j++){
			int a = min(dist[cents[0]][j], dist[cents[1]][j]);
			stuff[a] = max(stuff[a], deg[j]-1);
		}
		for(int i = 0; i < minmaxdist; i++){
			ans *= stuff[i];
		}
		ans *= 2;
		cout << ans << endl;
		return 0;
	} else {
		int c = cents[0];
		LL best;
		if(1){
			vector<int> stuff(minmaxdist + 1, 1);
			LL ans = 1;
			for(int j = 0; j < n; j++){
				int a = min(dist[c][j], dist[c][j]);
				stuff[a] = max(stuff[a], deg[j] - (a > 0));	
			}
			for(int i = 0; i < minmaxdist; i++){
				ans *= stuff[i];
			}
			best = ans;
		}
		for(int i = 0; i < n; i++){
			if(dist[i][c] == 1){
				vector<int> stuff(minmaxdist, 1);
				LL ans = 1;
				for(int j = 0; j < n; j++){
					int a = min(dist[c][j], dist[i][j]);
					stuff[a] = max(stuff[a], deg[j]-1);
				}
				for(int i = 0; i < minmaxdist; i++){
					ans *= stuff[i];
				}
				ans *= 2;
				best = min(ans, best);
			}
		}
		cout << best << endl;
	}
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

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

	vector<bool> vec(n + 1, false);
	vec[1] = true;

	vector<int> vec2(n + 1 , 1);

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;

		vec2[y] += 1;
		vec2[x] -= 1;

		if (vec[x]) {
			if (vec2[x] == 0) vec[x] = false;
			vec[y] = true;
		}
	}

	int ans = 0;
	for (auto e : vec) {
		if (e)	ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

const ll INF = 1e15;
const int MAX_V = 1e5;
const int MAX_E = 1e5;
struct edge{
    int to;
    ll c;
    edge(int _t, ll _c){
        to = _t;
        c = _c;
    };
};

vector<edge> g[MAX_V];
vector<bool> check(MAX_V,false);
vector<ll> dis(MAX_V,INF);

//深さ優先探索を利用する
void dfs(int s){
   // if(check[s])return;
    check[s] = true;
/*
現在iへの最小移動コスト
sへの最小移動コスト + s->iへの移動コストを比べる
*/
    rep(i,g[s].size()){
        if(dis[g[s][i].to] > g[s][i].c + dis[s]){
            dis[g[s][i].to] = g[s][i].c + dis[s];
            dfs(g[s][i].to);
        }
    }
}

int main(){
    int n;
    cin >> n;
    int a,b;
    ll c;
    rep(i,n-1){
        cin >> a >> b >> c;
        a--;b--;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }

    int q,k;
    cin >> q >> k;
    k--;
    dis[k] = 0;//初期値
    //dfsを使ってkから各頂点への距離を求めておく
    dfs(k);

    int x,y;
    rep(i,q){
        cin >> x >> y;
        x--;y--;
        cout << dis[x] + dis[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 14336
import java.util.Scanner;
 
class Main{
 
    public static void main(String[] args){
 
        Scanner scanner = new Scanner(System.in);
        String val1 = scanner.next();
        String val2 = scanner.next();
        scanner.close();
        String check = val2.substring(0, val1.length());
        if(check.equals(val1)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
 
}

Measured memory_bytes: 26912
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int M, d;
bool used[102];
int main() {
    M = read(), d = read(); int ans = 0;
    for (reg int m = 1; m <= M; m++) {
        memset(used, 0, sizeof(used));
        for (int i = 2; i <= sqrt(m); i++) {
            if (m % i == 0) {
                if (i + 10 * (m / i) <= d && i < 10 && (m / i) < 10) used[i + 10 * (m / i)] = true;
                if (m / i + 10 * i <= d && i < 10 && (m / i) < 10) used[m / i + 10 * i] = true;
            }
        }
        for (reg int i = 1; i <= d; i++) ans += used[i];
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

bool ex[111111];
int N;
int D[1111];
signed main(){
    cin>>N;
    rep(i,N)cin>>D[i];

    rep(i,N){
        int d=0;
        rep(j,5){
            if(i+j>=N)break;
            d=d*10+D[i+j];
            ex[d]=true;
        }
    }

    rep(i,111111){
        if(!ex[i]){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    //bool ans = true;
    if (s[0] != 'A')
    {
        cout << "WA" << endl;
        return 0;
    }
    int countC = 0;
    int indexC;
    for (int i = 2; i <= len - 2; i++)
    {
        if (s[i] == 'C')
        {
            countC++;
            indexC = i;
        }
    }
    if (countC != 1)
    {
        cout << "WA" << endl;
        return 0;
    }
    else
    {
        for (int i = 1; i < len; i++)
        {
            if (i != indexC && isupper(s[i]))
            {
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    cout << "AC" << endl;
}

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

int N,A,B,C,l[8]={};
long long mpsum,mpmin=9999999999;

void calc(vector<int> v){
    int num[4]={};//使われた回数を確認
        int a=0,b=0,c=0;//a,b,cのmp消費前の竹の長さ
        for(int i=0;i<N;i++){
            num[v[i]]+=1;
            if(v[i]==1)a+=l[i];
            if(v[i]==2)b+=l[i];
            if(v[i]==3)c+=l[i];
        }
        if(num[1]!=0&&num[2]!=0&&num[3]!=0){
            mpsum=(abs(A-a)+abs(B-b)+abs(C-c)+(num[1]+num[2]+num[3]-3)*10);
            if(mpsum<mpmin)mpmin=mpsum;
        }

}
void dfs(int depth,vector<int> v){

    if(depth==N)calc(v);
    else{
        for(int i=0;i<4;i++){
            v[depth]=i;
            dfs(depth+1,v);
        }
    }

}

int main(){
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++)cin>>l[i];
    vector<int> v(8,0);
    dfs(0,v);
    cout<<mpmin<<endl;

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  V<string> res(0);

  auto append = [&](auto self, ll used_ct, ll rest_len, string cur) -> void {
    // f(ll u, ll rest_len, string cur)
    if (rest_len == 0) {
      res.emplace_back(cur);
      return;
    }

    rep(i, used_ct + 1) {
      string next = cur + (char)('a' + i);
      self(self, i == used_ct ? used_ct + 1 : used_ct, rest_len - 1, next);
    }
  };

  append(append, 0, N, "");

  sort(all(res));

  for (auto st : res) {
    cout << st << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 ll n;
  cin>>n;
  ll a[n];
  ll has[n]={0};
  for(ll i=0;i<n;i++)
  {
      cin>>a[i];
  }
    has[0]=0;
    has[1]=abs(a[0]-a[1]);
    for(ll i=2;i<n;i++)
    {
        has[i]=min(has[i-1]+abs(a[i-1]-a[i]),has[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<has[n-1];
  return 0;
}

Measured memory_bytes: 1792
mod = 10**9 + 7
H, W, K = map(int, input().split())
K -= 1
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1

for i in range(H):
    for b in range(1<<(W-1)):
        if '11' in bin(b):
            continue
        b <<= 1
        for k in range(W):
            if b & (1<<k):
                dp[i+1][k] += dp[i][k-1]
            elif b & (1<<(k+1)):
                dp[i+1][k] += dp[i][k+1]
            else:
                dp[i+1][k] += dp[i][k]
            dp[i+1][k] %= mod

print(dp[i+1][K])


Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21660
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <typeinfo>

#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 llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

vector<int> primes;
const static int N = 1000000;
int arr[N];
void Eratosthenes(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 2; i < N; i++){
		if(arr[i]){
            primes.push_back(i);
		}
	}
}

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

    int x;
    cin >> x;
    int pos = lower_bound(primes.begin(), primes.end(), x) - primes.begin();

    cout << primes[pos] << endl;
    return 0;
}

Measured memory_bytes: 4860
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[100001],b[100001],c[100001];
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
  int dp[3][100001];
  dp[0][0]=a[0];
  dp[1][0]=b[0];
  dp[2][0]=c[0];
  for(int i=1;i<n;i++){
    dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
    dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
    dp[2][i]=c[i]+max(dp[0][i-1],dp[1][i-1]);
  }
  cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(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()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
 
template<typename T>
struct is_vector : false_type{};
 
template<typename T>
struct is_vector<vector<T>> : true_type{};
 
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int n; cin >> n;

  string ans;
  ans.resize(2*n, 'x');
  const int red = 0, blue = 1;
  vi pos(2, -1);
  int know;
  vector<P> hist;
  hist.push_back(P(n+1, -1));
  hist.push_back(P(1, -1));

  while (1) {
    int idx = hist.back().first;
    int &color = hist.back().second;
    cout << '?';
    rep(i,n) cout << ' ' << idx+i;
    cout << endl;

    string t; cin >> t;
    if (t == "Red") {
      color = red;
    } else if (t == "Blue") {
      color = blue;
    } else {
      return;
    }

    if (hist.size() == 2) {
      hist.front().second = 1-color;
      pos[1-color] = n+1;
    }

    if (abs(idx-pos[1-color]) == 1) {
      if (idx < pos[1-color]) {
        know = idx;
        ans[idx-1] = color == red ? 'R' : 'B';
        ans[idx-1+n] = 1-color == red ? 'R' : 'B';
      } else {
        know = pos[1-color];
        ans[pos[1-color]-1] = 1-color == red ? 'R' : 'B';
        ans[pos[1-color]-1+n] = color == red ? 'R' : 'B';
      }
      break;
    }

    pos[color] = idx;
    hist.push_back(P((idx+pos[1-color])/2, -1));
  }

  Graph question(2, vi(n-1));
  rep(i,n-1) {
    question[0][i] = know+i+1;
    question[1][i] = know+n+i+1;
    if (question[1][i] > 2*n) question[1][i] -= 2*n;
  }

  rep(i,2) {
    for (auto p : question[i]) {
      cout << '?' << ' ' << know << ' ' << know+n;
      for (auto q : question[i]) {
        if (p != q) cout << ' ' << q;
      }
      cout << endl;

      string t; cin >> t;
      if (t == "Red") {
        ans[p-1] = 'B';
      } else if (t == "Blue") {
        ans[p-1] = 'R';
      } else {
        return;
      }
    }
  }

  cout << "! " << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 724
N = int(input())
if 10<=N<=99:
    print(9)
elif 1000<=N<=9999:
    print(909)
elif N==100000:
    print(90909)
elif 1<=N<=9:
    print(N)
elif 100<=N<=999:
    print(9 + (N-99))
elif 10000<=N<=99999:
    print(909 + (N-9999))


Measured memory_bytes: 2940
// ABC173-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


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

    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    int ans=0;
    rep(b1,(1<<h)){
        rep(b2,(1<<w)){
            int total=0;
            rep(i,h){
                rep(j,w){
                    if(b1>>i&1) continue;
                    if(b2>>j&1) continue;
                    if(a[i][j]=='#') total++;
                }
            }
            if(total==k) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3588