akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

int N;

void solve() {
	long long ans = 0;
	cin >> N;
	vector<int> B;
	B.resize(N);
	for (int n = 0; n < N-1; n++) {
		cin >> B[n];
	}
	ans += B[0];
	for (int n = 1; n < N-1; n++) {
		ans += min(B[n-1],B[n]);
	}
	ans += B[N -2];
	cout << ans << endl;
	return;
}

//////////////////////////////
//////////////////////////////

int main() {
#ifdef DEBUGTIME
	for (int time = 0; time < DEBUGTIME; time++) {
		solve();
		cout << "####################" << endl;
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi R(4,0);
	REP(i, 3) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		R[a]++; R[b]++;
	}
	int I1 = 0, I2 = 0;
	REP(i, 4) {
		if (R[i] == 1)I1++;
		if (R[i] == 2)I2++;
	}
	if (I1 == 2 && I2 == 2)cout << "YES" << endl;
	else cout << "NO" << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#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 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);
};

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

    // Actual program code starts here.
    VEC(int) Terms {1, 1, 1, 2, 1, 2, 1, 5, 2, 2,
        1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 
       2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;
    cout << Terms[--K] << endl;
    return 0;
};

Measured memory_bytes: 256
var  a,b,i,j,k,l:longint;
begin
  readln(a,b);
  if  a<0  then

    if  b>0  then
      begin
        writeln('Zero');
        exit;
      end
             else
      if  (b-a+1) mod 2=0  then
        begin
          writeln('Positive');
          exit;
        end
                           else
        begin
          writeln('Negative');
          exit;
        end

           else
    writeln('Positive');
end.


Measured memory_bytes: 128
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Console.ReadLine();
		var a = Console.ReadLine().Split().Select(int.Parse).ToList();

		int n = a.Max(), h = n / 2;
		a.RemoveAll(x => x == n);
		var r = a.OrderBy(x => x <= h ? x : n - x).Last();
		Console.WriteLine($"{n} {r}");
	}
}


Measured memory_bytes: 22112
#include <iostream>
#include <vector>
#include <list>
#include <string>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector 
#define pb push_back

int main(void)
{
  string s;

  cin >> s;
  if (s.length() == 1) {
    cout << 0 << endl;
    return 0;
  }

  list<char> l;
  rep(i, s.length()) l.pb(s[i]);
  int ans = 0;

  auto it = l.begin();
  while(it != l.end()) {
    char left = *it;
    it++;
    if (it == l.end()) break;
    char right = *it;
    if (left == right) continue;
    ans += 2;
    it--;
    if (it == l.begin()) {
      l.pop_front();
      l.pop_front();
      it = l.begin();
    } else {
      it = l.erase(it);
      it = l.erase(it);
      it--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, M;
    cin >> N >> M;
    vector<ll> cnt(1e5+1, 0);
    Rep (i, 2*M) {
        ll a;
        cin >> a;
        cnt[a]++;
    } 

    for (ll e : cnt) {
        if (e % 2 == 1) {
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

ll dp[101][100010];
ll a[100010][2];
int lim;
int n;

ll f(int pos, ll wt)
{
	if (pos == 0) return a[pos][0] <= wt?a[pos][1]:0;
	ll &ret = dp[pos][wt];
	if (ret != -1) return ret;
	ret = f(pos-1, wt);
	if (a[pos][0] <= wt) ret = max(ret, a[pos][1] + f(pos-1, wt-a[pos][0]));
	return ret;
}

int main(void)
{
	fast;
	#ifndef ONLINE_JUDGE
	// freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
	#endif

	cin >> n;
	ll w; cin >> w;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i][0] >> a[i][1];
	}
	a[n][1] = a[n][0] = 0;
	memset(dp, -1, sizeof dp);
	cout << f(n, w);
}

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

int main(){
  int k;
  string s;
  cin>>k>>s;
  if(k>=s.size()){
  cout<<s<<endl;
  return 0;
  }
  else{
  for(int i=0;i<k;i++){
  cout<<s[i];
  }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1 << 21

//ダイクストラ法
void dijkstra(vector<vector<int> > &graph, int n){

    vector<int> cost(n, INF);
    vector<int> color(n, WHITE);

    cost[0] = 0;
    color[0] = GRAY;
    while(1){
        int minv = INF;
        int u = NIL;    //現在地
        rep(i, n){
            if(cost[i] < minv && color[i] != BLACK){
                minv = cost[i];
                u = i;
            }
        }
        if(u == NIL) break;

        color[u] = BLACK;
        rep(j, n){
            if(color[j] != BLACK && graph[u][j] != NIL){
                if(cost[j] > cost[u] + graph[u][j]){
                    cost[j] = cost[u] + graph[u][j];
                    color[j] = GRAY;
                }
            }
        }
    }

    rep(i, n){
        cout << i << " " << cost[i] << endl;
    }
}

int main() {

    int n;
    cin >> n;
    vector<vector<int> > graph(n, vector<int>(n, INF));
    int k, c, u , v;
    rep(i, n){
        cin >> u >> k; //u 頂点  k 隣接リストの個数
        rep(j, k){
            cin >> v;      //隣接リストの番号
            cin >> graph[u][v]; //隣接リストの重み
        }
    }

    dijkstra(graph, n);

    return 0;
} 


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<LL,LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n>>m>>s;
    for(i=0;i<s;i++)
    {
        cin>>o;
        v[o]++;
    }
    for(i=1;i<=n;i++)
    {
        if(m+(v[i]-s)<=0)
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
    }

}



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

int A, B, C, X;

int main(){
  cin >> A >> B >> C >> X;
  int ans = 0;
  for(int i = 0; i <= A; i++)
    for(int j = 0; j <= B; j++)
      for(int k = 0; k <= C; k++)
        if(X == 500*i+100*j+50*k)
          ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

N=int(input())
S=input()
K=int(input())

L = []
for i in range(N):
    if S[i] != S[K-1]:
        L.append("*")
    else:
        L.append(S[i])

ans = ''
for i in range(N):
    ans += L[i]

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	int n;

	cin >> n;
	for(int X = 0; X < n; ++X){
		int st, ed;
		queue<int> q;
		cin>>st>>ed;

		if( st == ed ){
			cout << "\n";
			continue;
		}

		if( ed <= 5 ){
			if( st > 5 ){
				for(int i = st; i <= 9; ++i) q.push( i ); 
				for(int i = 5; i >= ed; --i) q.push( i );
			}else{
				if( st > ed )
					for(int i = st; i >= ed; --i) q.push( i );
				else
					for(int i = st; i <= ed; ++i) q.push( i );
			}
		}else{
			if( st < ed ){
				for(int i = st; i <= ed; ++i) q.push( i );
			}else{
				for(int i = st; i <= 9; ++i) q.push( i );
				for(int i = 5; i >= 0; --i) q.push( i );
				for(int i = 1; i <= ed; ++i) q.push( i );
			}
		}
		cout << q.front();
		q.pop();
		while( !q.empty() ){
			cout << ' ' << q.front();
			q.pop();
		}
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int x, y, A, B, C;
    cin >> x >> y >> A >> B >> C;
    multiset <int> a;
    forn (i, 0, A) {
        int t;
        cin >> t;
        a.insert(t);
        if (sz(a) > x)
            a.erase(a.begin());
    }
    multiset <int> b;
    forn (i, 0, B) {
        int t;
        cin >> t;
        b.insert(t);
        if (sz(b) > y)
            b.erase(b.begin());
    }
    vector <int> c(C);
    cin >> c;
    sort(rall(c));
    long long ans = 0;
    forn (i, 0, C) {
        if (sz(a) < x) {
            a.insert(c[i]);
        } else if (sz(b) < y) {
            b.insert(c[i]);
        } else if (sz(a) == x && sz(b) == y) {
            if (*a.begin() < *b.begin()) {
                a.insert(c[i]);
                a.erase(a.begin());
            } else {
                b.insert(c[i]);
                b.erase(b.begin());
            }
        }
    }
    for (int i : a)
        ans += i;
    for (int i : b)
        ans += i;
    cout << ans;
    return 0;
}

Measured memory_bytes: 9088
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    let x=read::<i32>();
    let mut cnt=0;
    for i in 0..a+1{
        for j in 0..b+1{
            for k in 0..c+1{
                if 500*i+100*j+50*k==x{cnt+=1}
            }
        }
    }
    println!("{}",cnt)
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc164b
{
    class Program
    {
        static void Main(string[] args)
        {
            //==========================================================================================================================
            //1) input
            List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            int t_hp = input[0];
            int t_ap = input[1];
            int a_hp = input[2];
            int a_ap = input[3];

            int count = 2;
            while (!(t_hp <= 0) && !(a_hp <= 0))
            {
                if (count % 2 == 0)
                {
                    a_hp -= t_ap;
                }
                else
                {
                    t_hp -= a_ap;
                }
                count++;
            }


            //==========================================================================================================================
            //2) output
            string output = "Yes";
            if (t_hp <= 0)
            {
                output = "No";
            }


            Console.WriteLine(output);

        }
    }
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}

int n, a[2000005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n;

    for (int i = 0; i < n; ++i)
        std::cin >> a[i];

    int first = std::max(a[0], a[1]), second = std::min(a[0], a[1]);
    int fp = (a[0] > a[1] ? 0 : 1), sp = (fp + 1) % 2;
    for (int i = 2; i < n; ++i) {
        if (a[i] >= first) {
            second = first;
            first = a[i];
            sp = fp;
            fp = i;
        }
        else if (a[i] >= second) {
            second = a[i];
            sp = i;
        }
    }

    for (int i = 0; i < n; ++i)
        if (i != fp)
            std::cout << first << std::endl;
        else
            std::cout << second << std::endl;

    return 0;
}


Measured memory_bytes: 2432
def main():
    s = input() # 入力文字列
    out =''
    for i in s:
        if (out=='')and(i=='B'):
        # outが空かつbackspaceのときはなにもしない
            pass
        elif (i=='B'):
            out = out[:-1] # 最後の文字列[-1]までを代入，pyでは[0:n]のときn-1までをいれる
        else:
            out = out + i
    print(out)
main()

Measured memory_bytes: 2940
#include <iostream>

const int MAX_N = 100;
const int MAX_M = 100;

int vectorCulculation(int[], int[], int);

int main(){
	int A[MAX_N][MAX_M] = {};
	int b[MAX_M] = {};
	int n;
	int m;
	
	std::cin >> n >> m;

	/*ベクトルAの入力*/
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < m; ++j){
			std::cin >> A[i][j];
		}
	}

	/*ベクトルbの入力*/
	for (int i = 0; i < m; ++i){
		std::cin >> b[i];
	}

	/*ベクトルcの出力*/
	for (int i = 0; i < n; i++)
	{
		std::cout << vectorCulculation(A[i], b, m) << std::endl;
	}
}

int vectorCulculation(int a[], int b[], int m){
	int ci = 0;
	for (int i = 0; i < m; ++i){
		ci += a[i] * b[i];
	}
	return ci;
}


Measured memory_bytes: 3168
#include<iostream>
// #include<stdlib.h>
using namespace std;

int main(){
    long long int N,K;
    cin >> N >> K;
    
    long long int min;
    long long int r, s;
    r=N%K;
    s=-(r-K);

    if(N<=K){
        if(N<K-N){
            min=N;
        }
        else{
            min=K-N;
        }
    }
    else if(N>K){
        if(r>s){
        min=s;
        }
        else{
            min=r;
        }
    }
    
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x,y,xx,yy;
    cin>>x>>y>>xx>>yy;
    cout<<y-yy+xx<<" "<<-x+xx+yy<<" "<<y-yy+x<<" "<<xx-x+y<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G,T INF){
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
	d[u]=d[v]+c;
	b[u]=v;
	q.emplace(d[u],u);
      }
    }
  }
  return d;
}


template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

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

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

//INSERT ABOVE HERE
signed main(){
  Int n,m,s,t,U,V;
  cin>>n>>m>>s>>t>>U>>V;
  s--;t--;U--;V--;
  
  const Int INF=1e16;

  using P = pair<Int, Int>;
  vector<vector<P> > G(n);
  for(Int i=0;i<m;i++){
    Int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G[a].emplace_back(b,c);
    G[b].emplace_back(a,c);
  }

  auto ds=dijkstra(s,G,INF);
  auto dt=dijkstra(t,G,INF);
  assert(ds[t]==dt[s]);
  Int L=ds[t];

  using TP=tuple<Int, Int, Int>;
  
  vector<vector<TP> > T(n);
  for(Int v=0;v<n;v++){
    for(auto e:G[v]){
      Int u,c;
      tie(u,c)=e;
      if(ds[v]+dt[v]==L&&ds[u]+dt[u]==L&&
	 (ds[u]+c==ds[v]||ds[v]+c==ds[u]))
	T[v].emplace_back(u,c,(ds[u]+c==ds[v])+1);
      else T[v].emplace_back(u,c,0);
    }
  }

  auto dp=make_v<Int>(4,n);
  fill_v(dp,INF);
  
  priority_queue<TP,vector<TP>,greater<TP> > pq;

  dp[0][U]=0;
  pq.emplace(dp[0][U],0,U);
  
  while(!pq.empty()){
    Int d,c,v;
    tie(d,c,v)=pq.top();pq.pop();
    if(dp[c][v]<d) continue;
    //cout<<d<<" "<<c<<" "<<v<<endl;
    for(auto e:T[v]){
      Int u,nc,nd;
      tie(u,nc,nd)=e;
      Int nt=-1;
      if(c==0){
	if(nd){
	  nt=nd;
	  if(dp[nt][u]>d){
	    dp[nt][u]=d;
	    pq.emplace(dp[nt][u],nt,u);
	  }
	}
	nt=c;
	if(dp[nt][u]>d+nc){
	  dp[nt][u]=d+nc;
	  pq.emplace(dp[nt][u],nt,u);
	}
      }
      if(c==1||c==2){
	if(c==nd){
	  nt=c;
	  if(dp[nt][u]>d){
	    dp[nt][u]=d;
	    pq.emplace(dp[nt][u],nt,u);
	  }
	}
	nt=3;
	if(dp[nt][u]>d+nc){
	  dp[nt][u]=d+nc;
	  pq.emplace(dp[nt][u],nt,u);
	}
      }
      if(c==3){
	nt=3;
	if(dp[nt][u]>d+nc){
	  dp[nt][u]=d+nc;
	  pq.emplace(dp[nt][u],nt,u);
	}
      }
    }
  }
  
  cout<<min({dp[0][V],dp[1][V],dp[2][V],dp[3][V]})<<endl;
  return 0;
}



Measured memory_bytes: 44816
def match(i, j):
    if i == j: return True
    elif i == "?" or j == "?": return True
    else: return False

def solve():
    s = input()
    t = input()
    Ans = []
    for i in range(len(s) - len(t) + 1):
        #check
        l = list(s)
        for j in range(len(t)):
            if match(s[i + j], t[j]): 
                if s[i + j] == "?": l[i + j] = t[j]
            else: break
        else: #一致する
            for k, w in enumerate(l):
                if w == "?": l[k] = "a"
            Ans.append("".join(map(str, l)))
    if len(Ans) == 0: print("UNRESTORABLE")
    else: 
        Ans.sort()
        print(Ans[0])

    return 0

if __name__ == "__main__":
    solve()
            
            


Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  string A,B,C;

  cin >> A >> B >> C;
  cout << ((A[A.length()-1]==B[0])&&(B[B.length()-1]==C[0])?"YES":"NO") << endl;

  return 0;
}

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

using namespace std;

void solve() {
  int N, M;
  string s;
  deque<int> ans;

  cin >> N >> M;
  cin >> s;

  int cur = N;
  while (cur > 0) {
    int left = max(cur - M, 0);
    while (s.at(left) == '1') {
      ++left;
      if (left == cur) {
        cout << -1 << endl;
        return;
      }
    }
    ans.push_front(cur - left);
    cur = left;
  }

  for (auto it = ans.begin(); it != ans.end(); it++) {
    if (it != ans.begin()) {
      cout << " ";
    }
    cout << *it;
  }
  cout << endl;
}

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



Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int n;
	cin>>n;
	int ans=0;
	for(int i=0; i<n; i++){
		int s,f;
		cin>>s>>f;
		if( (a>=f) || (b<=s)) int k;
		else ans=1;
	}
	cout<<ans<<endl;
}
			


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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'

int main() {
    int r;
    cin >> r;
    int s = 3*r*r;
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int A[] = new int[N+1];
        
        for(int i = 0; i < N; i++ ) {
            int x = sc.nextInt();
            A[x]++;
        }
        
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        
        for(int i = 0; i < N + 1; i++ ) {
            if( A[i] > 0 ) {
                pq.add( A[i] );
            }
        }
        
        int ans = 0;
        
        while(true) {
            if( pq.size() <= K ) {
                break;
            }
            
            ans += pq.poll();
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60176
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,ll> P;


int main(void){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int len=0;
    int prev=0;
    for(int i=0;i<n;i++){
        if(prev+1==a[i]){
            len++;
            prev=a[i];
        }
    }
    if(prev==0)cout<<-1<<endl;
    else cout<<n-len<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))


a, b, x = LI()
acnt = (a - 1) // x if a > 0 else -1
bcnt = b // x if b != 0 else 1
ans = bcnt - acnt if not(a == b == 0) else 1
print(ans)


Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
     
int main(){
  int N,ans=0,x=0;
  string s;
  cin>>N>>s;
  for(int i=0;i<N;i++){
    if(s[i]=='I'){
      x++;
      if(ans<x)ans=x;
    }else {
      x--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] x = new int[n];
        int[] y = new int[n];

        for (int i=0; i<n; i++) {
            x[i] = sc.nextInt();
        }
        for (int i=0; i<n; i++) {
            y[i] = sc.nextInt();
        }

        int[] P = new int[n];

        for (int i=0; i<n; i++) {
            P[i] = Math.abs(x[i] - y[i]);
        }

        double p1 = 0;
        double p2 = 0;
        double p3 = 0;
        double pi = 0;

        for (int i=0; i<n; i++) {
            p1 += P[i];
        }

        for (int i=0; i<n; i++) {
            p2 += Math.pow(P[i], 2);
        }
        p2 = Math.sqrt(p2);

        for (int i=0; i<n; i++) {
            p3 += Math.pow(P[i], 3);
        }
        p3 = Math.pow(p3, 1.0/3);

        for (int i=0; i<n; i++) {
            if (pi < P[i])
                pi = P[i];
        }

        System.out.println(p1);
        System.out.println(p2);
        System.out.println(p3);
        System.out.println(pi);


    }
}


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

int main(void){
    int n, k;
    cin >> n >> k;
    int i = 0;
    while(n>k+(k-1)*i){
        i++;
    }
    cout << ++i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
const int dx[4] = {1, 0, 0, -1}, dy[4] = {0, 1, -1, 0};
int H, W;
map<char, int> dir;
map<int, char> dir2;
string ans;
bool range_out(int x, int y){
    return x < 0 || y < 0 || W <= x || H <= y;
}
bool dfs(const vector<string>& pond, int cx, int cy, int cd, int leaves, string score){
    if(leaves == 0){
        ans = score;
        return true;
    }
    
    rep(i, 4){
        if(i == 3 - cd) continue;
        int nx = cx, ny = cy;
        bool end = false;
        while(true){
            nx += dx[i]; ny += dy[i];
            if(range_out(nx, ny)){
                end = true;
                break;
            }
            if(pond[ny][nx] == 'o') break;
        }
        if(end) continue;
        vector<string> temp = pond;
        temp[ny][nx] = '.';
        string st = score + dir2[i];
        if(dfs(temp, nx, ny, i, leaves - 1, st)) return true;
    }
    return false;;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    vector<string> pond(H);
    rep(i, H) cin >> pond[i];
    int sx, sy, sd;
    int leafnum = 0;
    dir['U'] = 2; dir['D'] = 1; dir['L'] = 3; dir['R'] = 0;
    for(const auto& k : dir) dir2[k.second] = k.first;
    rep(i, H) rep(j, W){
        if(pond[i][j] == 'o')
          leafnum++;
        if('A' <= pond[i][j] && pond[i][j] <= 'Z'){
            sx = j; sy = i;
            sd = dir[pond[i][j]];
            pond[i][j] = '.';
        }
    }
    string hoge = "";
    dfs(pond, sx, sy, sd, leafnum, hoge);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3212
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> list = new ArrayList<>();
        for(int i = 0; i  < n; i++) {
        	String s = normalize(sc.next());
        	list.add(s);
        }

        list.add("zzzzzzzzzzzzzzzzzz");//dummy
        Collections.sort(list);

        long ans = 0;
        for(int i = 0; i < list.size(); i++) {
        	for(int j = i + 1 ; j < list.size(); j++) {
        		if( ! list.get(i).equals(list.get(j))) {
        			ans += (comb(j - i));
        			i = j -1 ;
        			break;
        		}
        	}
        }
        System.out.println(ans);
	}

	public static long comb(long num) {
		return num * (num-1) / 2;
	}

	public static String normalize(String s) {
		int [] num = new int [26];
		for(int i = 0; i < s.length(); i++) {
			int ch = s.charAt(i) - 'a';
			num[ch]++;
		}
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < 26; i++) {
			char c = (char)('a' + i);
			for(int j = 0; j < num[i]; j++) {
				sb.append(c);
			}
		}
		return sb.toString();
	}
}

Measured memory_bytes: 66292
from math import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
N,M = map(int,input().split())
S = input()
T = input()
g = gcd(N,M)
l = lcm(N,M)
for i in range(g):
    if S[l//M*i] != T[l//N*i]:
        print(-1)
        exit()
print(l)

Measured memory_bytes: 64440
#include <map>
#include <iostream>

using namespace std;

const int Maxn = 107;

int n;
char last;
string str;
map<string, int> m;

int main()
{
    cin >> n >> str;
    m.insert(make_pair(str, 1));
    last = str[str.length()-1];
    for(int i = 1; i < n; ++i)
    {
        cin >> str;
        if(str[0] != last || m.count(str))
        {
            cout << "No" << endl;
            return 0;
        }
        m.insert(make_pair(str, 1));
        last = str[str.length()-1];
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define DB long double
using namespace std;
//#define P 998244353
//inline int ad(int x,int y){return (x+y>=P)?(x+y-P):(x+y);}
//inline int mt(int x,int y){return 1ll*x*y%P;}
//inline void mo(int &x){x=(x>=P)?(x-P):x; x=(x<0)?(x+P):x;}
template<typename T>inline void ckmx(T &x,T y){x=max(x,y);}
template<typename T>inline void ckmi(T &x,T y){x=min(x,y);}
template<typename T>void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-48;
	x*=f;
}
int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}
int a[100010];
int ans[1000010],an,n;
int p[1000010],ss[100010],ssn;
int f[100010];
int tmp[100010];
int main(){
	for(int i=1;i<=1000000;++i) p[i]=i;
	for(int i=2;i<=1000000;++i){
		if(p[i]==i) ss[++ssn]=i;
		for(int j=1;j<=ssn;++j){
			if(i*ss[j]>1000000||p[i]<ss[j]) break;
			p[i*ss[j]]=ss[j];
		}
	}
	read(n);
	int gc=0;
	for(int i=0;i<=n;++i){
		read(a[n-i]);
		gc=gcd(gc,abs(a[n-i]));
	}
	int sv=gc;
	for(int i=2;i*i<=gc;++i)
	if(gc%i==0){
		f[i]=1; ans[++an]=i;
		while(gc%i==0) gc/=i;
	}
	if(gc!=1) {
		ans[++an]=gc;
		if(gc<=n) f[gc]=1;
	}
	gc=sv;
	for(int i=2;i<=n;++i)
	if(p[i]==i&&(!f[i])){
		for(int j=0;j<=n;++j) tmp[j]=a[j]%i;
		for(int j=n;j>=i;--j)
			tmp[j-i+1]=(tmp[j-i+1]+tmp[j])%i,tmp[j]=0;
		int f=1;
		for(int j=i;j>=0&&f;--j)
			f&=(tmp[j]==0);
		if(f) ans[++an]=i;
	}
	sort(ans+1,ans+1+an);
	for(int i=1;i<=an;++i)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 5632
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int a[1000];
    int cnt5 = 0, cnt7 = 0;
    for(int i = 0; i < 3; i++){
        int t;
        cin>>t;
        if(t == 5)cnt5++;
        else if(t == 7)cnt7++;
    }
    if(cnt5 == 2 && cnt7 == 1)cout<<"YES";
    else cout<<"NO";

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int f[3][101],a[3][101];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			f[i][j]=fmax(f[i-1][j],f[i][j-1])+a[i][j];
		}
	}
	printf("%d\n",f[2][n]);
	return 0;
}

Measured memory_bytes: 128
s = input()
j = int(s[:2])
k = int(s[2:])
if 0 < j <= 12 and 0 < k <= 12:
    print("AMBIGUOUS")
elif 0 <= j <= 99 and 0 < k <= 12:
    print("YYMM")
elif 0 <= k <= 99 and 0 < j <= 12:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		var x = 1;
		while (true)
		{
			var a = int.Parse(Console.ReadLine());
			if (a == 0) break;
			System.Console.WriteLine("Case " + x++ + ": " + a);
		}
	}
}


Measured memory_bytes: 15928
#include<iostream>
#include<algorithm>
using namespace std;
#define N 100010
int main(void)
{
	int n,m,h[N],ma[N];
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		ma[i]=0;
	}
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		ma[a]=max(ma[a],h[b]);
		ma[b]=max(ma[b],h[a]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=h[i]>ma[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4336
using System;
using System.Linq;
using static System.Console;
using static System.Math;

namespace abc79_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var op = new string[3];

            for(int i=0; i<(1<<3); i++){
                int sum=int.Parse(str[0].ToString());
                for(int j=0; j<3; j++){
                    if((i>>j & 1) == 1){
                        sum += int.Parse(str[j+1].ToString());
                        op[j] = "+";
                    }else{
                        sum -= int.Parse(str[j+1].ToString());
                        op[j] = "-";
                    }
                }

                if(sum == 7){
                    WriteLine($"{str[0]}{op[0]}{str[1]}{op[1]}{str[2]}{op[2]}{str[3]}=7");
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 13140
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def longest_common_subsequence(S, T):
    """compute table dp satisfying: 
    dp[i,j] = LCS(S[:i], T[:j])"""
    LS, LT = len(S), len(T)
    dp = np.zeros((LS + 1, LT + 1), np.int32)
    for n in range(1, LS + 1):
        dp[n, 1:] = dp[n - 1, :-1] + (S[n - 1] == T)  # 左上から
        np.maximum(dp[n], dp[n - 1], out=dp[n])  # 上から
        np.maximum.accumulate(dp[n], out=dp[n])  # 左から
    return dp


def reconstruct_LCS(S, T, dp):
    tmp = []
    i, j = len(S), len(T)
    while i > 0 and j > 0:
        if S[i - 1] == T[j - 1]:
            i, j = i - 1, j - 1
            tmp.append(S[i])
        elif dp[i, j] == dp[i - 1, j]:
            i -= 1
        else:
            j -= 1
    return ''.join(reversed(tmp))

S = np.array(list(readline().decode()), 'U1')[:-1]
T = np.array(list(readline().decode()), 'U1')[:-1]
dp = longest_common_subsequence(S, T)

print(reconstruct_LCS(S, T, dp))

Measured memory_bytes: 62236
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[100];
int b[100];
int c[100];
int d[100];
int dp[100];

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;
}


Measured memory_bytes: 256
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    N, W = map(int, input().split())
    items = [0] * N

    for i in range(N):
        w, v = map(int, input().split())
        items[i] = (v, w)

    dp = [0] * (W + 1)

    for value, weight in items:
        for w in range(W + 1)[:: -1]:
            if w - weight >= 0:
                dp[w] = max(dp[w], dp[w - weight] + value)

    print(dp[W])

sol()

Measured memory_bytes: 39920
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PAIR pair<double, double>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
#define PI acos(-1)
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

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

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

int main(){
	vector<int> line;
	int N;
	int K;
	cin >> N;
	cin >> K;
	string str;
	cin >> str;
	line.push_back(1);
	char bc = str.front();
	REPA(i, N){
		if(bc==str[i])++line.back();
		else{
			line.push_back(1);
			bc = str[i];
		}
	}
	cout << min(N-1, N - (int)line.size() + K * 2) << endl;

	return 0;
}


Measured memory_bytes: 1020
#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[i];
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  vector<int> p;
  for (int i = 1; i <= 30; i++){
    p.push_back(1 << i);
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++){
    B[i] = *upper_bound(p.begin(), p.end(), A[i]) - A[i];
  }
  set<pair<int, int>> A2;
  for (int i = 0; i < N; i++){
    A2.insert(make_pair(A[i], i));
  }
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (A2.count(make_pair(A[i], i))){
      auto itr = A2.lower_bound(make_pair(B[i], 0));
      if ((*itr).first == B[i] && (*itr).second != i){
        A2.erase(itr);
        A2.erase(make_pair(A[i], i));
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 14356
use std::io::*;
use std::str::*;
use std::cmp::max;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let k: usize = read().unwrap();
    let n: usize = read().unwrap();
    let mut a: Vec<usize> = Vec::new();
    for _ in 0..n {
        a.push(read().unwrap());
    }
    let mut max_dist = k - a[n - 1] + a[0];
    // let mut dist: Vec<usize> = Vec::new();
    for n_i in 1..n {
        max_dist = max(max_dist, a[n_i] - a[n_i - 1]);
    }
    println!("{:?}", k - max_dist);
}

Measured memory_bytes: 6396
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>

using namespace std;
char square[10000][10000];
int a = 0;
int b = 0;
long long TaroSquare[10000][10000];
int h, w;
int main()
{

    TaroSquare[0][0] = 1;
    cin >> h >> w;
    for(int i = 0;  i< h; i++)
        for(int j = 0; j < w; j++)
            cin >> square[i][j];
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
        {
            for(int p = 0; p < 2; p++)
            {
                if(p == 0)
                {
                    a = i - 1;
                    b = j;
                    if( a < 0 || b < 0) continue;
                    if(square[a][b] == '#') continue;
                    TaroSquare[i][j] = TaroSquare[i][j] + TaroSquare[a][b];
                    TaroSquare[i][j] = TaroSquare[i][j] %1000000007;

                }
                else if(p == 1)
                {
                    a = i;
                    b = j - 1;
                    if( a < 0 || b < 0) continue;
                    if(square[a][b] == '#') continue;
                    TaroSquare[i][j] = TaroSquare[i][j] + TaroSquare[a][b];
                    TaroSquare[i][j] = TaroSquare[i][j] %1000000007;
                }
            }
        }
    cout << TaroSquare[h - 1][w - 1];
}

Measured memory_bytes: 90624
#include <stdio.h>

int main(void){

  long n,k,q;
  scanf("%ld %ld %ld", &n, &k, &q);
  long a[q];
  for (long i = 0; i < q; i++) {
    scanf("%ld", &a[i]);
  }
  long list[n];
  for (long i = 0; i < n; i++) {
    list[i] = 0;
  }
  for (long i = 0; i < q; i++) {
    list[a[i]-1]++;
  }
  for (long i = 0; i < n; i++) {
    list[i] = q-list[i];
    if (list[i] < k) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }

  return 0;
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    vll sumA(N + 1);
    rep(i, N) sumA[i + 1] = sumA[i] + A[i];
    
    ll sumq[4];
    sumq[0] = A[0], sumq[1] = A[1];
    sumq[2] = A[2], sumq[3] = sumA[N] - sumA[3];
    int q1 = 1;
    int q3 = 3;
    for (; q3 < N - 1; ) {
        if (abs(sumq[2] - sumq[3] + 2 * A[q3]) < abs(sumq[2] - sumq[3])) {
            sumq[2] += A[q3];
            sumq[3] -= A[q3];
            q3++;
        }
        else break;
    }

    ll ans = *max_element(sumq, sumq + 4) - *min_element(sumq, sumq + 4);
    for (int half = 2; half < N - 2; ) {
        sumq[1] += A[half];
        sumq[2] -= A[half];
        half++;
        for (; q1 < half - 1; ) {
            if (abs(sumq[0] - sumq[1] + 2 * A[q1]) < abs(sumq[0] - sumq[1])) {
                sumq[0] += A[q1];
                sumq[1] -= A[q1];
                q1++;
            }
            else break;
        }

        for (; q3 < N - 1; ) {
            if (abs(sumq[2] - sumq[3] + 2 * A[q3]) < abs(sumq[2] - sumq[3])) {
                sumq[2] += A[q3];
                sumq[3] -= A[q3];
                q3++;
            }
            else break;
        }

        ans = min(ans, *max_element(sumq, sumq + 4) - *min_element(sumq, sumq + 4));
    }

    write(ans);
}

Measured memory_bytes: 3328
# https://atcoder.jp/contests/abc093/tasks/abc093_a


import itertools
import collections
import bisect

def main():
    S = input()
    if all(c in S for c in ['a', 'b', 'c']):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#define ll long long
#define endl '\n'
using namespace std;

int main(void)
{
  cin.tie(NULL); ios_base::sync_with_stdio(false);
  int N; cin >> N;
  set<int> st;
  while(N--)
    {
      int a; cin >> a;
      if(st.find(a) == st.end())
	{
	  st.insert(a);
	}
      else
	{
	  st.erase(a);
	}
    }
  cout << st.size() << endl;
  return 0;
}



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

int main(){
    string s; cin >> s;

    ll a, b, c;
    a = b = c = 0;
    for(auto x : s){
        if(x == 'a') a++;
        else if(x == 'b') b++;
        else if(x == 'c') c++;
    }

    if(s.size() == 1){
        put("YES");
    }else if(max({a,b,c}) - min({a,b,c}) > 1){
        put("NO");
    }else{
        put("YES");
    }
}

Measured memory_bytes: 3792
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	//var length = parseInt(input[0], 10);
  var num = tmp[0];
  var base  = input[1];
  var arr= String(base).split('');
	//出力
  var x = 0;
  var max = 0;
  //var num = arr.length;

  for (var i = 0; i < num; i++) {
    if (arr[i]=="I") {
      x += 1;
      if (max >= x) {
        max = max;
      }else {
        max = x;
      }
    }else if (arr[i]=="D") {
      x -= 1;
      }
    }
	console.log('%d',max);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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; }


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

    ll n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    vector<bool> isSameCharWithBeforeK(n, false);

    ll sum = 0;

    for (int i = 0; i < n; i++)
    {
        if (!isSameCharWithBeforeK[i]) {
            if (i + k < n && t[i] == t[i + k]) {
                isSameCharWithBeforeK[i + k] = true;
            }
            if (t[i] == 'r') {
                sum += p;
            }
            if (t[i] == 'p') {
                sum += s;
            }
            if (t[i] == 's') {
                sum += r;
            }
        }
    }

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 512